From 097b2101897af447591d00fb2809d91894572b87 Mon Sep 17 00:00:00 2001 From: Stefan Kanev Date: Thu, 31 Jul 2014 12:05:07 +0200 Subject: Add an after_bundle callback in Rails templates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The template runs before the generation of binstubs – this does not allow to write one, that makes an initial commit to version control. It is solvable by adding an after_bundle callback. --- railties/lib/rails/generators/actions.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'railties/lib/rails/generators/actions.rb') diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index a239874df0..4709914947 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -7,6 +7,7 @@ module Rails def initialize(*) # :nodoc: super @in_group = nil + @after_bundle_callbacks = [] end # Adds an entry into +Gemfile+ for the supplied gem. @@ -232,6 +233,16 @@ module Rails log File.read(find_in_source_paths(path)) end + # Registers a callback to be executed after bundle and spring binstubs + # have run. + # + # after_bundle do + # git add: '.' + # end + def after_bundle(&block) + @after_bundle_callbacks << block + end + protected # Define log for backwards compatibility. If just one argument is sent, -- cgit v1.2.3