LoginSignup
5
5

More than 5 years have passed since last update.

Ruboty で ruby を実行する

Last updated at Posted at 2015-03-01

朝から BestGems を眺めていたら、自分が先週作った ruboty プラグインが (ruboty- で絞り込んだ中で)下から3番目だったという事実を知ったので宣伝させてください...

作ったもの

なにができるの?

ruboty が ruby のコードを評価できるようになります。
ruby|rb|irb のキーワードに続けて rubyのコードを渡すと、実行結果を返してくれます。

実行イメージは下記の感じです。

ryutaro [2:40 PM] ruboty: ruby (["hello world"] * 3).join(' * ')
ruboty  [2:41 PM] => "hello world * hello world * hello world"
ryutaro [2:41 PM] ruboty: ruby %w(boo foo hoge fuga piyo).sample
ruboty  [2:41 PM] => "hoge"
ryutaro [2:41 PM] ruboty: ruby (1..15).map {|i| Hash.new{|h,k| h[k] = (k<2) ? k : h[k-1] + h[k-2]}[i]}
ruboty  [2:41 PM] => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]

どうやってやってるの?

hubot-scripts/ruby.coffee at master · github/hubot-scripts と同様、Try Ruby の API を叩いているだけです。

なので、一部のメソッドが使えない・バージョンがコントロールできないなどの制限もありますが、チャットで実行する分には十分だと思いますし、安全に使えます。

さいごに

ruboty を運用しているチームには Ruby が好きな人が多いと思いますので、少し幸せになれるのではないでしょうか。是非お試しください。

以上、宣伝でした。

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5