从字符串运行ruby代码

时间:2017-01-06 20:43:26

标签: ruby-on-rails ruby

有没有办法从字符串内部运行ruby代码。

这样的东西
'x = %ruby command%'

我已经从我的GemFile里面试了这个,没有运气

gem 'private_gem', '>= 2.0.0', :git => 'https://#{ENV['github_user']}:#{ENV['github_password']}@github.umn.edu:asrweb/umn_shib_auth.git'

这是错误消息

[!] There was an error parsing `Gemfile`: syntax error, unexpected tIDENTIFIER, expecting end-of-input - ... => 'https://#{ENV['github_user']}:#{ENV['github_password']}...
...                               ^. Bundler cannot continue.

1 个答案:

答案 0 :(得分:2)

只需使用双引号:

gem 'private_gem', '>= 2.0.0', :git => "https://#{ENV['github_user']}:#{ENV['github_password']}@github.umn.edu:asrweb/umn_shib_auth.git"