diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2015-06-25 16:56:13 -0500 |
---|---|---|
committer | Guillermo Iguaran <guilleiguaran@gmail.com> | 2015-06-25 16:56:13 -0500 |
commit | 8cc01e0b2bfa75a613720c535d34e451f5de769c (patch) | |
tree | d220d2d7c4463848ce00a2402d95b47efa563ecb /railties/lib | |
parent | 5f5e6d924973003c105feb711cefdb726f312768 (diff) | |
parent | e6be33f1ddafdb3e85b9809d0280439fc83559ae (diff) | |
download | rails-8cc01e0b2bfa75a613720c535d34e451f5de769c.tar.gz rails-8cc01e0b2bfa75a613720c535d34e451f5de769c.tar.bz2 rails-8cc01e0b2bfa75a613720c535d34e451f5de769c.zip |
Merge pull request #20697 from 5t111111/add-block-to-add_source
add_source in Application Template should take a block for gem entries
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 70a20801a0..560a553789 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -63,12 +63,26 @@ module Rails # Add the given source to +Gemfile+ # + # If block is given, gem entries in block are wrapped into the source group. + # # add_source "http://gems.github.com/" - def add_source(source, options={}) + # + # add_source "http://gems.github.com/" do + # gem "rspec-rails" + # end + def add_source(source, options={}, &block) log :source, source in_root do - prepend_file "Gemfile", "source #{quote(source)}\n", verbose: false + if block + append_file "Gemfile", "source #{quote(source)} do", force: true + @in_group = true + instance_eval(&block) + @in_group = false + append_file "Gemfile", "\nend\n", force: true + else + prepend_file "Gemfile", "source #{quote(source)}\n", verbose: false + end end end |