Skip to content
This repository

refactor the naming within plugin new generator #8263

Merged
merged 1 commit into from over 1 year ago

3 participants

Yves Senn Piotr Sarnacki Yehuda Katz
Yves Senn
Collaborator

Having a method called full?, which checks on :full and :mountable
is very confusing. I renamed full? to engine? and created a full?
method that only checks the :full option.

I started this work from the discussion on #8192.

Yves Senn refactor the naming within plugin new generator
Having a method called `full?`, which checks on :full and :mountable
is very confusing. I renamed `full?` to `engine?` and created a `full?`
method that only checks the `:full` option
e63a97d
Yves Senn
Collaborator

@drogus can you take a look?

Piotr Sarnacki
Collaborator

@senny could you paste a gists of files that are generated by both options in such configuration? I would like to get feedback also from others and it will make discussion much simpler (summary of other things related to those options would be great, too)

Yves Senn
Collaborator

@drogus what content do you want inside the gist? Only the file names or the complete content?

Piotr Sarnacki
Collaborator

@senny filenames, otherwise it will be hard to read :)

Yves Senn
Collaborator

Here is the generator output from plugin new --full and plugin new --mountable

https://gist.github.com/4117054

Yves Senn
Collaborator

@rafaelfranca any thoughts on this one?

Yehuda Katz wycats merged commit d6c732f into from January 06, 2013
Yehuda Katz wycats closed this January 06, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Nov 18, 2012
Yves Senn refactor the naming within plugin new generator
Having a method called `full?`, which checks on :full and :mountable
is very confusing. I renamed `full?` to `engine?` and created a `full?`
method that only checks the `:full` option
e63a97d
This page is out of date. Refresh to see the latest.
16  railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
@@ -53,13 +53,11 @@ def lib
53 53
       template "lib/%name%.rb"
54 54
       template "lib/tasks/%name%_tasks.rake"
55 55
       template "lib/%name%/version.rb"
56  
-      if full?
57  
-        template "lib/%name%/engine.rb"
58  
-      end
  56
+      template "lib/%name%/engine.rb" if engine?
59 57
     end
60 58
 
61 59
     def config
62  
-      template "config/routes.rb" if full?
  60
+      template "config/routes.rb" if engine?
63 61
     end
64 62
 
65 63
     def test
@@ -70,7 +68,7 @@ def test
70 68
 
71 69
 task default: :test
72 70
       EOF
73  
-      if full?
  71
+      if engine?
74 72
         template "test/integration/navigation_test.rb"
75 73
       end
76 74
     end
@@ -133,7 +131,7 @@ def javascripts
133 131
     end
134 132
 
135 133
     def script(force = false)
136  
-      return unless full?
  134
+      return unless engine?
137 135
 
138 136
       directory "script", force: force do |content|
139 137
         "#{shebang}\n" + content
@@ -271,8 +269,12 @@ def create_dummy_app(path = nil)
271 269
         end
272 270
       end
273 271
 
  272
+      def engine?
  273
+        full? || mountable?
  274
+      end
  275
+
274 276
       def full?
275  
-        options[:full] || options[:mountable]
  277
+        options[:full]
276 278
       end
277 279
 
278 280
       def mountable?
2  railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19 19
 <% end -%>
20 20
 
21 21
   <%= '# ' if options.dev? || options.edge? -%>s.add_dependency "rails", "~> <%= Rails::VERSION::STRING %>"
22  
-<% if full? && !options[:skip_javascript] -%>
  22
+<% if engine? && !options[:skip_javascript] -%>
23 23
   # s.add_dependency "<%= "#{options[:javascript]}-rails" %>"
24 24
 <% end -%>
25 25
 <% unless options[:skip_active_record] -%>
2  railties/lib/rails/generators/rails/plugin_new/templates/Gemfile
@@ -2,7 +2,7 @@ source "http://rubygems.org"
2 2
 
3 3
 <% if options[:skip_gemspec] -%>
4 4
 <%= '# ' if options.dev? || options.edge? -%>gem "rails", "~> <%= Rails::VERSION::STRING %>"
5  
-<% if full? && !options[:skip_javascript] -%>
  5
+<% if engine? && !options[:skip_javascript] -%>
6 6
 # gem "<%= "#{options[:javascript]}-rails" %>"
7 7
 <% end -%>
8 8
 <% else -%>
2  railties/lib/rails/generators/rails/plugin_new/templates/Rakefile
@@ -14,7 +14,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
14 14
   rdoc.rdoc_files.include('lib/**/*.rb')
15 15
 end
16 16
 
17  
-<% if full? && !options[:skip_active_record] && with_dummy_app? -%>
  17
+<% if engine? && !options[:skip_active_record] && with_dummy_app? -%>
18 18
 APP_RAKEFILE = File.expand_path("../<%= dummy_path -%>/Rakefile", __FILE__)
19 19
 load 'rails/tasks/engine.rake'
20 20
 <% end %>
2  railties/lib/rails/generators/rails/plugin_new/templates/lib/%name%.rb
... ...
@@ -1,4 +1,4 @@
1  
-<% if full? -%>
  1
+<% if engine? -%>
2 2
 require "<%= name %>/engine"
3 3
 
4 4
 <% end -%>
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.