1- require 'rails/generators'
21require 'rails/generators/rails/app/app_generator'
32
43module Refinery
54 class DummyGenerator < Rails ::Generators ::Base
6- desc "Creates blank Rails application, installs Refinery CMS, and all sample data "
5+ desc "Creates a blank Rails application with Refinery CMS installed. "
76
87 class_option :database , :default => ''
98
109 def self . source_paths
11- paths = self . superclass . source_paths
12- paths << File . expand_path ( '../templates' , __FILE__ )
13- paths . flatten
10+ [
11+ self . superclass . source_paths ,
12+ File . expand_path ( '../templates' , __FILE__ )
13+ ] . flatten . compact
1414 end
1515
1616 PASSTHROUGH_OPTIONS = [
17- :skip_active_record , :skip_javascript , :skip_action_cable , :skip_action_mailer , :database , :javascript , :quiet , :pretend , :force , :skip
17+ :database ,
18+ :force ,
19+ :javascript ,
20+ :pretend ,
21+ :quiet ,
22+ :skip ,
23+ :skip_action_cable ,
24+ :skip_action_mailer ,
25+ :skip_active_record ,
26+ :skip_javascript
1827 ]
1928
2029 def generate_test_dummy
@@ -24,8 +33,13 @@ def generate_test_dummy
2433 opts [ :skip_bundle ] = true
2534 opts [ :skip_action_cable ] = true
2635 opts [ :skip_action_mailer ] = true
36+ opts [ :skip_keeps ] = true
37+ opts [ :skip_migrate ] = true
38+ opts [ :template ] = refinery_path . join ( "templates" , "refinery" , "edge.rb" ) . to_s
2739
28- invoke Rails ::Generators ::AppGenerator , [ File . expand_path ( dummy_path , destination_root ) ] , opts
40+ invoke Rails ::Generators ::AppGenerator ,
41+ [ File . expand_path ( dummy_path , destination_root ) ] ,
42+ opts
2943 end
3044
3145 def test_dummy_config
@@ -67,19 +81,22 @@ def test_dummy_inherited_templates
6781
6882 attr :database
6983
70- protected
84+ protected
7185
7286 def dummy_path
7387 'spec/dummy'
7488 end
7589
90+ def dummy_application_path
91+ File . expand_path ( "#{ dummy_path } /config/application.rb" , destination_root )
92+ end
93+
7694 def module_name
7795 'Dummy'
7896 end
7997
8098 def application_definition
8199 @application_definition ||= begin
82- dummy_application_path = File . expand_path ( "#{ dummy_path } /config/application.rb" , destination_root )
83100 unless options [ :pretend ] || !File . exists? ( dummy_application_path )
84101 contents = File . read ( dummy_application_path )
85102 contents [ ( contents . index ( "module #{ module_name } " ) ) ..-1 ]
@@ -93,7 +110,11 @@ def camelized
93110 end
94111
95112 def gemfile_path
96- '../../../../Gemfile'
113+ "../../../../Gemfile"
114+ end
115+
116+ def refinery_path
117+ Pathname . new File . expand_path ( "../../../../../../" , __FILE__ )
97118 end
98119 end
99120end
0 commit comments