padrino-gen 0.6.3 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/padrino-gen +2 -2
- data/lib/padrino-gen/generators/actions.rb +50 -30
- data/lib/padrino-gen/generators/app/Gemfile +1 -0
- data/lib/padrino-gen/generators/app/config/boot.rb +1 -1
- data/lib/padrino-gen/generators/app.rb +7 -6
- data/lib/padrino-gen/generators/components/actions.rb +55 -56
- data/lib/padrino-gen/generators/components/orms/activerecord_gen.rb +48 -31
- data/lib/padrino-gen/generators/components/orms/couchrest_gen.rb +7 -9
- data/lib/padrino-gen/generators/components/orms/datamapper_gen.rb +16 -12
- data/lib/padrino-gen/generators/components/orms/mongomapper_gen.rb +6 -20
- data/lib/padrino-gen/generators/components/orms/sequel_gen.rb +6 -9
- data/lib/padrino-gen/generators/components/renderers/haml_gen.rb +1 -2
- data/lib/padrino-gen/generators/components/scripts/jquery_gen.rb +2 -2
- data/lib/padrino-gen/generators/components/scripts/prototype_gen.rb +3 -3
- data/lib/padrino-gen/generators/components/scripts/rightjs_gen.rb +2 -4
- data/lib/padrino-gen/generators/components/tests/bacon_test_gen.rb +3 -3
- data/lib/padrino-gen/generators/components/tests/riot_test_gen.rb +3 -3
- data/lib/padrino-gen/generators/components/tests/rspec_test_gen.rb +3 -3
- data/lib/padrino-gen/generators/components/tests/shoulda_test_gen.rb +3 -3
- data/lib/padrino-gen/generators/components/tests/testspec_test_gen.rb +3 -3
- data/lib/padrino-gen/generators/controller.rb +9 -8
- data/lib/padrino-gen/generators/mailer.rb +6 -5
- data/lib/padrino-gen/generators/migration.rb +5 -5
- data/lib/padrino-gen/generators/model.rb +5 -5
- data/lib/padrino-gen/generators.rb +12 -8
- data/lib/padrino-gen/padrino-tasks/activerecord.rb +33 -32
- data/lib/padrino-gen.rb +3 -0
- data/padrino-gen.gemspec +5 -5
- data/test/helper.rb +1 -1
- data/test/test_app_generator.rb +38 -39
- data/test/test_controller_generator.rb +11 -11
- data/test/test_mailer_generator.rb +4 -4
- data/test/test_migration_generator.rb +21 -21
- data/test/test_model_generator.rb +29 -31
- metadata +3 -3
@@ -17,17 +17,17 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
should "generate only generate model once" do
|
20
|
-
silence_logger { @app.start(['sample_app', '
|
20
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
|
21
21
|
response_success = silence_logger { @model_gen.start(['user', '-r=/tmp/sample_app']) }
|
22
22
|
response_duplicate = silence_logger { @model_gen.start(['user', '-r=/tmp/sample_app']) }
|
23
23
|
assert_match_in_file(/class User < ActiveRecord::Base/m, '/tmp/sample_app/app/models/user.rb')
|
24
24
|
# assert_match /'user' model has already been generated!/, response_duplicate
|
25
|
-
assert_match "identical\e[0m
|
26
|
-
assert_match "identical\e[0m
|
25
|
+
assert_match "identical\e[0m app/models/user.rb", response_duplicate
|
26
|
+
assert_match "identical\e[0m test/models/user_test.rb", response_duplicate
|
27
27
|
end
|
28
28
|
|
29
29
|
should "generate migration file versions properly" do
|
30
|
-
silence_logger { @app.start(['sample_app', '
|
30
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
|
31
31
|
silence_logger { @model_gen.start(['user', '-r=/tmp/sample_app']) }
|
32
32
|
silence_logger { @model_gen.start(['account', '-r=/tmp/sample_app']) }
|
33
33
|
silence_logger { @model_gen.start(['bank', '-r=/tmp/sample_app']) }
|
@@ -40,33 +40,31 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
40
40
|
# ACTIVERECORD
|
41
41
|
context "model generator using activerecord" do
|
42
42
|
should "generate model file" do
|
43
|
-
silence_logger { @app.start(['sample_app', '
|
43
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
|
44
44
|
silence_logger { @model_gen.start(['user', '-r=/tmp/sample_app']) }
|
45
45
|
assert_match_in_file(/class User < ActiveRecord::Base/m, '/tmp/sample_app/app/models/user.rb')
|
46
46
|
end
|
47
47
|
|
48
48
|
should "generate migration file with no fields" do
|
49
49
|
current_time = stop_time_for_test.strftime("%Y%m%d%H%M%S")
|
50
|
-
silence_logger { @app.start(['sample_app', '
|
50
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
|
51
51
|
silence_logger { @model_gen.start(['user', '-r=/tmp/sample_app']) }
|
52
52
|
migration_file_path = "/tmp/sample_app/db/migrate/001_create_users.rb"
|
53
53
|
assert_match_in_file(/class CreateUsers < ActiveRecord::Migration/m, migration_file_path)
|
54
54
|
assert_match_in_file(/create_table :users/m, migration_file_path)
|
55
|
-
assert_match_in_file(/# t.column :age, :integer[\n\s]+?end/m, migration_file_path)
|
56
55
|
assert_match_in_file(/drop_table :users/m, migration_file_path)
|
57
56
|
end
|
58
57
|
|
59
58
|
should "generate migration file with given fields" do
|
60
59
|
current_time = stop_time_for_test.strftime("%Y%m%d%H%M%S")
|
61
|
-
silence_logger { @app.start(['sample_app', '
|
60
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
|
62
61
|
silence_logger { @model_gen.start(['person', "name:string", "age:integer", "email:string", '-r=/tmp/sample_app']) }
|
63
62
|
migration_file_path = "/tmp/sample_app/db/migrate/001_create_people.rb"
|
64
63
|
assert_match_in_file(/class CreatePeople < ActiveRecord::Migration/m, migration_file_path)
|
65
64
|
assert_match_in_file(/create_table :people/m, migration_file_path)
|
66
|
-
assert_match_in_file(
|
67
|
-
assert_match_in_file(/t.
|
68
|
-
assert_match_in_file(/t.
|
69
|
-
assert_match_in_file(/t.column :email, :string/m, migration_file_path)
|
65
|
+
assert_match_in_file(/t.string :name/m, migration_file_path)
|
66
|
+
assert_match_in_file(/t.integer :age/m, migration_file_path)
|
67
|
+
assert_match_in_file(/t.string :email/m, migration_file_path)
|
70
68
|
assert_match_in_file(/drop_table :people/m, migration_file_path)
|
71
69
|
end
|
72
70
|
end
|
@@ -74,18 +72,18 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
74
72
|
# COUCHREST
|
75
73
|
context "model generator using couchrest" do
|
76
74
|
should "generate model file with no properties" do
|
77
|
-
silence_logger { @app.start(['sample_app', '
|
75
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=couchrest']) }
|
78
76
|
silence_logger { @model_gen.start(['user', '-r=/tmp/sample_app']) }
|
79
77
|
assert_match_in_file(/class User < CouchRest::ExtendedDocument/m, '/tmp/sample_app/app/models/user.rb')
|
80
|
-
assert_match_in_file(/use_database
|
78
|
+
assert_match_in_file(/use_database COUCHDB/m, '/tmp/sample_app/app/models/user.rb')
|
81
79
|
assert_match_in_file(/# property <name>[\s\n]+?end/m, '/tmp/sample_app/app/models/user.rb')
|
82
80
|
end
|
83
81
|
|
84
82
|
should "generate model file with given fields" do
|
85
|
-
silence_logger { @app.start(['sample_app', '
|
83
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=couchrest']) }
|
86
84
|
silence_logger { @model_gen.start(['person', "name:string", "age", "email:string", '-r=/tmp/sample_app']) }
|
87
85
|
assert_match_in_file(/class Person < CouchRest::ExtendedDocument/m, '/tmp/sample_app/app/models/person.rb')
|
88
|
-
assert_match_in_file(/use_database
|
86
|
+
assert_match_in_file(/use_database COUCHDB/m, '/tmp/sample_app/app/models/person.rb')
|
89
87
|
assert_match_in_file(/property :name/m, '/tmp/sample_app/app/models/person.rb')
|
90
88
|
assert_match_in_file(/property :age/m, '/tmp/sample_app/app/models/person.rb')
|
91
89
|
assert_match_in_file(/property :email/m, '/tmp/sample_app/app/models/person.rb')
|
@@ -95,7 +93,7 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
95
93
|
# DATAMAPPER
|
96
94
|
context "model generator using datamapper" do
|
97
95
|
should "generate model file with fields" do
|
98
|
-
silence_logger { @app.start(['sample_app', '
|
96
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-d=datamapper']) }
|
99
97
|
silence_logger { @model_gen.start(['user', "name:string", "age:integer", "created_at:datetime", '-r=/tmp/sample_app']) }
|
100
98
|
assert_match_in_file(/class User\n\s+include DataMapper::Resource/m, '/tmp/sample_app/app/models/user.rb')
|
101
99
|
assert_match_in_file(/property :name, String/m, '/tmp/sample_app/app/models/user.rb')
|
@@ -104,7 +102,7 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
104
102
|
end
|
105
103
|
|
106
104
|
should "properly generate version numbers" do
|
107
|
-
silence_logger { @app.start(['sample_app', '
|
105
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-d=datamapper']) }
|
108
106
|
silence_logger { @model_gen.start(['user', "name:string", "age:integer", "created_at:datetime", '-r=/tmp/sample_app']) }
|
109
107
|
silence_logger { @model_gen.start(['person', "name:string", "age:integer", "created_at:datetime", '-r=/tmp/sample_app']) }
|
110
108
|
silence_logger { @model_gen.start(['account', "name:string", "age:integer", "created_at:datetime", '-r=/tmp/sample_app']) }
|
@@ -118,7 +116,7 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
118
116
|
|
119
117
|
should "generate migration with given fields" do
|
120
118
|
current_time = stop_time_for_test.strftime("%Y%m%d%H%M%S")
|
121
|
-
silence_logger { @app.start(['sample_app', '
|
119
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-d=datamapper']) }
|
122
120
|
silence_logger { @model_gen.start(['person', "name:string", "created_at:datetime", "email:string", '-r=/tmp/sample_app']) }
|
123
121
|
assert_match_in_file(/class Person\n\s+include DataMapper::Resource/m, '/tmp/sample_app/app/models/person.rb')
|
124
122
|
migration_file_path = "/tmp/sample_app/db/migrate/001_create_people.rb"
|
@@ -134,14 +132,14 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
134
132
|
# MONGOMAPPER
|
135
133
|
context "model generator using mongomapper" do
|
136
134
|
should "generate model file with no properties" do
|
137
|
-
silence_logger { @app.start(['sample_app', '
|
135
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-d=mongomapper']) }
|
138
136
|
silence_logger { @model_gen.start(['person', '-r=/tmp/sample_app']) }
|
139
137
|
assert_match_in_file(/class Person\n\s+include MongoMapper::Document/m, '/tmp/sample_app/app/models/person.rb')
|
140
138
|
assert_match_in_file(/# key <name>, <type>[\n\s]+end/m, '/tmp/sample_app/app/models/person.rb')
|
141
139
|
end
|
142
140
|
|
143
141
|
should "generate model file with given fields" do
|
144
|
-
silence_logger { @app.start(['sample_app', '
|
142
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-d=mongomapper']) }
|
145
143
|
silence_logger { @model_gen.start(['user', "name:string", "age:integer", "email:string", '-r=/tmp/sample_app']) }
|
146
144
|
assert_match_in_file(/class User\n\s+include MongoMapper::Document/m, '/tmp/sample_app/app/models/user.rb')
|
147
145
|
assert_match_in_file(/key :name, String/m, '/tmp/sample_app/app/models/user.rb')
|
@@ -153,14 +151,14 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
153
151
|
# SEQUEL
|
154
152
|
context "model generator using sequel" do
|
155
153
|
should "generate model file with given properties" do
|
156
|
-
silence_logger { @app.start(['sample_app', '
|
154
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-d=sequel']) }
|
157
155
|
silence_logger { @model_gen.start(['user', "name:string", "age:integer", "created:datetime", '-r=/tmp/sample_app']) }
|
158
156
|
assert_match_in_file(/class User < Sequel::Model/m, '/tmp/sample_app/app/models/user.rb')
|
159
157
|
end
|
160
158
|
|
161
159
|
should "generate migration file with given properties" do
|
162
160
|
current_time = stop_time_for_test.strftime("%Y%m%d%H%M%S")
|
163
|
-
silence_logger { @app.start(['sample_app', '
|
161
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-d=sequel']) }
|
164
162
|
silence_logger { @model_gen.start(['person', "name:string", "age:integer", "created:datetime", '-r=/tmp/sample_app']) }
|
165
163
|
migration_file_path = "/tmp/sample_app/db/migrate/001_create_people.rb"
|
166
164
|
assert_match_in_file(/class Person < Sequel::Model/m, '/tmp/sample_app/app/models/person.rb')
|
@@ -176,7 +174,7 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
176
174
|
context "model generator testing files" do
|
177
175
|
# BACON
|
178
176
|
should "generate test file for bacon" do
|
179
|
-
silence_logger { @app.start(['sample_app', '
|
177
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
|
180
178
|
silence_logger { @model_gen.start(['User', '-r=/tmp/sample_app']) }
|
181
179
|
assert_match_in_file(/describe "User Model"/m, '/tmp/sample_app/test/models/user_test.rb')
|
182
180
|
assert_match_in_file(/@user = User.new/m, '/tmp/sample_app/test/models/user_test.rb')
|
@@ -185,7 +183,7 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
185
183
|
|
186
184
|
# RIOT
|
187
185
|
should "generate test file for riot" do
|
188
|
-
silence_logger { @app.start(['sample_app', '
|
186
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=riot', '-d=activerecord']) }
|
189
187
|
silence_logger { @model_gen.start(['User', '-r=/tmp/sample_app']) }
|
190
188
|
assert_match_in_file(/context "User Model" do/m, '/tmp/sample_app/test/models/user_test.rb')
|
191
189
|
assert_match_in_file(/@user = User.new/m, '/tmp/sample_app/test/models/user_test.rb')
|
@@ -194,7 +192,7 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
194
192
|
|
195
193
|
# RSPEC
|
196
194
|
should "generate test file for rspec" do
|
197
|
-
silence_logger { @app.start(['sample_app', '
|
195
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=rspec', '-d=activerecord']) }
|
198
196
|
silence_logger { @model_gen.start(['User', '-r=/tmp/sample_app']) }
|
199
197
|
assert_match_in_file(/describe "User Model"/m, '/tmp/sample_app/test/models/user_spec.rb')
|
200
198
|
assert_match_in_file(/@user = User.new/m, '/tmp/sample_app/test/models/user_spec.rb')
|
@@ -203,7 +201,7 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
203
201
|
|
204
202
|
# SHOULDA
|
205
203
|
should "generate test file for shoulda" do
|
206
|
-
silence_logger { @app.start(['sample_app', '
|
204
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=shoulda', '-d=activerecord']) }
|
207
205
|
silence_logger { @model_gen.start(['Person', '-r=/tmp/sample_app']) }
|
208
206
|
assert_match_in_file(/class PersonControllerTest < Test::Unit::TestCase/m, '/tmp/sample_app/test/models/person_test.rb')
|
209
207
|
assert_match_in_file(/context "Person Model"/m, '/tmp/sample_app/test/models/person_test.rb')
|
@@ -213,7 +211,7 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
213
211
|
|
214
212
|
# TESTSPEC
|
215
213
|
should "generate test file for testspec" do
|
216
|
-
silence_logger { @app.start(['sample_app', '
|
214
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=testspec', '-d=activerecord']) }
|
217
215
|
silence_logger { @model_gen.start(['User', '-r=/tmp/sample_app']) }
|
218
216
|
assert_match_in_file(/context "User Model"/m, '/tmp/sample_app/test/models/user_test.rb')
|
219
217
|
assert_match_in_file(/@user = User.new/m, '/tmp/sample_app/test/models/user_test.rb')
|
@@ -224,7 +222,7 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
224
222
|
context "the model destroy option" do
|
225
223
|
|
226
224
|
should "destroy the model file" do
|
227
|
-
silence_logger { @app.start(['sample_app', '
|
225
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
|
228
226
|
silence_logger { @model_gen.start(['User', '-r=/tmp/sample_app']) }
|
229
227
|
silence_logger { @model_gen.start(['User', '-r=/tmp/sample_app', '-d']) }
|
230
228
|
assert_no_file_exists('/tmp/sample_app/app/models/user.rb')
|
@@ -233,14 +231,14 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
233
231
|
end
|
234
232
|
|
235
233
|
should "destroy the model test file with rspec" do
|
236
|
-
silence_logger { @app.start(['sample_app', '
|
234
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=rspec', '-d=activerecord']) }
|
237
235
|
silence_logger { @model_gen.start(['User', '-r=/tmp/sample_app']) }
|
238
236
|
silence_logger { @model_gen.start(['User', '-r=/tmp/sample_app', '-d']) }
|
239
237
|
assert_no_file_exists('/tmp/sample_app/test/models/user_spec.rb')
|
240
238
|
end
|
241
239
|
|
242
240
|
should "destroy the model migration" do
|
243
|
-
silence_logger { @app.start(['sample_app', '
|
241
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=rspec', '-d=activerecord']) }
|
244
242
|
silence_logger { @model_gen.start(['Person', '-r=/tmp/sample_app']) }
|
245
243
|
silence_logger { @model_gen.start(['User', '-r=/tmp/sample_app']) }
|
246
244
|
silence_logger { @model_gen.start(['User', '-r=/tmp/sample_app', '-d']) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Padrino Team
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2010-01-
|
15
|
+
date: 2010-01-26 00:00:00 +01:00
|
16
16
|
default_executable: padrino-gen
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
requirements:
|
34
34
|
- - "="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.6.
|
36
|
+
version: 0.6.7
|
37
37
|
version:
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: thor
|