From e61d6afbab24163d37a73b25262ef73119b99a78 Mon Sep 17 00:00:00 2001 From: Alexey Vakhov Date: Fri, 2 Sep 2011 13:31:00 +0400 Subject: fix indent for generator environment method --- railties/lib/rails/generators/actions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 b8541c236e..a7462f39ba 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -97,7 +97,7 @@ module Rails in_root do if options[:env].nil? - inject_into_file 'config/application.rb', "\n #{data}", :after => sentinel, :verbose => false + inject_into_file 'config/application.rb', "\n #{data}", :after => sentinel, :verbose => false else Array.wrap(options[:env]).each do |env| inject_into_file "config/environments/#{env}.rb", "\n #{data}", :after => env_file_sentinel, :verbose => false -- cgit v1.2.3 From 34618e6697475bca8b4bcfaaa2d55a99e78c031a Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Sun, 4 Sep 2011 08:17:53 +0530 Subject: Warnings removed for using shadow variable. --- railties/lib/rails/generators/actions.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (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 a7462f39ba..c43a99e85c 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -119,8 +119,8 @@ module Rails if commands.is_a?(Symbol) run "git #{commands}" else - commands.each do |command, options| - run "git #{command} #{options}" + commands.each do |cmd, options| + run "git #{cmd} #{options}" end end end -- cgit v1.2.3 From 47bc5d0cc8dec79c0c64ade7d453b60f846424a9 Mon Sep 17 00:00:00 2001 From: Wojciech Mach Date: Sun, 4 Sep 2011 10:14:53 +0200 Subject: Add gem_group support to generators --- railties/lib/rails/generators/actions.rb | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (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 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 -- cgit v1.2.3 From 148e4a541361f140f13aa35bb43b3d57c95831d6 Mon Sep 17 00:00:00 2001 From: Dmitriy Kiriyenko Date: Thu, 29 Sep 2011 15:35:25 +0300 Subject: Honour RAILS_ENV environment variable when running rake. --- railties/lib/rails/generators/actions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 575f4bb106..5af5d3b856 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -252,7 +252,7 @@ module Rails # def rake(command, options={}) log :rake, command - env = options[:env] || 'development' + env = options[:env] || ENV["RAILS_ENV"] || 'development' sudo = options[:sudo] && RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ ? 'sudo ' : '' in_root { run("#{sudo}#{extify(:rake)} #{command} RAILS_ENV=#{env}", :verbose => false) } end -- cgit v1.2.3 From b0b436ebcea8206015b3f52bb5915a7bba7cc5a9 Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Fri, 30 Sep 2011 15:56:38 +0530 Subject: warning removed : '&' interpreted as argument prefix --- railties/lib/rails/generators/actions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 5af5d3b856..b26839644e 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -90,7 +90,7 @@ module Rails append_file "Gemfile", "\ngroup #{name} do\n", :force => true @in_group = true - instance_eval &block + instance_eval(&block) @in_group = false append_file "Gemfile", "end\n", :force => true -- cgit v1.2.3 From c8d7291b6b5736562b112007365317648ae2b790 Mon Sep 17 00:00:00 2001 From: ganesh Date: Fri, 25 Nov 2011 14:55:28 +0530 Subject: Added tests for #3751 --- railties/lib/rails/generators/actions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 b26839644e..184cb2866b 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -68,7 +68,7 @@ module Rails end in_root do - str = "gem #{parts.join(", ")}\n" + str = "\ngem #{parts.join(", ")}\n" str = " " + str if @in_group append_file "Gemfile", str, :verbose => false end -- cgit v1.2.3 From 95e9b5fbfd87b81bf2d2b16a6df6d9ddbfdb686d Mon Sep 17 00:00:00 2001 From: John Donahue Date: Fri, 25 Nov 2011 09:06:14 -0800 Subject: Updating newline fix to maintain existing linebreaks and indentation and test for b/eol on inserts --- railties/lib/rails/generators/actions.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (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 184cb2866b..ca93f9ef9d 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -68,8 +68,9 @@ module Rails end in_root do - str = "\ngem #{parts.join(", ")}\n" + str = "gem #{parts.join(", ")}" str = " " + str if @in_group + str = "\n" + str append_file "Gemfile", str, :verbose => false end end @@ -87,13 +88,13 @@ module Rails log :gemfile, "group #{name}" in_root do - append_file "Gemfile", "\ngroup #{name} do\n", :force => true + append_file "Gemfile", "\ngroup #{name} do", :force => true @in_group = true instance_eval(&block) @in_group = false - append_file "Gemfile", "end\n", :force => true + append_file "Gemfile", "\nend\n", :force => true end end -- cgit v1.2.3