1
- require 'rails/generators'
2
1
require 'rails/generators/rails/app/app_generator'
3
2
4
3
module Refinery
5
4
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. "
7
6
8
7
class_option :database , :default => ''
9
8
10
9
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
14
14
end
15
15
16
16
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
18
27
]
19
28
20
29
def generate_test_dummy
@@ -24,8 +33,13 @@ def generate_test_dummy
24
33
opts [ :skip_bundle ] = true
25
34
opts [ :skip_action_cable ] = true
26
35
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
27
39
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
29
43
end
30
44
31
45
def test_dummy_config
@@ -67,19 +81,22 @@ def test_dummy_inherited_templates
67
81
68
82
attr :database
69
83
70
- protected
84
+ protected
71
85
72
86
def dummy_path
73
87
'spec/dummy'
74
88
end
75
89
90
+ def dummy_application_path
91
+ File . expand_path ( "#{ dummy_path } /config/application.rb" , destination_root )
92
+ end
93
+
76
94
def module_name
77
95
'Dummy'
78
96
end
79
97
80
98
def application_definition
81
99
@application_definition ||= begin
82
- dummy_application_path = File . expand_path ( "#{ dummy_path } /config/application.rb" , destination_root )
83
100
unless options [ :pretend ] || !File . exists? ( dummy_application_path )
84
101
contents = File . read ( dummy_application_path )
85
102
contents [ ( contents . index ( "module #{ module_name } " ) ) ..-1 ]
@@ -93,7 +110,11 @@ def camelized
93
110
end
94
111
95
112
def gemfile_path
96
- '../../../../Gemfile'
113
+ "../../../../Gemfile"
114
+ end
115
+
116
+ def refinery_path
117
+ Pathname . new File . expand_path ( "../../../../../../" , __FILE__ )
97
118
end
98
119
end
99
120
end
0 commit comments