Method: Rails::Generators::Actions#gem_group

Defined in:
railties/lib/rails/generators/actions.rb

#gem_group(*names, &block) ⇒ Object

Wraps gem entries inside a group.

gem_group :development, :test do
  gem "rspec-rails"
end


111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'railties/lib/rails/generators/actions.rb', line 111

def gem_group(*names, &block)
  options = names.extract_options!
  str = names.map(&:inspect)
  str << quote(options) unless options.empty?
  str = str.join(", ")
  log :gemfile, "group #{str}"

  in_root do
    append_file_with_newline "Gemfile", "\ngroup #{str} do", force: true
    with_indentation(&block)
    append_file_with_newline "Gemfile", "end", force: true
  end
end