diff options
author | José Valim <jose.valim@gmail.com> | 2011-09-04 01:47:10 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-09-04 01:47:10 -0700 |
commit | 98c3fd87e2879ab2fb9c8cd31afacae5e7110325 (patch) | |
tree | a7966a80b1c8b61987c64d75013e5b852fd06dd6 /railties/lib/rails/generators/actions.rb | |
parent | 036a25019d79565a6016cb60c520816916bb7de6 (diff) | |
parent | 47bc5d0cc8dec79c0c64ade7d453b60f846424a9 (diff) | |
download | rails-98c3fd87e2879ab2fb9c8cd31afacae5e7110325.tar.gz rails-98c3fd87e2879ab2fb9c8cd31afacae5e7110325.tar.bz2 rails-98c3fd87e2879ab2fb9c8cd31afacae5e7110325.zip |
Merge pull request #2841 from wojtekmach/app-generators-group
Add gem group support to generators
Diffstat (limited to 'railties/lib/rails/generators/actions.rb')
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index c43a99e85c..575f4bb106 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -68,7 +68,32 @@ module Rails end in_root do - append_file "Gemfile", "gem #{parts.join(", ")}\n", :verbose => false + str = "gem #{parts.join(", ")}\n" + str = " " + str if @in_group + append_file "Gemfile", str, :verbose => false + end + end + + # Wraps gem entries inside a group. + # + # ==== Example + # + # gem_group :development, :test do + # gem "rspec-rails" + # end + # + def gem_group(*names, &block) + name = names.map(&:inspect).join(", ") + log :gemfile, "group #{name}" + + in_root do + append_file "Gemfile", "\ngroup #{name} do\n", :force => true + + @in_group = true + instance_eval &block + @in_group = false + + append_file "Gemfile", "end\n", :force => true end end |