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 , :database , :javascript , :quiet , :pretend , :force , :skip
17
+ :skip_active_record , :skip_javascript , :database , :javascript , :quiet ,
18
+ :pretend , :force , :skip
18
19
]
19
20
20
21
def generate_test_dummy
21
22
opts = ( options || { } ) . slice ( *PASSTHROUGH_OPTIONS )
22
23
opts [ :database ] = 'sqlite3' if opts [ :database ] . blank?
23
24
opts [ :force ] = true
24
25
opts [ :skip_bundle ] = true
26
+ opts [ :skip_keeps ] = true
27
+ opts [ :skip_migrate ] = true
28
+ opts [ :template ] = refinery_path . join ( "templates" , "refinery" , "edge.rb" ) . to_s
25
29
26
- invoke Rails ::Generators ::AppGenerator , [ File . expand_path ( dummy_path , destination_root ) ] , opts
30
+ invoke Rails ::Generators ::AppGenerator ,
31
+ [ File . expand_path ( dummy_path , destination_root ) ] ,
32
+ opts
27
33
end
28
34
29
35
def test_dummy_config
@@ -65,19 +71,22 @@ def test_dummy_inherited_templates
65
71
66
72
attr :database
67
73
68
- protected
74
+ protected
69
75
70
76
def dummy_path
71
77
'spec/dummy'
72
78
end
73
79
80
+ def dummy_application_path
81
+ File . expand_path ( "#{ dummy_path } /config/application.rb" , destination_root )
82
+ end
83
+
74
84
def module_name
75
85
'Dummy'
76
86
end
77
87
78
88
def application_definition
79
89
@application_definition ||= begin
80
- dummy_application_path = File . expand_path ( "#{ dummy_path } /config/application.rb" , destination_root )
81
90
unless options [ :pretend ] || !File . exists? ( dummy_application_path )
82
91
contents = File . read ( dummy_application_path )
83
92
contents [ ( contents . index ( "module #{ module_name } " ) ) ..-1 ]
@@ -91,7 +100,11 @@ def camelized
91
100
end
92
101
93
102
def gemfile_path
94
- '../../../../Gemfile'
103
+ "../../../../Gemfile"
104
+ end
105
+
106
+ def refinery_path
107
+ Pathname . new File . expand_path ( "../../../../../../" , __FILE__ )
95
108
end
96
109
end
97
110
end
0 commit comments