From fefce1262b7eddfe463873843d9719e76d385ff5 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 11 Nov 2010 07:42:10 -0600 Subject: Don't need to support rails plugin --version --- railties/lib/rails/commands/plugin_new.rb | 6 ------ 1 file changed, 6 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/commands/plugin_new.rb b/railties/lib/rails/commands/plugin_new.rb index 00a7e30902..8baa8ebfd4 100644 --- a/railties/lib/rails/commands/plugin_new.rb +++ b/railties/lib/rails/commands/plugin_new.rb @@ -1,9 +1,3 @@ -require 'rails/version' -if %w(--version -v).include? ARGV.first - puts "Rails #{Rails::VERSION::STRING}" - exit(0) -end - if ARGV.first != "new" ARGV[0] = "--help" else -- cgit v1.2.3 From 73443329de6817b32ea0fa65889056c146181bca Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 14 Nov 2010 19:04:17 -0600 Subject: Add skip-gemspec option to 'plugin new' generator --- .../generators/rails/plugin_new/plugin_new_generator.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (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 8fac6fc70a..9c54b98238 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 @@ -102,14 +102,17 @@ task :default => :test alias_method :plugin_path, :app_path - class_option :dummy_path, :type => :string, :default => "test/dummy", - :desc => "Create dummy application at given path" + class_option :dummy_path, :type => :string, :default => "test/dummy", + :desc => "Create dummy application at given path" - class_option :full, :type => :boolean, :default => false, - :desc => "Generate rails engine with integration tests" + class_option :full, :type => :boolean, :default => false, + :desc => "Generate rails engine with integration tests" - class_option :mountable, :type => :boolean, :default => false, - :desc => "Generate mountable isolated application" + class_option :mountable, :type => :boolean, :default => false, + :desc => "Generate mountable isolated application" + + class_option :skip_gemspec, :type => :boolean, :default => false, + :desc => "Skip gemspec file" def initialize(*args) raise Error, "Options should be given after the plugin name. For details run: rails plugin --help" if args[0].blank? @@ -122,7 +125,7 @@ task :default => :test def create_root_files build(:readme) build(:rakefile) - build(:gemspec) + build(:gemspec) unless options[:skip_gemspec] build(:license) build(:gitignore) unless options[:skip_git] build(:gemfile) unless options[:skip_gemfile] -- cgit v1.2.3 From dc1250265cdf1ae4ab2d61b5d0b1cf2aa2f8ba0e Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 14 Nov 2010 19:27:06 -0600 Subject: Deprecate plugin generator --- railties/lib/rails/generators/rails/plugin/plugin_generator.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb index 40ed2062d3..a3387b8a57 100644 --- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb +++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb @@ -1,3 +1,4 @@ + require 'rails/generators/rails/generator/generator_generator' module Rails @@ -5,6 +6,12 @@ module Rails class PluginGenerator < NamedBase class_option :tasks, :desc => "When supplied creates tasks base files." + def show_deprecation + return unless behavior == :invoke + message = "Plugin generator is depreacted, please use 'rails plugin new' command to generate plugin structure." + ActiveSupport::Deprecation.warn message + end + check_class_collision def create_root_files -- cgit v1.2.3 From ef4afed81cab133ac511944d660e8c0667c43075 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 14 Nov 2010 19:32:43 -0600 Subject: There is no need to make isolated? method with bang-bang, just alias isolated --- railties/lib/rails/engine.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 466a31c2a0..62fb781c19 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -329,6 +329,7 @@ module Rails class << self attr_accessor :called_from, :isolated + alias :isolated? :isolated alias :engine_name :railtie_name def inherited(base) @@ -368,10 +369,6 @@ module Rails end end end - - def isolated? - !!isolated - end end delegate :middleware, :root, :paths, :to => :config -- cgit v1.2.3 From 4da6d956043337c3c14d4f74cbbf05c3a50b4e9b Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 14 Nov 2010 19:33:25 -0600 Subject: Bye bye bang bang. --- railties/lib/rails/generators/named_base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index badf981d05..8fddf1ab72 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -61,7 +61,7 @@ module Rails end def namespaced? - !options[:skip_namespace] && !!namespace + !options[:skip_namespace] && namespace end def inside_namespace? -- cgit v1.2.3 From b0665345f85e4b7f3b3367ee36fa205e7ff78d12 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 15 Nov 2010 13:09:05 -0600 Subject: Allow running `rails plugin new` command inside rails application --- railties/lib/rails/commands.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index e3aa6d7c3e..c8a33c1266 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -12,14 +12,19 @@ command = aliases[command] || command case command when 'generate', 'destroy', 'plugin' - require APP_PATH - Rails.application.require_environment! + if command == "plugin" && ARGV.first == "new" + require "rails/commands/plugin_new" + else + require APP_PATH + Rails.application.require_environment! - if defined?(ENGINE_PATH) - engine = Rails.application.railties.engines.find { |r| r.root.to_s == ENGINE_PATH } - Rails.application = engine + if defined?(ENGINE_PATH) + engine = Rails.application.railties.engines.find { |r| r.root.to_s == ENGINE_PATH } + Rails.application = engine + end + + require "rails/commands/#{command}" end - require "rails/commands/#{command}" when 'benchmarker', 'profiler' require APP_PATH -- cgit v1.2.3 From bf176e9c7a1aa46b021384b91f4f9ec9a1132c0f Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 15 Nov 2010 13:09:39 -0600 Subject: Do not allow to use plugin_new generator directly, you should use Usage: rails new APP_PATH [options] Options: -G, [--skip-git] # Skip Git ignores and keeps -r, [--ruby=PATH] # Path to the Ruby binary of your choice # Default: /Users/drogus/.rvm/rubies/ruby-1.8.7-p302/bin/ruby -b, [--builder=BUILDER] # Path to an application builder (can be a filesystem path or URL) [--edge] # Setup the application with Gemfile pointing to Rails repository [--dev] # Setup the application with Gemfile pointing to your Rails checkout [--skip-gemfile] # Don't create a Gemfile -d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db) # Default: sqlite3 -O, [--skip-active-record] # Skip Active Record files -m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL) -J, [--skip-prototype] # Skip Prototype files -T, [--skip-test-unit] # Skip Test::Unit files Runtime options: -s, [--skip] # Skip files that already exist -p, [--pretend] # Run but do not make any changes -f, [--force] # Overwrite files that already exist -q, [--quiet] # Supress status output Rails options: -v, [--version] # Show Rails version number and quit -h, [--help] # Show this help message and quit Description: The 'rails new' command creates a new Rails application with a default directory structure and configuration at the path you specify. Example: rails new ~/Code/Ruby/weblog This generates a skeletal Rails installation in ~/Code/Ruby/weblog. See the README in the newly created application to get going. command --- railties/lib/rails/commands.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index c8a33c1266..de5d876c18 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -14,6 +14,9 @@ case command when 'generate', 'destroy', 'plugin' if command == "plugin" && ARGV.first == "new" require "rails/commands/plugin_new" + elsif command == 'generate' && ARGV.first == "plugin_new" + puts "This generator should not be used directly as a generator. You should use `rails plugin new` command instead" + exit(1) else require APP_PATH Rails.application.require_environment! -- cgit v1.2.3 From ecd0310e1422170c4fea6dccf60a42273bce779e Mon Sep 17 00:00:00 2001 From: Doug Ireton Date: Tue, 16 Nov 2010 13:20:25 +0800 Subject: Fix misspelling of 'deprecation' in plugin_generator. --- railties/lib/rails/generators/rails/plugin/plugin_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb index a3387b8a57..97f681d826 100644 --- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb +++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb @@ -8,7 +8,7 @@ module Rails def show_deprecation return unless behavior == :invoke - message = "Plugin generator is depreacted, please use 'rails plugin new' command to generate plugin structure." + message = "Plugin generator is deprecated, please use 'rails plugin new' command to generate plugin structure." ActiveSupport::Deprecation.warn message end -- cgit v1.2.3 From ced8ebcee0fa09939f82cacc59a864f5625e4bd5 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 15 Nov 2010 22:39:28 -0600 Subject: Change inside_namespace method to inside_template and use it in all templates by default The initial implementation of namespacing was based on wrong assumptions. Namespacing path and class names in templates should be based on current namespace and skip_namespace attribute, but it should be not necessary to wrap content on all the templates into additional block methods. --- .../erb/scaffold/templates/_form.html.erb | 2 -- .../erb/scaffold/templates/edit.html.erb | 2 -- .../erb/scaffold/templates/index.html.erb | 2 -- .../generators/erb/scaffold/templates/new.html.erb | 2 -- .../erb/scaffold/templates/show.html.erb | 2 -- railties/lib/rails/generators/named_base.rb | 41 +++++++++++----------- 6 files changed, 20 insertions(+), 31 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb index c8ee939ad7..d12b2ff0e5 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb @@ -1,4 +1,3 @@ -<% without_namespacing do -%> <%%= form_for(@<%= singular_table_name %>) do |f| %> <%% if @<%= singular_table_name %>.errors.any? %>
@@ -22,4 +21,3 @@ <%%= f.submit %>
<%% end %> -<% end -%> diff --git a/railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb index d1bfcbc429..e58b9fbd08 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb @@ -1,8 +1,6 @@ -<% without_namespacing do -%>

