如何在Thor任务中为组添加gem?

时间:2013-01-05 17:23:52

标签: thor

我正处于Thor任务中,我想在我的gem文件中为资产组添加gems(见下文)。

gem_group命令(从标准Rails应用程序模板中获知)在Thor任务中似乎不起作用(请参阅底部的错误)。

我怎样才能最好地在Thor任务中将gem添加到gem文件中的组?

欢迎任何想法 - 谢谢。

class ThorBuild < Thor

  desc "add_gems", "Adds the gems I need"
  def add_gems
    puts "Running add_gems"

    gem 'mongoid', '~> 3.0.15'
    gem 'bson_ext'
    gem 'less-rails'
    gem 'devise'

    gem_group :assets do
      gem 'therubyracer', '= 0.10.0', :platforms => :ruby
      gem 'twitter-bootstrap-rails'
    end
  end

end

输出看起来像这样......

Running add_gems
/home/ubuntu/sites/ThorBuild.thor:12:in `add_gems': undefined method `gem_group' for #<Thor::Sandbox::ThorBuild:0x000000007b5110> (NoMethodError)
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/task.rb:27:in `run'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor.rb:275:in `dispatch'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/base.rb:425:in `start'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/runner.rb:36:in `method_missing'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/task.rb:29:in `run'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/task.rb:126:in `run'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor.rb:275:in `dispatch'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/base.rb:425:in `start'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/bin/thor:6:in `<top (required)>'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/bin/thor:19:in `load'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/bin/thor:19:in `<main>'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `<main>'

0 个答案:

没有答案