Runa ã¨ãã Ruby 㧠Gem ã使ã£ããè¤æ°ãã¡ã¤ã«ã§æ§æãããä¸è¦æ¨¡ã®ã¢ããªã±ã¼ã·ã§ã³ãç°¡åã«æ¸ãããã®ãã¬ã¼ã ã¯ã¼ã¯ãä½ã£ã¦ãã¾ãã
Runa ãä½ã£ãçµç·¯
- Ruby ã¯åç¬ã®ã¹ã¯ãªãããã¡ã¤ã«ã¨ãã¦å®è¡ããã¨ãã¯åãåããç°¡åã§å¤§å¤ä½¿ãããã(å°è¦æ¨¡ã¢ããªã±ã¼ã·ã§ã³)
- ããç¹å®ã® gem ã«ä¾åãããè¤æ°ãã¡ã¤ã«ã§æ§æããããããªã¢ããªã±ã¼ã·ã§ã³ãä½ããã¨ããã¨ã¹ã¿ã³ãã¼ããªæ¹æ³ãç¨æããã¦ããã(ç¹ã«é å¸ãå ±æã®ãã¨ãèããã¨)æ·å± ãé«ããªã£ã¦ãã¾ã(ä¸è¦æ¨¡ã¢ããªã±ã¼ã·ã§ã³)
- ãããä»ã¾ã§ä½ãåé¡ã«ãªããªãã£ãã®ã¯ãWeb ã¢ããªã§ããã° Rails ããã®è¾ºããé¢åãã¿ã¦ãããããã³ã³ã½ã¼ã«ã¢ããªã±ã¼ã·ã§ã³ãªã gem ã§é å¸ããã¿ãããªæ¹æ³ã§ãããããã¦ããçµç·¯ããããããã gem ã§é å¸ããã«ã¯ RubyGems ã®ã¢ã«ã¦ã³ããå¿ è¦ã ã£ãããæ¨ä»ã®ã»ãã¥ãªãã£åé¡ãªã©ãèããã¨æãã¤ãã®ã¢ããªã±ã¼ã·ã§ã³ãæ°è»½ã«ç½®ããããªæãã§ã¯ãã§ã«ç¡ããªã£ã¦ããæ°ããã(大è¦æ¨¡ã¢ããªã±ã¼ã·ã§ã³)
- ç§ãæ®æ®µä½ãããã®ã¯å人çãªåé¡ãæãä»ãã§è§£æ±ºããã¡ãã£ã¨ããã¢ããªã±ã¼ã·ã§ã³ã§ããé å¸ã¯ã¬ãã¸ããªä½ã£ããã使ããã人ã¯ã©ããä½ã«ããã
ããã§æ®æ®µä½¿ãã®ã¢ããªã±ã¼ã·ã§ã³ãæ°è»½ã«ä½ããããã«ããããã« Runa ãä½ãã¾ãããRuby ã«ã¯ Bundler ã¨ããåªããä¾åé¢ä¿ç®¡çãã¼ã«ããã§ã«åå¨ãã¦ãããå®éã®ã¨ãã Runa 㯠Bundler ã®ã©ã¹ãã¯ã³ãã¤ã«ãåããèãã©ããã¼ã§ãã
Runa ã®ã¤ã³ã¹ãã¼ã«
gem ã§ã¤ã³ã¹ãã¼ã«ãã¾ããruna
ã³ãã³ãã使ããããã«ãªãã®ã§ä»¥å¾ã¯ããã使ãã¾ãã
$ gem install runa
runa new ã¢ããªã±ã¼ã·ã§ã³å
ã§ããã¸ã§ã¯ããä½æãã¾ãããã£ã¬ã¯ããªãã§ããã®ã§ä¸ã«ç§»åãã¾ãã
$ runa new hello Created 'hello' application. $ cd hello
Gem ã®è¿½å ãè¤æ°ãã¡ã¤ã«ã®ã¢ããªã±ã¼ã·ã§ã³ä½æã«å¿ è¦ãªãã®ãèªåã§è¿½å ããã¦ãã¾ãã
$ ls .bundle/ .runa/ lib/ .gitignore Gemfile hello.rb
runa run ã¹ã¯ãªããå
ã§å®è¡ãã¾ããruna run
ã§å®è¡ããã¨è¿½å ãã Gem ã lib/ 以ä¸ã¸ã®ãã¹ãéã£ãç¶æ
ã§å®è¡ããã¾ãã
$ runa run .\hello.rb Hello, world!
Launchy Gem ã追å ãã¦ã¿ã¾ããGem ã®è¿½å ã«ã¯runa gem_add Gemå
ã使ãã¾ãã(bundle install
ããå¾ã« runa install
ã§ã OK)
$ runa gem_add launchy . . Installing launchy 2.5.2 Generate '.runa/runa_load_path.rb'
ãã㧠hello.rb ãã require "launchy"
ãå¯è½ã«ãªãã¾ãã
require "hello" require "launchy" url = "https://www.ruby-lang.org" Launchy.open(url) puts "Hello, #{url}"
å®è¡ããã¨ãã©ã¦ã¶ã§ https://www.ruby-lang.org/ ãéããããã«ãªãã¾ãã
Runa ã¢ããªã±ã¼ã·ã§ã³ããããã¤ãã
ããã¾ã§ã¯ bundler ã ãã§ãé å¼µãã°ã§ããã¨æãã¾ãã
Runa ã使ãã¨ä½æããã¹ã¯ãªãããèµ·åããããã®å®è¡ãã¡ã¤ã«(ã·ã§ã«ã¹ã¯ãªãããWindowsãªãããããã¡ã¤ã«)ãç°¡åã«ä½æãããã¨ãã§ãã¾ãããããä¸çªã®ç¹å¾´ã§ããç§ã¯ãã®èµ·åã¹ã¯ãªããã PATH ã®éã£ãå ´æã«é ç½®ãã¦ãã¾ãã
å®è¡ãã¡ã¤ã«ã®ä½æã«ã¯ runa deploy
ã³ãã³ãã使ãã¾ãã(ããã§ã¯ ../bin
ã«ãã¹ãéã£ã¦ããã¨ä»®å®ãã¦ãã¾ã)
$ runa deploy hello.rb ../bin Generate '.runa/runa_load_path.rb' Deploy execution script to '../bin/hello.bat'.
ãããã¤ããããããã¡ã¤ã«(ãããã¯ã·ã§ã«ã¹ã¯ãªãã)㯠runa ã³ãã³ããçµç±ããã«ã·ã§ã«ããå®è¡ãããã§ãã¾ãã(ã¤ã¾ã .exe
ã¨åã)
$ ../bin/hello $ hello # (注) PATH ãéã£ã¦ããã° Hello, https://www.ruby-lang.org (ãã©ã¦ã¶èµ·å)
Win+R ãããç´æ¥å®è¡ã§ãã¾ãã
ãããã¤ããã¢ããªã±ã¼ã·ã§ã³ã®æåãå¤æ´ãã
å®è¡ç¨ãã¡ã¤ã«ã®å®ä½ã¯å
ã
ä½ã£ã runa ã¬ãã¸ããªãªã®ã§ãhello.rb
ãå¤æ´ããã°ã¢ããªã±ã¼ã·ã§ã³ã®æåãå¤æ´ãããã¨ãã§ãã¾ãããã®ã¨ããåãããã¤ã¯ä¸è¦ãã§ãããã㯠gem ã追å ããã¨ããåæ§ã§ãã
ä¾ã¨ã㦠hello ã¢ããªã±ã¼ã·ã§ã³ã« clipboard gem ã追å ãã¦ãç¹å®ã®ãã¼ã¸ãéãã¤ã¤ URL ãã¯ãªãããã¼ãã«ã³ãã¼ãã¦ã¿ã¾ããã¾ã㯠clipboard gem ãã¤ã³ã¹ãã¼ã«ãã¾ãã
$ runa gem_add clipboard . . Generate '.runa/runa_load_path.rb'
hello.rb
ãæ¸ãæãã¾ãã
require "hello" require "launchy" + require "clipboard" url = "https://www.ruby-lang.org" Launchy.open(url) puts "Hello, #{url}" + Clipboard.copy(url)
åãããã¤ã¯ä¸è¦ãªã®ã§ãã®ã¾ã¾ã³ãã³ãã©ã¤ã³ã Win+R ãã hello
ãå®è¡ãã¾ãã
$ hello Hello, https://www.ruby-lang.org (ãã©ã¦ã¶èµ·åï¼ã¯ãªãããã¼ãã« https://www.ruby-lang.org ãã³ãã¼ããã)
åãã«ãä¸è¦ã§ã¢ããªã±ã¼ã·ã§ã³ã®æåãå¤æ´ãããã¨ãã§ããã®ã¯ããªã便å©ã§ãã
ä»ã®äººã®ä½¿ã£ã Runa ã¢ããªã±ã¼ã·ã§ã³ã使ã
Runa ã§ä½ãããã¢ããªã±ã¼ã·ã§ã³ã¯ä»ã®äººã®ç°å¢ã§ãç°¡åã«åãããã¨ãã§ãã¾ããããã§ã¯å ã»ã©ä½ã£ã hello ã¢ããªã±ã¼ã·ã§ã³ãåããã¦ã¿ã¾ãã
$ git clone https://github.com/ongaeshi/hello.git cd hello $ runa install $ runa run hello.rb
ã¨ã¦ãç°¡åã§ããããããã¤ãç°¡åã§ãã
$ runa deploy hello.rb /path/to/bin
æå¾ã« gosu ã使ã£ãã²ã¼ã ã runa ã§åããã¦çµããã«ãã¾ãã
$ git clone https://github.com/ongaeshi/minesweeper.git cd minesweeper $ runa install $ runa run hello.rb
ãããã«
ç§ãèªåç¨ã«ä½ã£ããã®ã¯ongaeshi/toolbox ã«ç½®ãã¦ããã¾ããsrc2urlã¨ããæ°ã«å ¥ãã§ãã使ã£ã¦ãã¾ãã
ã¿ãªããããæ°ã«å ¥ãã®ã¢ããªã±ã¼ã·ã§ã³ã runa ã§ä½ã£ã¦æ°è»½ã«å ¬éãã¦ãã ããï¼