Editing <%= singular_table_name %>

<%%= render 'form' %> <%%= link_to 'Show', @<%= singular_table_name %> %> | <%%= link_to 'Back', <%= index_helper %>_path %> -<% end -%> diff --git a/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb index 435d126ee4..4c46db4d67 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb @@ -1,4 +1,3 @@ -<% without_namespacing do -%>

Listing <%= plural_table_name %>

@@ -26,4 +25,3 @@
<%%= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path %> -<% end -%> diff --git a/railties/lib/rails/generators/erb/scaffold/templates/new.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/new.html.erb index fe4d0971c4..02ae4d015e 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/new.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/new.html.erb @@ -1,7 +1,5 @@ -<% without_namespacing do -%>

New <%= singular_table_name %>

<%%= render 'form' %> <%%= link_to 'Back', <%= index_helper %>_path %> -<% end -%> diff --git a/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb index bc3a87b99f..c0e5ccff1e 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb @@ -1,4 +1,3 @@ -<% without_namespacing do -%>

<%%= notice %>

<% for attribute in attributes -%> @@ -11,4 +10,3 @@ <%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> | <%%= link_to 'Back', <%= index_helper %>_path %> -<% end -%> diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index 8fddf1ab72..e0dde4360f 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -16,6 +16,14 @@ module Rails parse_attributes! if respond_to?(:attributes) end + no_tasks do + def template(source, *args, &block) + inside_template do + super + end + end + end + protected attr_reader :file_name alias :singular_name :file_name @@ -23,17 +31,9 @@ module Rails # Wrap block with namespace of current application # if namespace exists and is not skipped def module_namespacing(&block) - inside_namespace do - content = capture(&block) - content = wrap_with_namespace(content) if namespaced? - concat(content) - end - end - - def without_namespacing(&block) - inside_namespace do - concat(capture(&block)) - end + content = capture(&block) + content = wrap_with_namespace(content) if namespaced? + concat(content) end def indent(content, multiplier = 2) @@ -46,12 +46,15 @@ module Rails "module #{namespace.name}\n#{content}\nend\n" end - def inside_namespace - @inside_namespace = true if namespaced? - result = yield - result + def inside_template + @inside_template = true + yield ensure - @inside_namespace = false + @inside_template = false + end + + def inside_template? + @inside_template end def namespace @@ -64,16 +67,12 @@ module Rails !options[:skip_namespace] && namespace end - def inside_namespace? - @inside_namespace - end - def file_path @file_path ||= (class_path + [file_name]).join('/') end def class_path - inside_namespace? || !namespaced? ? regular_class_path : namespaced_class_path + inside_template? || !namespaced? ? regular_class_path : namespaced_class_path end def regular_class_path -- cgit v1.2.3 From 510375b501d1a158edf579966a51568d539dcd6e Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 16 Nov 2010 16:41:37 +0100 Subject: Fix plugin new --mountable: ActionController instead of ActiveController --- .../templates/app/controllers/%name%/application_controller.rb.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/app/controllers/%name%/application_controller.rb.tt b/railties/lib/rails/generators/rails/plugin_new/templates/app/controllers/%name%/application_controller.rb.tt index f225bc9f7f..448ad7f989 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/app/controllers/%name%/application_controller.rb.tt +++ b/railties/lib/rails/generators/rails/plugin_new/templates/app/controllers/%name%/application_controller.rb.tt @@ -1,4 +1,4 @@ module <%= camelized %> - class ApplicationController < ActiveController::Base + class ApplicationController < ActionController::Base end end -- cgit v1.2.3 From 1395545404eb0b28af08108b50d7cfe3fa9a5357 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 16 Nov 2010 18:57:25 +0100 Subject: Do not run migrations from mounted engine separately. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no good way now to run migrations for mounted engine in test application, but that way of running migrations makes it really hard to run engine in development mode and test it (you need to copy migrations in dev mode and in that case in tests they will be run twice). Signed-off-by: José Valim --- .../lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb b/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb index dbcaf6b92f..7b61047e77 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb +++ b/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb @@ -9,8 +9,6 @@ Rails.backtrace_cleaner.remove_silencers! <% if full? && !options[:skip_active_record] -%> # Run any available migration from application ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__) -# and from engine -ActiveRecord::Migrator.migrate File.expand_path("../../db/migrate/", __FILE__) <% end -%> # Load support files -- cgit v1.2.3 From ccd2f3ede585fb2f2d830e661dbb8b8538de2dc5 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 16 Nov 2010 15:11:46 -0800 Subject: Update the version.rb files to include a PRE part --- railties/lib/rails/version.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/version.rb b/railties/lib/rails/version.rb index 0213d46254..b076881c21 100644 --- a/railties/lib/rails/version.rb +++ b/railties/lib/rails/version.rb @@ -3,8 +3,8 @@ module Rails MAJOR = 3 MINOR = 1 TINY = 0 - BUILD = "beta" + PRE = "beta" - STRING = [MAJOR, MINOR, TINY, BUILD].join('.') + STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') end end -- cgit v1.2.3 From 7b2f2c8b477adae9bc7243fb9c895f8a823188a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 17 Nov 2010 23:31:29 +0100 Subject: Tidy up generators commits. --- railties/lib/rails/commands.rb | 5 +---- railties/lib/rails/generators.rb | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index de5d876c18..338565247f 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -12,11 +12,8 @@ command = aliases[command] || command case command when 'generate', 'destroy', 'plugin' - if command == "plugin" && ARGV.first == "new" + if command == 'plugin' && ARGV.first == 'new' require "rails/commands/plugin_new" - elsif command == 'generate' && ARGV.first == "plugin_new" - puts "This generator should not be used directly as a generator. You should use `rails plugin new` command instead" - exit(1) else require APP_PATH Rails.application.require_environment! diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 240810b8bd..27a4007c20 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -228,6 +228,7 @@ module Rails rails = groups.delete("rails") rails.map! { |n| n.sub(/^rails:/, '') } rails.delete("app") + rails.delete("plugin_new") print_list("rails", rails) hidden_namespaces.each {|n| groups.delete(n.to_s) } -- cgit v1.2.3 From 938243feb9ea177b84276821818c9eed66064340 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 19 Nov 2010 16:26:09 -0800 Subject: do not require ruby-debug automatically. please require it if you have declared it as a dependency --- railties/lib/rails/test_help.rb | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index 38f2f651f4..f81002328f 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -39,14 +39,3 @@ class ActionDispatch::IntegrationTest @routes = Rails.application.routes end end - -begin - require_library_or_gem 'ruby-debug' - Debugger.start - if Debugger.respond_to?(:settings) - Debugger.settings[:autoeval] = true - Debugger.settings[:autolist] = 1 - end -rescue LoadError - # ruby-debug wasn't available so neither can the debugging be -end -- cgit v1.2.3 From 4a51328ae8d51f8d1a637780d5b82fd27261758f Mon Sep 17 00:00:00 2001 From: zhengjia Date: Tue, 16 Nov 2010 09:26:21 -0600 Subject: Minor fix on Rails:Railtie documentation --- railties/lib/rails/railtie.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index c76bc83377..030a838dc1 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -97,7 +97,7 @@ module Rails # If your railtie has rake tasks, you can tell Rails to load them through the method # rake tasks: # - # class MyRailtie < Railtie + # class MyRailtie < Rails::Railtie # rake_tasks do # load "path/to/my_railtie.tasks" # end @@ -107,7 +107,7 @@ module Rails # your generators at a different location, you can specify in your Railtie a block which # will load them during normal generators lookup: # - # class MyRailtie < Railtie + # class MyRailtie < Rails::Railtie # generators do # require "path/to/my_railtie_generator" # end -- cgit v1.2.3