Skip to content

Commit

Permalink
refactor the naming within plugin new generator
Browse files Browse the repository at this point in the history
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
  • Loading branch information
senny committed Nov 18, 2012
1 parent 5a3e258 commit e63a97d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
Expand Up @@ -53,13 +53,11 @@ def lib
template "lib/%name%.rb"
template "lib/tasks/%name%_tasks.rake"
template "lib/%name%/version.rb"
if full?
template "lib/%name%/engine.rb"
end
template "lib/%name%/engine.rb" if engine?
end

def config
template "config/routes.rb" if full?
template "config/routes.rb" if engine?
end

def test
Expand All @@ -70,7 +68,7 @@ def test
task default: :test
EOF
if full?
if engine?
template "test/integration/navigation_test.rb"
end
end
Expand Down Expand Up @@ -133,7 +131,7 @@ def javascripts
end

def script(force = false)
return unless full?
return unless engine?

directory "script", force: force do |content|
"#{shebang}\n" + content
Expand Down Expand Up @@ -271,8 +269,12 @@ def create_dummy_app(path = nil)
end
end

def engine?
full? || mountable?
end

def full?
options[:full] || options[:mountable]
options[:full]
end

def mountable?
Expand Down
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |s|
<% end -%>

<%= '# ' if options.dev? || options.edge? -%>s.add_dependency "rails", "~> <%= Rails::VERSION::STRING %>"
<% if full? && !options[:skip_javascript] -%>
<% if engine? && !options[:skip_javascript] -%>
# s.add_dependency "<%= "#{options[:javascript]}-rails" %>"
<% end -%>
<% unless options[:skip_active_record] -%>
Expand Down
Expand Up @@ -2,7 +2,7 @@ source "http://rubygems.org"

<% if options[:skip_gemspec] -%>
<%= '# ' if options.dev? || options.edge? -%>gem "rails", "~> <%= Rails::VERSION::STRING %>"
<% if full? && !options[:skip_javascript] -%>
<% if engine? && !options[:skip_javascript] -%>
# gem "<%= "#{options[:javascript]}-rails" %>"
<% end -%>
<% else -%>
Expand Down
Expand Up @@ -14,7 +14,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('lib/**/*.rb')
end

<% if full? && !options[:skip_active_record] && with_dummy_app? -%>
<% if engine? && !options[:skip_active_record] && with_dummy_app? -%>
APP_RAKEFILE = File.expand_path("../<%= dummy_path -%>/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
<% end %>
Expand Down
@@ -1,4 +1,4 @@
<% if full? -%>
<% if engine? -%>
require "<%= name %>/engine"

<% end -%>
Expand Down

0 comments on commit e63a97d

Please sign in to comment.