diff options
Diffstat (limited to 'railties/lib/rails/generators')
10 files changed, 39 insertions, 42 deletions
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? %> <div id="error_explanation"> @@ -22,4 +21,3 @@ <%%= f.submit %> </div> <%% 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 -%> <h1>Editing <%= singular_table_name %></h1> <%%= 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 -%> <h1>Listing <%= plural_table_name %></h1> <table> @@ -26,4 +25,3 @@ <br /> <%%= 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 -%> <h1>New <%= singular_table_name %></h1> <%%= 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 -%> <p id="notice"><%%= notice %></p> <% 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 badf981d05..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 @@ -61,11 +64,7 @@ module Rails end def namespaced? - !options[:skip_namespace] && !!namespace - end - - def inside_namespace? - @inside_namespace + !options[:skip_namespace] && namespace end def file_path @@ -73,7 +72,7 @@ module Rails 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 diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb index 40ed2062d3..97f681d826 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 deprecated, please use 'rails plugin new' command to generate plugin structure." + ActiveSupport::Deprecation.warn message + end + check_class_collision def create_root_files 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] 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 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 |