From 6c58585ff5b667de4f29860e4b06e743e0614891 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Fri, 10 Jun 2011 23:43:24 +0200 Subject: shell out to run bundler on app generation, see rationale in the comment --- railties/lib/rails/generators/app_base.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 7972c72c1e..f07e090c25 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -188,13 +188,19 @@ module Rails end def bundle_command(command) - require 'bundler' - require 'bundler/cli' - say_status :run, "bundle #{command}" - Bundler::CLI.new.send(command) - rescue - say_status :failure, "bundler raised an exception, are you offline?", :red + + # We are going to shell out rather than invoking Bundle::CLI.new(command) + # because `rails new` loads the Thor gem and on the other hand bundler uses + # its own vendored Thor, which could be a different version. Running both + # things in the same process is a recipe for a night with paracetamol. + # + # We use backticks and #print here instead of vanilla #system because it + # is easier to silence stdout in the existing test suite this way. The + # end-user gets the bundler commands called anyway, so no big deal. + # + # Thanks to James Tucker for the Gem tricks involved in this call. + print `"#{Gem.ruby}" -rubygems "#{Gem.bin_path('bundler', 'bundle')}" #{command}` end def run_bundle -- cgit v1.2.3 From ca312b6612e2c76aabd301807a1b63fc050e46d5 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 11 Jun 2011 01:18:08 +0200 Subject: s/Bundle/Bundler/ --- railties/lib/rails/generators/app_base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index f07e090c25..1196e2b7eb 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -190,7 +190,7 @@ module Rails def bundle_command(command) say_status :run, "bundle #{command}" - # We are going to shell out rather than invoking Bundle::CLI.new(command) + # We are going to shell out rather than invoking Bundler::CLI.new(command) # because `rails new` loads the Thor gem and on the other hand bundler uses # its own vendored Thor, which could be a different version. Running both # things in the same process is a recipe for a night with paracetamol. -- cgit v1.2.3 From 04c31e2a108d08bc142485488d06ac4a716fca7a Mon Sep 17 00:00:00 2001 From: thoefer Date: Sat, 11 Jun 2011 23:56:29 +0200 Subject: fixed typo for a methodname --- railties/lib/rails/railtie.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index 5f50943626..f96dd6b9eb 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -84,7 +84,7 @@ module Rails # == Loading rake tasks and generators # # If your railtie has rake tasks, you can tell Rails to load them through the method - # rake tasks: + # rake_tasks: # # class MyRailtie < Rails::Railtie # rake_tasks do -- cgit v1.2.3 From 4dc3bb9cbdaefdedfdde9b0e2d088cbb16c4a55c Mon Sep 17 00:00:00 2001 From: Ryan Bates Date: Sun, 12 Jun 2011 18:29:14 -0700 Subject: namespace engine assets --- .../generators/rails/plugin_new/plugin_new_generator.rb | 14 +++++++------- .../templates/app/views/layouts/application.html.erb.tt | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 railties/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/application.html.erb.tt (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb index 807350316c..7c0a2b9cf4 100644 --- a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +++ b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb @@ -11,15 +11,15 @@ module Rails def app if mountable? directory "app" - template "#{app_templates_dir}/app/views/layouts/application.html.erb.tt", + template "app/views/layouts/application.html.erb.tt", "app/views/layouts/#{name}/application.html.erb" - empty_directory_with_gitkeep "app/assets/images" + empty_directory_with_gitkeep "app/assets/images/#{name}" elsif full? empty_directory_with_gitkeep "app/models" empty_directory_with_gitkeep "app/controllers" empty_directory_with_gitkeep "app/views" empty_directory_with_gitkeep "app/helpers" - empty_directory_with_gitkeep "app/assets/images" + empty_directory_with_gitkeep "app/assets/images/#{name}" end end @@ -108,9 +108,9 @@ task :default => :test def stylesheets if mountable? copy_file "#{app_templates_dir}/app/assets/stylesheets/application.css", - "app/assets/stylesheets/application.css" + "app/assets/stylesheets/#{name}/application.css" elsif full? - empty_directory_with_gitkeep "app/assets/stylesheets" + empty_directory_with_gitkeep "app/assets/stylesheets/#{name}" end end @@ -119,9 +119,9 @@ task :default => :test if mountable? template "#{app_templates_dir}/app/assets/javascripts/application.js.tt", - "app/assets/javascripts/application.js" + "app/assets/javascripts/#{name}/application.js" elsif full? - empty_directory_with_gitkeep "app/assets/javascripts" + empty_directory_with_gitkeep "app/assets/javascripts/#{name}" end end diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/application.html.erb.tt b/railties/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/application.html.erb.tt new file mode 100644 index 0000000000..01550dec2f --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/application.html.erb.tt @@ -0,0 +1,14 @@ + + + + <%= camelized %> + <%%= stylesheet_link_tag "<%= name %>/application" %> + <%%= javascript_include_tag "<%= name %>/application" %> + <%%= csrf_meta_tags %> + + + +<%%= yield %> + + + -- cgit v1.2.3 From 6c3e80af685393b1069b96af3193625137e9b29e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 15 Jun 2011 11:52:45 -0700 Subject: load_generators from engine should also handle self automatically. --- railties/lib/rails/railtie.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index 5f50943626..0c641254cf 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -174,11 +174,11 @@ module Rails def eager_load! end - def load_console(app) + def load_console(app=self) self.class.console.each { |block| block.call(app) } end - def load_tasks(app) + def load_tasks(app=self) extend Rake::DSL if defined? Rake::DSL self.class.rake_tasks.each { |block| block.call(app) } @@ -190,7 +190,7 @@ module Rails end end - def load_generators(app) + def load_generators(app=self) self.class.generators.each { |block| block.call(app) } end -- cgit v1.2.3 From adbe7daab6623baf97a842f73fe310c850552fdd Mon Sep 17 00:00:00 2001 From: Wen-Tien Chang Date: Thu, 16 Jun 2011 13:29:17 +0800 Subject: Improve the legacy wild controller route in app templates --- railties/lib/rails/generators/rails/app/templates/config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/rails/app/templates/config/routes.rb b/railties/lib/rails/generators/rails/app/templates/config/routes.rb index d50f536164..ea81748464 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/routes.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/routes.rb @@ -54,5 +54,5 @@ # This is a legacy wild controller route that's not recommended for RESTful applications. # Note: This route will make all actions in every controller accessible via GET requests. - # match ':controller(/:action(/:id(.:format)))' + # match ':controller(/:action(/:id))(.:format)' end -- cgit v1.2.3 From d92ad224e0e07cc109ec3eea7c93de5ef8cfdfea Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Thu, 16 Jun 2011 21:25:29 +0530 Subject: replace dev.ror.com plugin url with a dummy one --- railties/lib/rails/commands/plugin.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/commands/plugin.rb b/railties/lib/rails/commands/plugin.rb index 048af7cbef..4df849447d 100644 --- a/railties/lib/rails/commands/plugin.rb +++ b/railties/lib/rails/commands/plugin.rb @@ -313,11 +313,11 @@ module Commands o.separator "" o.separator "EXAMPLES" o.separator " Install a plugin from a subversion URL:" - o.separator " #{@script_name} plugin install http://dev.rubyonrails.com/svn/rails/plugins/continuous_builder\n" + o.separator " #{@script_name} plugin install http://example.com/my_svn_plugin\n" o.separator " Install a plugin from a git URL:" o.separator " #{@script_name} plugin install git://github.com/SomeGuy/my_awesome_plugin.git\n" o.separator " Install a plugin and add a svn:externals entry to vendor/plugins" - o.separator " #{@script_name} plugin install -x continuous_builder\n" + o.separator " #{@script_name} plugin install -x my_svn_plugin\n" end end -- cgit v1.2.3 From 245dba0c8941463e4b07733443bb0e161889b153 Mon Sep 17 00:00:00 2001 From: Joseph Wong Date: Thu, 16 Jun 2011 10:52:05 -0700 Subject: Cherry-picking patch for https://github.com/rails/rails/issues/1460 from 3-1-stable to master [3.1.0.rc1] Plugins inside engines not eager-loaded properly and their rake tasks ignored Working with the new support for plugins inside engines in Rails 3.1, I found that certain things that work for regular plugins don't work for these new nested plugins. In particular, these methods in Rails::Engine don't seem to understand that an engine could have nested plugins: #load_tasks #load_generators #load_console #eager_load! A solution which worked out for me is to move the calls to railties.all { ... } from the overriding methods in Rails::Application into Rails::Engine. --- railties/lib/rails/application.rb | 6 ------ railties/lib/rails/engine.rb | 12 ++++++++++-- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index a2b2af98a6..fe29668c72 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -78,10 +78,6 @@ module Rails require environment if environment end - def eager_load! #:nodoc: - railties.all(&:eager_load!) - super - end def reload_routes! routes_reloader.reload! @@ -100,14 +96,12 @@ module Rails def load_tasks(app=self) initialize_tasks - railties.all { |r| r.load_tasks(app) } super self end def load_console(app=self) initialize_console - railties.all { |r| r.load_console(app) } super self end diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index b358de89d0..52c89274e7 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -395,12 +395,20 @@ module Rails delegate :middleware, :root, :paths, :to => :config delegate :engine_name, :isolated?, :to => "self.class" - def load_tasks(*) + def load_tasks(app=self) + railties.all { |r| r.load_tasks(app) } super paths["lib/tasks"].existent.sort.each { |ext| load(ext) } end - + + def load_console(app=self) + railties.all { |r| r.load_console(app) } + super + end + def eager_load! + railties.all(&:eager_load!) + config.eager_load_paths.each do |load_path| matcher = /\A#{Regexp.escape(load_path)}\/(.*)\.rb\Z/ Dir.glob("#{load_path}/**/*.rb").sort.each do |file| -- cgit v1.2.3 From 1844572fd129f03bc6741b3ae928b730133cf6e3 Mon Sep 17 00:00:00 2001 From: wycats Date: Thu, 16 Jun 2011 12:08:26 -0700 Subject: =?UTF-8?q?Make=20the=20API=20for=20compression=20consistent=C2=A0?= =?UTF-8?q?between=20JS=20and=20CSS.=20By=20default,=20users=20just=20need?= =?UTF-8?q?=20to=20say=20whether=20they=20want=20compression=20or=20not,?= =?UTF-8?q?=20and=20a=20default=20will=20be=20chosen=20by=20a=20Railtie.?= =?UTF-8?q?=20In=20the=20case=20of=20CSS,=20this=20default=20is=20already?= =?UTF-8?q?=20chosen=20by=20the=20sass-rails=20gem.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users can still explicitly choose a compressor in their application.rb if they have a preference, but will usually want to let plugins choose defaults in their Railties. --- .../rails/app/templates/config/environments/production.rb.tt | 3 --- 1 file changed, 3 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt index 60e26755fe..06ed890e05 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt @@ -14,9 +14,6 @@ # Compress JavaScripts and CSS config.assets.compress = true - # Specify the default JavaScript compressor - config.assets.js_compressor = :uglifier - # Specifies the header that your server uses for sending files # (comment out if your front-end server doesn't support this) config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx -- cgit v1.2.3 From 29dfe05e075c3369c1182ba1ff0ba92755287d3c Mon Sep 17 00:00:00 2001 From: Joseph Wong Date: Thu, 16 Jun 2011 13:24:33 -0700 Subject: Patch for #1458 - [3.1.0.rc1] App plugins initialized before engines and plugins inside engines It seems that plugins inside a Rails 3.1 application proper (i.e. in /vendor/plugins) are initialized before engines and plugins inside engines. After some debugging, I found the culprit in Rails::Application::Railties#all: def all(&block) @all ||= railties + engines + super @all.each(&block) if block @all end The call to super here implicitly passes the &block argument, which has the unfortunate side-effect of adding the plugin initializers first (in front of other railties and engines) in the case of Rails::Engine#initializers: def initializers initializers = [] railties.all { |r| initializers += r.initializers } initializers += super initializers end The solution here is to replace the super call with a call to #plugins. --- railties/lib/rails/application/railties.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/application/railties.rb b/railties/lib/rails/application/railties.rb index 4fc5e92837..8f3a3e8bbb 100644 --- a/railties/lib/rails/application/railties.rb +++ b/railties/lib/rails/application/railties.rb @@ -4,7 +4,7 @@ module Rails class Application < Engine class Railties < Rails::Engine::Railties def all(&block) - @all ||= railties + engines + super + @all ||= railties + engines + plugins @all.each(&block) if block @all end -- cgit v1.2.3 From 08983fefd547142ef8b913af1859b96597753d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 17 Jun 2011 15:10:53 -0300 Subject: Attributes on scaffold and model generators default to string. This allows the following: "rails g scaffold Post title body:text author" --- railties/lib/rails/generators/generated_attribute.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/generated_attribute.rb b/railties/lib/rails/generators/generated_attribute.rb index 9450894b05..f9f89c9f1d 100644 --- a/railties/lib/rails/generators/generated_attribute.rb +++ b/railties/lib/rails/generators/generated_attribute.rb @@ -7,7 +7,7 @@ module Rails attr_accessor :name, :type def initialize(name, type) - raise Thor::Error, "Missing type for attribute '#{name}'.\nExample: '#{name}:string' where string is the type." if type.blank? + type = :string if type.blank? @name, @type = name, type.to_sym end -- cgit v1.2.3