diff options
author | Wojciech Mach <wojtek@wojtekmach.pl> | 2011-09-04 10:14:53 +0200 |
---|---|---|
committer | Wojciech Mach <wojtek@wojtekmach.pl> | 2011-09-04 10:32:48 +0200 |
commit | 47bc5d0cc8dec79c0c64ade7d453b60f846424a9 (patch) | |
tree | 4bd0b6f94f25f40094f31b9ee64719867e820401 /railties/lib | |
parent | 9da07d1b0166950dbdc7cc6e62751f7cabacb38b (diff) | |
download | rails-47bc5d0cc8dec79c0c64ade7d453b60f846424a9.tar.gz rails-47bc5d0cc8dec79c0c64ade7d453b60f846424a9.tar.bz2 rails-47bc5d0cc8dec79c0c64ade7d453b60f846424a9.zip |
Add gem_group support to generators
Diffstat (limited to 'railties/lib')
-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 a7462f39ba..49e8a4a37d 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 |