padrino-gen 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -10
- data/Rakefile +4 -15
- data/bin/padrino-gen +3 -0
- data/lib/padrino-gen/generators/actions.rb +10 -4
- data/lib/padrino-gen/generators/app/app.rb.tt +2 -2
- data/lib/padrino-gen/generators/components/mocks/mocha.rb +9 -0
- data/lib/padrino-gen/generators/components/mocks/rr.rb +11 -0
- data/lib/padrino-gen/generators/components/orms/activerecord.rb +112 -0
- data/lib/padrino-gen/generators/components/orms/couchrest.rb +44 -0
- data/lib/padrino-gen/generators/components/orms/datamapper.rb +86 -0
- data/lib/padrino-gen/generators/components/orms/mongoid.rb +68 -0
- data/lib/padrino-gen/generators/components/orms/mongomapper.rb +43 -0
- data/lib/padrino-gen/generators/components/orms/sequel.rb +71 -0
- data/lib/padrino-gen/generators/components/renderers/erb.rb +3 -0
- data/lib/padrino-gen/generators/components/renderers/haml.rb +3 -0
- data/lib/padrino-gen/generators/components/scripts/extcore.rb +4 -0
- data/lib/padrino-gen/generators/components/scripts/jquery.rb +4 -0
- data/lib/padrino-gen/generators/components/scripts/mootools.rb +4 -0
- data/lib/padrino-gen/generators/components/scripts/prototype.rb +5 -0
- data/lib/padrino-gen/generators/components/scripts/rightjs.rb +4 -0
- data/lib/padrino-gen/generators/components/stylesheets/less.rb +33 -0
- data/lib/padrino-gen/generators/components/stylesheets/sass.rb +25 -0
- data/lib/padrino-gen/generators/components/tests/bacon.rb +64 -0
- data/lib/padrino-gen/generators/components/tests/cucumber.rb +63 -0
- data/lib/padrino-gen/generators/components/tests/riot.rb +69 -0
- data/lib/padrino-gen/generators/components/tests/rspec.rb +66 -0
- data/lib/padrino-gen/generators/components/tests/shoulda.rb +70 -0
- data/lib/padrino-gen/generators/components/tests/testspec.rb +63 -0
- data/lib/padrino-gen/generators/controller.rb +4 -4
- data/lib/padrino-gen/generators/project/config/apps.rb.tt +12 -4
- data/lib/padrino-gen/generators/project/config/boot.rb +1 -1
- data/lib/padrino-gen/generators/project.rb +1 -1
- data/lib/padrino-gen/generators/templates/controller.rb.tt +1 -1
- data/lib/padrino-gen/generators/templates/scripts/ext-core.js +8 -0
- data/lib/padrino-gen/generators/templates/scripts/jquery.js +150 -15
- data/lib/padrino-gen/padrino-tasks/activerecord.rb +1 -1
- data/lib/padrino-gen/padrino-tasks/mongomapper.rb +1 -1
- data/lib/padrino-gen/padrino-tasks/sequel.rb +37 -0
- data/lib/padrino-gen.rb +9 -2
- data/padrino-gen.gemspec +30 -28
- data/test/helper.rb +5 -0
- data/test/test_app_generator.rb +11 -19
- data/test/test_cli.rb +4 -6
- data/test/test_controller_generator.rb +43 -33
- data/test/test_mailer_generator.rb +11 -17
- data/test/test_migration_generator.rb +42 -47
- data/test/test_model_generator.rb +90 -89
- data/test/test_project_generator.rb +43 -39
- metadata +30 -28
- data/VERSION +0 -1
- data/lib/padrino-gen/generators/components/mocks/mocha_gen.rb +0 -20
- data/lib/padrino-gen/generators/components/mocks/rr_gen.rb +0 -22
- data/lib/padrino-gen/generators/components/orms/activerecord_gen.rb +0 -123
- data/lib/padrino-gen/generators/components/orms/couchrest_gen.rb +0 -56
- data/lib/padrino-gen/generators/components/orms/datamapper_gen.rb +0 -97
- data/lib/padrino-gen/generators/components/orms/mongoid_gen.rb +0 -80
- data/lib/padrino-gen/generators/components/orms/mongomapper_gen.rb +0 -55
- data/lib/padrino-gen/generators/components/orms/sequel_gen.rb +0 -83
- data/lib/padrino-gen/generators/components/renderers/erb_gen.rb +0 -14
- data/lib/padrino-gen/generators/components/renderers/haml_gen.rb +0 -15
- data/lib/padrino-gen/generators/components/scripts/jquery_gen.rb +0 -15
- data/lib/padrino-gen/generators/components/scripts/mootools_gen.rb +0 -15
- data/lib/padrino-gen/generators/components/scripts/prototype_gen.rb +0 -16
- data/lib/padrino-gen/generators/components/scripts/rightjs_gen.rb +0 -15
- data/lib/padrino-gen/generators/components/stylesheets/less_gen.rb +0 -43
- data/lib/padrino-gen/generators/components/stylesheets/sass_gen.rb +0 -35
- data/lib/padrino-gen/generators/components/tests/bacon_test_gen.rb +0 -75
- data/lib/padrino-gen/generators/components/tests/cucumber_test_gen.rb +0 -76
- data/lib/padrino-gen/generators/components/tests/riot_test_gen.rb +0 -80
- data/lib/padrino-gen/generators/components/tests/rspec_test_gen.rb +0 -85
- data/lib/padrino-gen/generators/components/tests/shoulda_test_gen.rb +0 -81
- data/lib/padrino-gen/generators/components/tests/testspec_test_gen.rb +0 -74
@@ -1,17 +1,13 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
|
-
require 'thor/group'
|
3
|
-
require 'fakeweb'
|
4
2
|
|
5
3
|
class TestProjectGenerator < Test::Unit::TestCase
|
6
4
|
def setup
|
7
|
-
FakeWeb.allow_net_connect = false
|
8
5
|
`rm -rf /tmp/sample_project`
|
9
|
-
@project = Padrino::Generators::Project.dup
|
10
6
|
end
|
11
7
|
|
12
8
|
context 'the project generator' do
|
13
9
|
should "allow simple generator to run and create base_app with no options" do
|
14
|
-
assert_nothing_raised { silence_logger {
|
10
|
+
assert_nothing_raised { silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none') } }
|
15
11
|
assert_file_exists('/tmp/sample_project')
|
16
12
|
assert_file_exists('/tmp/sample_project/app')
|
17
13
|
assert_file_exists('/tmp/sample_project/config/boot.rb')
|
@@ -20,23 +16,23 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
20
16
|
end
|
21
17
|
|
22
18
|
should "not create models folder if no orm is chosen" do
|
23
|
-
silence_logger {
|
19
|
+
silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '--orm=none') }
|
24
20
|
assert_no_dir_exists('/tmp/sample_project/app/models')
|
25
21
|
end
|
26
22
|
|
27
23
|
should "not create tests folder if no test framework is chosen" do
|
28
|
-
silence_logger {
|
24
|
+
silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '--test=none') }
|
29
25
|
assert_no_dir_exists('/tmp/sample_project/test')
|
30
26
|
end
|
31
27
|
|
32
28
|
should "place app specific names into correct files" do
|
33
|
-
silence_logger {
|
29
|
+
silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none') }
|
34
30
|
assert_match_in_file(/class SampleProject < Padrino::Application/m, '/tmp/sample_project/app/app.rb')
|
35
31
|
assert_match_in_file(/Padrino.mount_core\("SampleProject"\)/m, '/tmp/sample_project/config/apps.rb')
|
36
32
|
end
|
37
33
|
|
38
34
|
should "create components file containing options chosen with defaults" do
|
39
|
-
silence_logger {
|
35
|
+
silence_logger { generate(:project, 'sample_project', '--root=/tmp') }
|
40
36
|
components_chosen = YAML.load_file('/tmp/sample_project/.components')
|
41
37
|
assert_equal 'none', components_chosen[:orm]
|
42
38
|
assert_equal 'rspec', components_chosen[:test]
|
@@ -47,7 +43,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
47
43
|
|
48
44
|
should "create components file containing options chosen" do
|
49
45
|
component_options = ['--orm=datamapper', '--test=riot', '--mock=mocha', '--script=prototype', '--renderer=erb', '--stylesheet=less']
|
50
|
-
silence_logger {
|
46
|
+
silence_logger { generate(:project, 'sample_project', '--root=/tmp', *component_options) }
|
51
47
|
components_chosen = YAML.load_file('/tmp/sample_project/.components')
|
52
48
|
assert_equal 'datamapper', components_chosen[:orm]
|
53
49
|
assert_equal 'riot', components_chosen[:test]
|
@@ -59,7 +55,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
59
55
|
|
60
56
|
should "output to log components being applied" do
|
61
57
|
component_options = ['--orm=datamapper', '--test=riot', '--mock=mocha', '--script=prototype', '--renderer=erb','--stylesheet=less']
|
62
|
-
buffer = silence_logger {
|
58
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', *component_options) }
|
63
59
|
assert_match /Applying.*?datamapper.*?orm/, buffer
|
64
60
|
assert_match /Applying.*?riot.*?test/, buffer
|
65
61
|
assert_match /Applying.*?mocha.*?mock/, buffer
|
@@ -69,7 +65,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
69
65
|
end
|
70
66
|
|
71
67
|
should "output gem files for base app" do
|
72
|
-
silence_logger {
|
68
|
+
silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none') }
|
73
69
|
assert_match_in_file(/gem 'padrino'/, '/tmp/sample_project/Gemfile')
|
74
70
|
assert_match_in_file(/gem 'rack-flash'/, '/tmp/sample_project/Gemfile')
|
75
71
|
assert_match_in_file(/gem 'rack-test'/, '/tmp/sample_project/Gemfile')
|
@@ -78,27 +74,27 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
78
74
|
|
79
75
|
context "a generator for mock component" do
|
80
76
|
should "properly generate for rr and riot" do
|
81
|
-
buffer = silence_logger {
|
77
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--mock=rr', '--test=riot', '--script=none') }
|
82
78
|
assert_match /Applying.*?rr.*?mock/, buffer
|
83
79
|
assert_match_in_file(/gem 'rr'/, '/tmp/sample_project/Gemfile')
|
84
80
|
end
|
85
81
|
|
86
82
|
should "properly generater for rr and bacon" do
|
87
|
-
buffer = silence_logger {
|
83
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--mock=rr', '--test=bacon', '--script=none') }
|
88
84
|
assert_match /Applying.*?rr.*?mock/, buffer
|
89
85
|
assert_match_in_file(/gem 'rr'/, '/tmp/sample_project/Gemfile')
|
90
86
|
assert_match_in_file(/RR::Adapters::RRMethods/m, '/tmp/sample_project/test/test_config.rb')
|
91
87
|
end
|
92
88
|
|
93
89
|
should "properly generate for mocha and rspec" do
|
94
|
-
buffer = silence_logger {
|
90
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--mock=mocha', '--script=none') }
|
95
91
|
assert_match /Applying.*?mocha.*?mock/, buffer
|
96
92
|
assert_match_in_file(/gem 'mocha'/, '/tmp/sample_project/Gemfile')
|
97
93
|
assert_match_in_file(/conf.mock_with :mocha/m, '/tmp/sample_project/spec/spec_helper.rb')
|
98
94
|
end
|
99
95
|
|
100
96
|
should "properly generate for rr and rspec" do
|
101
|
-
buffer = silence_logger {
|
97
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--mock=rr', '--script=none') }
|
102
98
|
assert_match /Applying.*?rr.*?mock/, buffer
|
103
99
|
assert_match_in_file(/gem 'rr'/, '/tmp/sample_project/Gemfile')
|
104
100
|
assert_match_in_file(/conf.mock_with :rr/m, '/tmp/sample_project/spec/spec_helper.rb')
|
@@ -109,15 +105,17 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
109
105
|
context "the generator for orm components" do
|
110
106
|
should "properly generate for sequel" do
|
111
107
|
@app.instance_eval("undef setup_orm if respond_to?('setup_orm')")
|
112
|
-
buffer = silence_logger {
|
108
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=sequel', '--script=none') }
|
113
109
|
assert_match /Applying.*?sequel.*?orm/, buffer
|
114
110
|
assert_match_in_file(/gem 'sequel'/, '/tmp/sample_project/Gemfile')
|
111
|
+
assert_match_in_file(/gem 'sqlite3-ruby'/, '/tmp/sample_project/Gemfile')
|
115
112
|
assert_match_in_file(/Sequel.connect/, '/tmp/sample_project/config/database.rb')
|
113
|
+
assert_match_in_file(%r{sqlite://}, '/tmp/sample_project/config/database.rb')
|
116
114
|
assert_dir_exists('/tmp/sample_project/app/models')
|
117
115
|
end
|
118
116
|
|
119
117
|
should "properly generate for activerecord" do
|
120
|
-
buffer = silence_logger {
|
118
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=activerecord', '--script=none') }
|
121
119
|
assert_match /Applying.*?activerecord.*?orm/, buffer
|
122
120
|
assert_match_in_file(/gem 'activerecord', :require => "active_record"/, '/tmp/sample_project/Gemfile')
|
123
121
|
assert_match_in_file(/ActiveRecord::Base.establish_connection/, '/tmp/sample_project/config/database.rb')
|
@@ -125,7 +123,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
125
123
|
end
|
126
124
|
|
127
125
|
should "properly generate default for datamapper" do
|
128
|
-
buffer = silence_logger {
|
126
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=datamapper', '--script=none') }
|
129
127
|
assert_match /Applying.*?datamapper.*?orm/, buffer
|
130
128
|
assert_match_in_file(/gem 'data_objects'/, '/tmp/sample_project/Gemfile')
|
131
129
|
assert_match_in_file(/gem 'datamapper'/, '/tmp/sample_project/Gemfile')
|
@@ -134,7 +132,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
134
132
|
end
|
135
133
|
|
136
134
|
should "properly generate for mongomapper" do
|
137
|
-
buffer = silence_logger {
|
135
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=mongomapper', '--script=none') }
|
138
136
|
assert_match /Applying.*?mongomapper.*?orm/, buffer
|
139
137
|
assert_match_in_file(/gem 'mongo_mapper'/, '/tmp/sample_project/Gemfile')
|
140
138
|
assert_match_in_file(/MongoMapper.database/, '/tmp/sample_project/config/database.rb')
|
@@ -142,7 +140,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
142
140
|
end
|
143
141
|
|
144
142
|
should "properly generate for couchrest" do
|
145
|
-
buffer = silence_logger {
|
143
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=couchrest', '--script=none') }
|
146
144
|
assert_match /Applying.*?couchrest.*?orm/, buffer
|
147
145
|
assert_match_in_file(/gem 'couchrest'/, '/tmp/sample_project/Gemfile')
|
148
146
|
assert_match_in_file(/CouchRest.database!/, '/tmp/sample_project/config/database.rb')
|
@@ -152,12 +150,12 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
152
150
|
|
153
151
|
context "the generator for renderer component" do
|
154
152
|
should "properly generate default for erb" do
|
155
|
-
buffer = silence_logger {
|
153
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--renderer=erb', '--script=none') }
|
156
154
|
assert_match /Applying.*?erb.*?renderer/, buffer
|
157
155
|
end
|
158
156
|
|
159
157
|
should "properly generate for haml" do
|
160
|
-
buffer = silence_logger {
|
158
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--renderer=haml','--script=none') }
|
161
159
|
assert_match /Applying.*?haml.*?renderer/, buffer
|
162
160
|
assert_match_in_file(/gem 'haml'/, '/tmp/sample_project/Gemfile')
|
163
161
|
end
|
@@ -165,21 +163,21 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
165
163
|
|
166
164
|
context "the generator for script component" do
|
167
165
|
should "properly generate for jquery" do
|
168
|
-
buffer = silence_logger {
|
166
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=jquery') }
|
169
167
|
assert_match /Applying.*?jquery.*?script/, buffer
|
170
168
|
assert_file_exists('/tmp/sample_project/public/javascripts/jquery.js')
|
171
169
|
assert_file_exists('/tmp/sample_project/public/javascripts/application.js')
|
172
170
|
end
|
173
171
|
|
174
172
|
should "properly generate for mootools" do
|
175
|
-
buffer = silence_logger {
|
173
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=mootools') }
|
176
174
|
assert_match /Applying.*?mootools.*?script/, buffer
|
177
175
|
assert_file_exists('/tmp/sample_project/public/javascripts/mootools-core.js')
|
178
176
|
assert_file_exists('/tmp/sample_project/public/javascripts/application.js')
|
179
177
|
end
|
180
178
|
|
181
179
|
should "properly generate for prototype" do
|
182
|
-
buffer = silence_logger {
|
180
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=prototype') }
|
183
181
|
assert_match /Applying.*?prototype.*?script/, buffer
|
184
182
|
assert_file_exists('/tmp/sample_project/public/javascripts/protopak.js')
|
185
183
|
assert_file_exists('/tmp/sample_project/public/javascripts/lowpro.js')
|
@@ -187,16 +185,23 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
187
185
|
end
|
188
186
|
|
189
187
|
should "properly generate for rightjs" do
|
190
|
-
buffer = silence_logger {
|
188
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=rightjs') }
|
191
189
|
assert_match /Applying.*?rightjs.*?script/, buffer
|
192
190
|
assert_file_exists('/tmp/sample_project/public/javascripts/right.js')
|
193
191
|
assert_file_exists('/tmp/sample_project/public/javascripts/application.js')
|
194
192
|
end
|
193
|
+
|
194
|
+
should "properly generate for ext-core" do
|
195
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=extcore') }
|
196
|
+
assert_match /Applying.*?extcore.*?script/, buffer
|
197
|
+
assert_file_exists('/tmp/sample_project/public/javascripts/ext-core.js')
|
198
|
+
assert_file_exists('/tmp/sample_project/public/javascripts/application.js')
|
199
|
+
end
|
195
200
|
end
|
196
201
|
|
197
202
|
context "the generator for test component" do
|
198
203
|
should "properly default generate for bacon" do
|
199
|
-
buffer = silence_logger {
|
204
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=bacon', '--script=none') }
|
200
205
|
assert_match /Applying.*?bacon.*?test/, buffer
|
201
206
|
assert_match_in_file(/gem 'bacon'/, '/tmp/sample_project/Gemfile')
|
202
207
|
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_project/test/test_config.rb')
|
@@ -205,7 +210,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
205
210
|
end
|
206
211
|
|
207
212
|
should "properly generate for riot" do
|
208
|
-
buffer = silence_logger {
|
213
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=riot', '--script=none') }
|
209
214
|
assert_match /Applying.*?riot.*?test/, buffer
|
210
215
|
assert_match_in_file(/gem 'riot'/, '/tmp/sample_project/Gemfile')
|
211
216
|
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_project/test/test_config.rb')
|
@@ -214,7 +219,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
214
219
|
end
|
215
220
|
|
216
221
|
should "properly generate for rspec" do
|
217
|
-
buffer = silence_logger {
|
222
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=rspec', '--script=none') }
|
218
223
|
assert_match /Applying.*?rspec.*?test/, buffer
|
219
224
|
assert_match_in_file(/gem 'rspec'.*?:require => "spec"/, '/tmp/sample_project/Gemfile')
|
220
225
|
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_project/spec/spec_helper.rb')
|
@@ -223,7 +228,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
223
228
|
end
|
224
229
|
|
225
230
|
should "properly generate for shoulda" do
|
226
|
-
buffer = silence_logger {
|
231
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=shoulda', '--script=none') }
|
227
232
|
assert_match /Applying.*?shoulda.*?test/, buffer
|
228
233
|
assert_match_in_file(/gem 'shoulda'/, '/tmp/sample_project/Gemfile')
|
229
234
|
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_project/test/test_config.rb')
|
@@ -232,7 +237,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
232
237
|
end
|
233
238
|
|
234
239
|
should "properly generate for testspec" do
|
235
|
-
buffer = silence_logger {
|
240
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=testspec', '--script=none') }
|
236
241
|
assert_match /Applying.*?testspec.*?test/, buffer
|
237
242
|
assert_match_in_file(/gem 'test-spec'.*?:require => "test\/spec"/, '/tmp/sample_project/Gemfile')
|
238
243
|
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_project/test/test_config.rb')
|
@@ -241,7 +246,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
241
246
|
end
|
242
247
|
|
243
248
|
should "properly generate for cucumber" do
|
244
|
-
buffer = silence_logger {
|
249
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=cucumber', '--script=none') }
|
245
250
|
assert_match /Applying.*?cucumber.*?test/, buffer
|
246
251
|
assert_match_in_file(/gem 'rspec'.*?:require => "spec"/, '/tmp/sample_project/Gemfile')
|
247
252
|
assert_match_in_file(/gem 'cucumber'/, '/tmp/sample_project/Gemfile')
|
@@ -259,21 +264,20 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
259
264
|
|
260
265
|
context "the generator for stylesheet component" do
|
261
266
|
should "properly generate for sass" do
|
262
|
-
buffer = silence_logger {
|
267
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--renderer=haml','--script=none','--stylesheet=sass') }
|
263
268
|
assert_match_in_file(/gem 'haml'/, '/tmp/sample_project/Gemfile')
|
264
|
-
assert_match_in_file(/module SassInitializer.*Sass::Plugin::Rack/m, '/tmp/sample_project/lib/
|
269
|
+
assert_match_in_file(/module SassInitializer.*Sass::Plugin::Rack/m, '/tmp/sample_project/lib/sass_plugin.rb')
|
265
270
|
assert_match_in_file(/register SassInitializer/m, '/tmp/sample_project/app/app.rb')
|
266
271
|
assert_dir_exists('/tmp/sample_project/app/stylesheets')
|
267
272
|
end
|
268
273
|
|
269
274
|
should "properly generate for less" do
|
270
|
-
buffer = silence_logger {
|
275
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--renderer=haml','--script=none','--stylesheet=less') }
|
271
276
|
assert_match_in_file(/gem 'less'/, '/tmp/sample_project/Gemfile')
|
272
277
|
assert_match_in_file(/gem 'rack-less'/, '/tmp/sample_project/Gemfile')
|
273
|
-
assert_match_in_file(/module LessInitializer.*Rack::Less/m, '/tmp/sample_project/lib/
|
278
|
+
assert_match_in_file(/module LessInitializer.*Rack::Less/m, '/tmp/sample_project/lib/less_plugin.rb')
|
274
279
|
assert_match_in_file(/register LessInitializer/m, '/tmp/sample_project/app/app.rb')
|
275
280
|
assert_dir_exists('/tmp/sample_project/app/stylesheets')
|
276
281
|
end
|
277
282
|
end
|
278
|
-
|
279
|
-
end
|
283
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 10
|
9
|
+
version: 0.9.10
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Padrino Team
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-
|
20
|
+
date: 2010-04-22 00:00:00 +02:00
|
21
21
|
default_executable: padrino-gen
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -30,8 +30,8 @@ dependencies:
|
|
30
30
|
segments:
|
31
31
|
- 0
|
32
32
|
- 9
|
33
|
-
-
|
34
|
-
version: 0.9.
|
33
|
+
- 10
|
34
|
+
version: 0.9.10
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
@@ -132,7 +132,6 @@ files:
|
|
132
132
|
- LICENSE
|
133
133
|
- README.rdoc
|
134
134
|
- Rakefile
|
135
|
-
- VERSION
|
136
135
|
- bin/padrino-gen
|
137
136
|
- lib/padrino-gen.rb
|
138
137
|
- lib/padrino-gen/generators/actions.rb
|
@@ -144,28 +143,29 @@ files:
|
|
144
143
|
- lib/padrino-gen/generators/app/views/layouts/.emptydirectory
|
145
144
|
- lib/padrino-gen/generators/cli.rb
|
146
145
|
- lib/padrino-gen/generators/components/actions.rb
|
147
|
-
- lib/padrino-gen/generators/components/mocks/
|
148
|
-
- lib/padrino-gen/generators/components/mocks/
|
149
|
-
- lib/padrino-gen/generators/components/orms/
|
150
|
-
- lib/padrino-gen/generators/components/orms/
|
151
|
-
- lib/padrino-gen/generators/components/orms/
|
152
|
-
- lib/padrino-gen/generators/components/orms/
|
153
|
-
- lib/padrino-gen/generators/components/orms/
|
154
|
-
- lib/padrino-gen/generators/components/orms/
|
155
|
-
- lib/padrino-gen/generators/components/renderers/
|
156
|
-
- lib/padrino-gen/generators/components/renderers/
|
157
|
-
- lib/padrino-gen/generators/components/scripts/
|
158
|
-
- lib/padrino-gen/generators/components/scripts/
|
159
|
-
- lib/padrino-gen/generators/components/scripts/
|
160
|
-
- lib/padrino-gen/generators/components/scripts/
|
161
|
-
- lib/padrino-gen/generators/components/
|
162
|
-
- lib/padrino-gen/generators/components/stylesheets/
|
163
|
-
- lib/padrino-gen/generators/components/
|
164
|
-
- lib/padrino-gen/generators/components/tests/
|
165
|
-
- lib/padrino-gen/generators/components/tests/
|
166
|
-
- lib/padrino-gen/generators/components/tests/
|
167
|
-
- lib/padrino-gen/generators/components/tests/
|
168
|
-
- lib/padrino-gen/generators/components/tests/
|
146
|
+
- lib/padrino-gen/generators/components/mocks/mocha.rb
|
147
|
+
- lib/padrino-gen/generators/components/mocks/rr.rb
|
148
|
+
- lib/padrino-gen/generators/components/orms/activerecord.rb
|
149
|
+
- lib/padrino-gen/generators/components/orms/couchrest.rb
|
150
|
+
- lib/padrino-gen/generators/components/orms/datamapper.rb
|
151
|
+
- lib/padrino-gen/generators/components/orms/mongoid.rb
|
152
|
+
- lib/padrino-gen/generators/components/orms/mongomapper.rb
|
153
|
+
- lib/padrino-gen/generators/components/orms/sequel.rb
|
154
|
+
- lib/padrino-gen/generators/components/renderers/erb.rb
|
155
|
+
- lib/padrino-gen/generators/components/renderers/haml.rb
|
156
|
+
- lib/padrino-gen/generators/components/scripts/extcore.rb
|
157
|
+
- lib/padrino-gen/generators/components/scripts/jquery.rb
|
158
|
+
- lib/padrino-gen/generators/components/scripts/mootools.rb
|
159
|
+
- lib/padrino-gen/generators/components/scripts/prototype.rb
|
160
|
+
- lib/padrino-gen/generators/components/scripts/rightjs.rb
|
161
|
+
- lib/padrino-gen/generators/components/stylesheets/less.rb
|
162
|
+
- lib/padrino-gen/generators/components/stylesheets/sass.rb
|
163
|
+
- lib/padrino-gen/generators/components/tests/bacon.rb
|
164
|
+
- lib/padrino-gen/generators/components/tests/cucumber.rb
|
165
|
+
- lib/padrino-gen/generators/components/tests/riot.rb
|
166
|
+
- lib/padrino-gen/generators/components/tests/rspec.rb
|
167
|
+
- lib/padrino-gen/generators/components/tests/shoulda.rb
|
168
|
+
- lib/padrino-gen/generators/components/tests/testspec.rb
|
169
169
|
- lib/padrino-gen/generators/controller.rb
|
170
170
|
- lib/padrino-gen/generators/mailer.rb
|
171
171
|
- lib/padrino-gen/generators/migration.rb
|
@@ -185,6 +185,7 @@ files:
|
|
185
185
|
- lib/padrino-gen/generators/templates/helper.rb.tt
|
186
186
|
- lib/padrino-gen/generators/templates/mailer.rb.tt
|
187
187
|
- lib/padrino-gen/generators/templates/mailer_initializer.rb.tt
|
188
|
+
- lib/padrino-gen/generators/templates/scripts/ext-core.js
|
188
189
|
- lib/padrino-gen/generators/templates/scripts/jquery.js
|
189
190
|
- lib/padrino-gen/generators/templates/scripts/lowpro.js
|
190
191
|
- lib/padrino-gen/generators/templates/scripts/mootools-core.js
|
@@ -194,6 +195,7 @@ files:
|
|
194
195
|
- lib/padrino-gen/padrino-tasks/datamapper.rb
|
195
196
|
- lib/padrino-gen/padrino-tasks/mongomapper.rb
|
196
197
|
- lib/padrino-gen/padrino-tasks/seed.rb
|
198
|
+
- lib/padrino-gen/padrino-tasks/sequel.rb
|
197
199
|
- padrino-gen.gemspec
|
198
200
|
- test/helper.rb
|
199
201
|
- test/test_app_generator.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.9.9
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Generators
|
3
|
-
module Components
|
4
|
-
module Mocks
|
5
|
-
|
6
|
-
module MochaGen
|
7
|
-
def setup_mock
|
8
|
-
require_dependencies 'mocha', :group => 'test'
|
9
|
-
case options[:test].to_s
|
10
|
-
when 'rspec'
|
11
|
-
inject_into_file 'spec/spec_helper.rb', " conf.mock_with :mocha\n", :after => "Spec::Runner.configure do |conf|\n"
|
12
|
-
else
|
13
|
-
insert_mocking_include "Mocha::API"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end # MochaGen
|
17
|
-
end # Mocks
|
18
|
-
end # Components
|
19
|
-
end # Generators
|
20
|
-
end # Padrino
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Generators
|
3
|
-
module Components
|
4
|
-
module Mocks
|
5
|
-
|
6
|
-
module RrGen
|
7
|
-
def setup_mock
|
8
|
-
require_dependencies 'rr', :group => 'test'
|
9
|
-
case options[:test].to_s
|
10
|
-
when 'rspec'
|
11
|
-
inject_into_file 'spec/spec_helper.rb', " conf.mock_with :rr\n", :after => "Spec::Runner.configure do |conf|\n"
|
12
|
-
when 'riot'
|
13
|
-
inject_into_file "test/test_config.rb","require 'riot/rr'\n", :after => "\"/../config/boot\"\n"
|
14
|
-
else
|
15
|
-
insert_mocking_include "RR::Adapters::RRMethods", :path => "test/test_config.rb"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end # RrGen
|
19
|
-
end # Mocks
|
20
|
-
end # Components
|
21
|
-
end # Generators
|
22
|
-
end # Padrino
|
@@ -1,123 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Generators
|
3
|
-
module Components
|
4
|
-
module Orms
|
5
|
-
|
6
|
-
module ActiverecordGen
|
7
|
-
|
8
|
-
AR = (<<-AR).gsub(/^ {10}/, '')
|
9
|
-
##
|
10
|
-
# You can use other adapters like:
|
11
|
-
#
|
12
|
-
# ActiveRecord::Base.configurations[:development] = {
|
13
|
-
# :adapter => 'mysql',
|
14
|
-
# :encoding => 'utf8',
|
15
|
-
# :reconnect => false,
|
16
|
-
# :database => 'your_database',
|
17
|
-
# :pool => 5,
|
18
|
-
# :username => 'root',
|
19
|
-
# :password => '',
|
20
|
-
# :host => 'localhost',
|
21
|
-
# :socket => '/tmp/mysql.sock'
|
22
|
-
# }
|
23
|
-
#
|
24
|
-
ActiveRecord::Base.configurations[:development] = {
|
25
|
-
:adapter => 'sqlite3',
|
26
|
-
:database => Padrino.root('db', "development.db")
|
27
|
-
}
|
28
|
-
|
29
|
-
ActiveRecord::Base.configurations[:production] = {
|
30
|
-
:adapter => 'sqlite3',
|
31
|
-
:database => Padrino.root('db', "production.db")
|
32
|
-
}
|
33
|
-
|
34
|
-
ActiveRecord::Base.configurations[:test] = {
|
35
|
-
:adapter => 'sqlite3',
|
36
|
-
:database => Padrino.root('db', "test.db")
|
37
|
-
}
|
38
|
-
|
39
|
-
# Setup our logger
|
40
|
-
ActiveRecord::Base.logger = logger
|
41
|
-
|
42
|
-
# Include Active Record class name as root for JSON serialized output.
|
43
|
-
ActiveRecord::Base.include_root_in_json = true
|
44
|
-
|
45
|
-
# Store the full class name (including module namespace) in STI type column.
|
46
|
-
ActiveRecord::Base.store_full_sti_class = true
|
47
|
-
|
48
|
-
# Use ISO 8601 format for JSON serialized times and dates.
|
49
|
-
ActiveSupport.use_standard_json_time_format = true
|
50
|
-
|
51
|
-
# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
|
52
|
-
# if you're including raw json in an HTML page.
|
53
|
-
ActiveSupport.escape_html_entities_in_json = false
|
54
|
-
|
55
|
-
# Now we can estabilish connection with our db
|
56
|
-
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[Padrino.env])
|
57
|
-
AR
|
58
|
-
|
59
|
-
def setup_orm
|
60
|
-
require_dependencies 'sqlite3-ruby', :require => 'sqlite3'
|
61
|
-
require_dependencies 'activerecord', :require => 'active_record'
|
62
|
-
create_file("config/database.rb", AR)
|
63
|
-
empty_directory('app/models')
|
64
|
-
end
|
65
|
-
|
66
|
-
AR_MODEL = (<<-MODEL).gsub(/^ {10}/, '')
|
67
|
-
class !NAME! < ActiveRecord::Base
|
68
|
-
|
69
|
-
end
|
70
|
-
MODEL
|
71
|
-
|
72
|
-
def create_model_file(name, fields)
|
73
|
-
model_path = destination_root('app/models/', "#{name.to_s.underscore}.rb")
|
74
|
-
model_contents = AR_MODEL.gsub(/!NAME!/, name.to_s.downcase.camelize)
|
75
|
-
create_file(model_path, model_contents,:skip => true)
|
76
|
-
end
|
77
|
-
|
78
|
-
AR_MIGRATION = (<<-MIGRATION).gsub(/^ {10}/, '')
|
79
|
-
class !FILECLASS! < ActiveRecord::Migration
|
80
|
-
def self.up
|
81
|
-
!UP!
|
82
|
-
end
|
83
|
-
|
84
|
-
def self.down
|
85
|
-
!DOWN!
|
86
|
-
end
|
87
|
-
end
|
88
|
-
MIGRATION
|
89
|
-
|
90
|
-
AR_MODEL_UP_MG = (<<-MIGRATION).gsub(/^ {6}/, '')
|
91
|
-
create_table :!TABLE! do |t|
|
92
|
-
!FIELDS!
|
93
|
-
end
|
94
|
-
MIGRATION
|
95
|
-
|
96
|
-
AR_MODEL_DOWN_MG = (<<-MIGRATION).gsub(/^ {10}/, '')
|
97
|
-
drop_table :!TABLE!
|
98
|
-
MIGRATION
|
99
|
-
|
100
|
-
def create_model_migration(migration_name, name, columns)
|
101
|
-
output_model_migration(migration_name, name, columns,
|
102
|
-
:base => AR_MIGRATION,
|
103
|
-
:column_format => Proc.new { |field, kind| "t.#{kind.underscore.gsub(/_/, '')} :#{field}" },
|
104
|
-
:up => AR_MODEL_UP_MG, :down => AR_MODEL_DOWN_MG)
|
105
|
-
end
|
106
|
-
|
107
|
-
AR_CHANGE_MG = (<<-MIGRATION).gsub(/^ {6}/, '')
|
108
|
-
change_table :!TABLE! do |t|
|
109
|
-
!COLUMNS!
|
110
|
-
end
|
111
|
-
MIGRATION
|
112
|
-
|
113
|
-
def create_migration_file(migration_name, name, columns)
|
114
|
-
output_migration_file(migration_name, name, columns,
|
115
|
-
:base => AR_MIGRATION, :change_format => AR_CHANGE_MG,
|
116
|
-
:add => Proc.new { |field, kind| "t.#{kind.underscore.gsub(/_/, '')} :#{field}" },
|
117
|
-
:remove => Proc.new { |field, kind| "t.remove :#{field}" })
|
118
|
-
end
|
119
|
-
end # ActiverecordGen
|
120
|
-
end # Orms
|
121
|
-
end # Components
|
122
|
-
end # Generators
|
123
|
-
end # Padrino
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Generators
|
3
|
-
module Components
|
4
|
-
module Orms
|
5
|
-
|
6
|
-
module CouchrestGen
|
7
|
-
|
8
|
-
COUCHREST = (<<-COUCHREST).gsub(/^ {10}/, '')
|
9
|
-
case Padrino.env
|
10
|
-
when :development then COUCHDB = '!NAME!_name_development'
|
11
|
-
when :production then COUCHDB = '!NAME!_name_production'
|
12
|
-
when :test then COUCHDB = '!NAME!_name_test'
|
13
|
-
end
|
14
|
-
CouchRest.database!(COUCHDB)
|
15
|
-
COUCHREST
|
16
|
-
|
17
|
-
def setup_orm
|
18
|
-
require_dependencies 'couchrest'
|
19
|
-
require_dependencies 'json_pure'
|
20
|
-
create_file("config/database.rb", COUCHREST.gsub(/!NAME!/, name.underscore))
|
21
|
-
empty_directory('app/models')
|
22
|
-
end
|
23
|
-
|
24
|
-
CR_MODEL = (<<-MODEL).gsub(/^ {10}/, '')
|
25
|
-
class !NAME! < CouchRest::ExtendedDocument
|
26
|
-
include CouchRest::Validation
|
27
|
-
|
28
|
-
use_database COUCHDB
|
29
|
-
|
30
|
-
unique_id :id
|
31
|
-
# property <name>
|
32
|
-
!FIELDS!
|
33
|
-
end
|
34
|
-
MODEL
|
35
|
-
|
36
|
-
def create_model_file(name, fields)
|
37
|
-
model_path = destination_root('app/models/', "#{name.to_s.underscore}.rb")
|
38
|
-
field_tuples = fields.collect { |value| value.split(":") }
|
39
|
-
column_declarations = field_tuples.collect { |field, kind| "property :#{field}" }.join("\n ")
|
40
|
-
model_contents = CR_MODEL.gsub(/!NAME!/, name.to_s.camelize)
|
41
|
-
model_contents.gsub!(/!FIELDS!/, column_declarations)
|
42
|
-
create_file(model_path, model_contents)
|
43
|
-
end
|
44
|
-
|
45
|
-
def create_model_migration(filename, name, fields)
|
46
|
-
# NO MIGRATION NEEDED
|
47
|
-
end
|
48
|
-
|
49
|
-
def create_migration_file(migration_name, name, columns)
|
50
|
-
# NO MIGRATION NEEDED
|
51
|
-
end
|
52
|
-
end # ActiverecordGen
|
53
|
-
end # Orms
|
54
|
-
end # Components
|
55
|
-
end # Generators
|
56
|
-
end # Padrino
|