merb_datamapper 0.9.3 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest.txt +15 -17
- data/Rakefile +2 -2
- data/TODO +3 -3
- data/lib/generators/data_mapper_migration.rb +4 -0
- data/lib/generators/data_mapper_model.rb +15 -0
- data/lib/generators/data_mapper_resource_controller.rb +25 -0
- data/lib/generators/templates/migration.rb +7 -0
- data/lib/generators/templates/model.rb +9 -0
- data/lib/generators/templates/model_migration.rb +15 -0
- data/lib/generators/templates/resource_controller.rb +59 -0
- data/{datamapper_generators/resource_controller/templates/app/views/%controller_file_name% → lib/generators/templates/views}/edit.html.erb +3 -4
- data/{datamapper_generators/resource_controller/templates/app/views/%controller_file_name% → lib/generators/templates/views}/index.html.erb +2 -2
- data/{datamapper_generators/resource_controller/templates/app/views/%controller_file_name% → lib/generators/templates/views}/new.html.erb +3 -4
- data/{datamapper_generators/resource_controller/templates/app/views/%controller_file_name% → lib/generators/templates/views}/show.html.erb +2 -2
- data/lib/merb/session/data_mapper_session.rb +1 -1
- data/lib/merb_datamapper.rb +4 -0
- data/lib/merb_datamapper/merbtasks.rb +31 -0
- data/lib/merb_datamapper/version.rb +2 -2
- data/spec/generators/data_mapper_migration_spec.rb +31 -0
- data/spec/generators/data_mapper_model_spec.rb +38 -0
- data/spec/generators/data_mapper_resource_controller_spec.rb +24 -0
- data/spec/generators/spec_helper.rb +279 -0
- data/spec/spec_helper.rb +1 -1
- metadata +33 -25
- data/datamapper_generators/migration/USAGE +0 -4
- data/datamapper_generators/migration/migration_generator.rb +0 -64
- data/datamapper_generators/migration/templates/new_migration.erb +0 -7
- data/datamapper_generators/model/USAGE +0 -0
- data/datamapper_generators/model/model_generator.rb +0 -45
- data/datamapper_generators/model/templates/app/models/%model_file_name%.rb +0 -7
- data/datamapper_generators/resource_controller/USAGE +0 -0
- data/datamapper_generators/resource_controller/resource_controller_generator.rb +0 -109
- data/datamapper_generators/resource_controller/templates/app/controllers/%controller_file_name%.rb +0 -68
- data/datamapper_generators/resource_controller/templates/app/helpers/%controller_file_name%_helper.rb +0 -16
- data/datamapper_generators/resource_migration/USAGE +0 -4
- data/datamapper_generators/resource_migration/resource_migration_generator.rb +0 -122
- data/datamapper_generators/resource_migration/templates/class_migration.erb +0 -13
@@ -0,0 +1,279 @@
|
|
1
|
+
# require merb-gen and the spec helpers
|
2
|
+
require 'merb-gen'
|
3
|
+
require 'merb-gen/spec_helper'
|
4
|
+
|
5
|
+
# require our other spec helpers
|
6
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
7
|
+
|
8
|
+
# require the generators
|
9
|
+
require 'generators/data_mapper_migration'
|
10
|
+
require 'generators/data_mapper_model'
|
11
|
+
require 'generators/data_mapper_resource_controller'
|
12
|
+
|
13
|
+
# include the helpers
|
14
|
+
Spec::Runner.configure do |config|
|
15
|
+
config.include Merb::Test::GeneratorHelper
|
16
|
+
end
|
17
|
+
|
18
|
+
# copied from merb-more/merb-gen/spec/spec_helpers.rb
|
19
|
+
# 07/08/2008
|
20
|
+
|
21
|
+
shared_examples_for "named generator" do
|
22
|
+
|
23
|
+
describe '#file_name' do
|
24
|
+
|
25
|
+
it "should convert the name to snake case" do
|
26
|
+
@generator.name = 'SomeMoreStuff'
|
27
|
+
@generator.file_name.should == 'some_more_stuff'
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should preserve dashes" do
|
31
|
+
@generator.name = "project-pictures"
|
32
|
+
@generator.file_name.should == "project-pictures"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#base_name' do
|
38
|
+
|
39
|
+
it "should convert the name to snake case" do
|
40
|
+
@generator.name = 'SomeMoreStuff'
|
41
|
+
@generator.base_name.should == 'some_more_stuff'
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should preserve dashes" do
|
45
|
+
@generator.name = "project-pictures"
|
46
|
+
@generator.base_name.should == "project-pictures"
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#symbol_name" do
|
52
|
+
|
53
|
+
it "should snakify the name" do
|
54
|
+
@generator.name = "ProjectPictures"
|
55
|
+
@generator.symbol_name.should == "project_pictures"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should replace dashes with underscores" do
|
59
|
+
@generator.name = "project-pictures"
|
60
|
+
@generator.symbol_name.should == "project_pictures"
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#class_name' do
|
66
|
+
|
67
|
+
it "should convert the name to camel case" do
|
68
|
+
@generator.name = 'some_more_stuff'
|
69
|
+
@generator.class_name.should == 'SomeMoreStuff'
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should convert a name with dashes to camel case" do
|
73
|
+
@generator.name = 'some-more-stuff'
|
74
|
+
@generator.class_name.should == 'SomeMoreStuff'
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#module_name' do
|
80
|
+
|
81
|
+
it "should convert the name to camel case" do
|
82
|
+
@generator.name = 'some_more_stuff'
|
83
|
+
@generator.module_name.should == 'SomeMoreStuff'
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should convert a name with dashes to camel case" do
|
87
|
+
@generator.name = 'some-more-stuff'
|
88
|
+
@generator.module_name.should == 'SomeMoreStuff'
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '#test_class_name' do
|
94
|
+
|
95
|
+
it "should convert the name to camel case and append 'test'" do
|
96
|
+
@generator.name = 'some_more_stuff'
|
97
|
+
@generator.test_class_name.should == 'SomeMoreStuffTest'
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
shared_examples_for "namespaced generator" do
|
105
|
+
|
106
|
+
describe "#class_name" do
|
107
|
+
it "should camelize the name" do
|
108
|
+
@generator.name = "project_pictures"
|
109
|
+
@generator.class_name.should == "ProjectPictures"
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should split off the last double colon separated chunk" do
|
113
|
+
@generator.name = "Test::Monkey::ProjectPictures"
|
114
|
+
@generator.class_name.should == "ProjectPictures"
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should split off the last slash separated chunk" do
|
118
|
+
@generator.name = "test/monkey/project_pictures"
|
119
|
+
@generator.class_name.should == "ProjectPictures"
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should convert a name with dashes to camel case" do
|
123
|
+
@generator.name = 'some-more-stuff'
|
124
|
+
@generator.class_name.should == 'SomeMoreStuff'
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe "#module_name" do
|
129
|
+
it "should camelize the name" do
|
130
|
+
@generator.name = "project_pictures"
|
131
|
+
@generator.module_name.should == "ProjectPictures"
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should split off the last double colon separated chunk" do
|
135
|
+
@generator.name = "Test::Monkey::ProjectPictures"
|
136
|
+
@generator.module_name.should == "ProjectPictures"
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should split off the last slash separated chunk" do
|
140
|
+
@generator.name = "test/monkey/project_pictures"
|
141
|
+
@generator.module_name.should == "ProjectPictures"
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should convert a name with dashes to camel case" do
|
145
|
+
@generator.name = 'some-more-stuff'
|
146
|
+
@generator.module_name.should == 'SomeMoreStuff'
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "#modules" do
|
151
|
+
it "should be empty if no modules are passed to the name" do
|
152
|
+
@generator.name = "project_pictures"
|
153
|
+
@generator.modules.should == []
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should split off all but the last double colon separated chunks" do
|
157
|
+
@generator.name = "Test::Monkey::ProjectPictures"
|
158
|
+
@generator.modules.should == ["Test", "Monkey"]
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should split off all but the last slash separated chunk" do
|
162
|
+
@generator.name = "test/monkey/project_pictures"
|
163
|
+
@generator.modules.should == ["Test", "Monkey"]
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe "#file_name" do
|
168
|
+
it "should snakify the name" do
|
169
|
+
@generator.name = "ProjectPictures"
|
170
|
+
@generator.file_name.should == "project_pictures"
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should preserve dashes" do
|
174
|
+
@generator.name = "project-pictures"
|
175
|
+
@generator.file_name.should == "project-pictures"
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should split off the last double colon separated chunk and snakify it" do
|
179
|
+
@generator.name = "Test::Monkey::ProjectPictures"
|
180
|
+
@generator.file_name.should == "project_pictures"
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should split off the last slash separated chunk and snakify it" do
|
184
|
+
@generator.name = "test/monkey/project_pictures"
|
185
|
+
@generator.file_name.should == "project_pictures"
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe "#base_name" do
|
190
|
+
it "should snakify the name" do
|
191
|
+
@generator.name = "ProjectPictures"
|
192
|
+
@generator.base_name.should == "project_pictures"
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should preserve dashes" do
|
196
|
+
@generator.name = "project-pictures"
|
197
|
+
@generator.base_name.should == "project-pictures"
|
198
|
+
end
|
199
|
+
|
200
|
+
it "should split off the last double colon separated chunk and snakify it" do
|
201
|
+
@generator.name = "Test::Monkey::ProjectPictures"
|
202
|
+
@generator.base_name.should == "project_pictures"
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should split off the last slash separated chunk and snakify it" do
|
206
|
+
@generator.name = "test/monkey/project_pictures"
|
207
|
+
@generator.base_name.should == "project_pictures"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
describe "#symbol_name" do
|
212
|
+
it "should snakify the name and replace dashes with underscores" do
|
213
|
+
@generator.name = "project-pictures"
|
214
|
+
@generator.symbol_name.should == "project_pictures"
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should split off the last slash separated chunk, snakify it and replace dashes with underscores" do
|
218
|
+
@generator.name = "test/monkey/project-pictures"
|
219
|
+
@generator.symbol_name.should == "project_pictures"
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
describe "#test_class_name" do
|
224
|
+
it "should camelize the name and append 'Test'" do
|
225
|
+
@generator.name = "project_pictures"
|
226
|
+
@generator.test_class_name.should == "ProjectPicturesTest"
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should split off the last double colon separated chunk" do
|
230
|
+
@generator.name = "Test::Monkey::ProjectPictures"
|
231
|
+
@generator.test_class_name.should == "ProjectPicturesTest"
|
232
|
+
end
|
233
|
+
|
234
|
+
it "should split off the last slash separated chunk" do
|
235
|
+
@generator.name = "test/monkey/project_pictures"
|
236
|
+
@generator.test_class_name.should == "ProjectPicturesTest"
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
describe "#full_class_name" do
|
241
|
+
it "should camelize the name" do
|
242
|
+
@generator.name = "project_pictures"
|
243
|
+
@generator.full_class_name.should == "ProjectPictures"
|
244
|
+
end
|
245
|
+
|
246
|
+
it "should camelize a name with dashes" do
|
247
|
+
@generator.name = "project-pictures"
|
248
|
+
@generator.full_class_name.should == "ProjectPictures"
|
249
|
+
end
|
250
|
+
|
251
|
+
it "should leave double colon separated chunks" do
|
252
|
+
@generator.name = "Test::Monkey::ProjectPictures"
|
253
|
+
@generator.full_class_name.should == "Test::Monkey::ProjectPictures"
|
254
|
+
end
|
255
|
+
|
256
|
+
it "should convert slashes to double colons and camel case" do
|
257
|
+
@generator.name = "test/monkey/project_pictures"
|
258
|
+
@generator.full_class_name.should == "Test::Monkey::ProjectPictures"
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
describe "#base_path" do
|
263
|
+
it "should be blank for no namespaces" do
|
264
|
+
@generator.name = "project_pictures"
|
265
|
+
@generator.base_path.should == ""
|
266
|
+
end
|
267
|
+
|
268
|
+
it "should snakify and join namespace for double colon separated chunk" do
|
269
|
+
@generator.name = "Test::Monkey::ProjectPictures"
|
270
|
+
@generator.base_path.should == "test/monkey"
|
271
|
+
end
|
272
|
+
|
273
|
+
it "should leave slashes but only use the namespace part" do
|
274
|
+
@generator.name = "test/monkey/project_pictures"
|
275
|
+
@generator.base_path.should == "test/monkey"
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb_datamapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Toy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-08-21 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.
|
23
|
+
version: 0.9.4
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: dm-migrations
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.9.
|
33
|
+
version: 0.9.4
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: merb-core
|
@@ -40,17 +40,27 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.9.
|
43
|
+
version: 0.9.4
|
44
44
|
version:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
|
-
name:
|
46
|
+
name: templater
|
47
47
|
type: :runtime
|
48
48
|
version_requirement:
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.
|
53
|
+
version: 0.1.5
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hoe
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 1.7.0
|
54
64
|
version:
|
55
65
|
description: DataMapper plugin providing DataMapper support for Merb
|
56
66
|
email:
|
@@ -70,23 +80,17 @@ files:
|
|
70
80
|
- README.txt
|
71
81
|
- Rakefile
|
72
82
|
- TODO
|
73
|
-
-
|
74
|
-
-
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
83
|
-
-
|
84
|
-
- datamapper_generators/resource_controller/templates/app/views/%controller_file_name%/index.html.erb
|
85
|
-
- datamapper_generators/resource_controller/templates/app/views/%controller_file_name%/new.html.erb
|
86
|
-
- datamapper_generators/resource_controller/templates/app/views/%controller_file_name%/show.html.erb
|
87
|
-
- datamapper_generators/resource_migration/USAGE
|
88
|
-
- datamapper_generators/resource_migration/resource_migration_generator.rb
|
89
|
-
- datamapper_generators/resource_migration/templates/class_migration.erb
|
83
|
+
- lib/generators/data_mapper_migration.rb
|
84
|
+
- lib/generators/data_mapper_model.rb
|
85
|
+
- lib/generators/data_mapper_resource_controller.rb
|
86
|
+
- lib/generators/templates/migration.rb
|
87
|
+
- lib/generators/templates/model.rb
|
88
|
+
- lib/generators/templates/model_migration.rb
|
89
|
+
- lib/generators/templates/resource_controller.rb
|
90
|
+
- lib/generators/templates/views/edit.html.erb
|
91
|
+
- lib/generators/templates/views/index.html.erb
|
92
|
+
- lib/generators/templates/views/new.html.erb
|
93
|
+
- lib/generators/templates/views/show.html.erb
|
90
94
|
- lib/merb/orms/data_mapper/connection.rb
|
91
95
|
- lib/merb/orms/data_mapper/database.yml.sample
|
92
96
|
- lib/merb/orms/data_mapper/resource.rb
|
@@ -95,6 +99,10 @@ files:
|
|
95
99
|
- lib/merb_datamapper/merbtasks.rb
|
96
100
|
- lib/merb_datamapper/version.rb
|
97
101
|
- spec/connection_spec.rb
|
102
|
+
- spec/generators/data_mapper_migration_spec.rb
|
103
|
+
- spec/generators/data_mapper_model_spec.rb
|
104
|
+
- spec/generators/data_mapper_resource_controller_spec.rb
|
105
|
+
- spec/generators/spec_helper.rb
|
98
106
|
- spec/spec.opts
|
99
107
|
- spec/spec_helper.rb
|
100
108
|
has_rdoc: true
|
@@ -119,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
127
|
version:
|
120
128
|
requirements: []
|
121
129
|
|
122
|
-
rubyforge_project:
|
130
|
+
rubyforge_project: merb
|
123
131
|
rubygems_version: 1.2.0
|
124
132
|
signing_key:
|
125
133
|
specification_version: 2
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# require 'merb'
|
2
|
-
class MigrationGenerator < RubiGen::Base
|
3
|
-
|
4
|
-
default_options :author => nil
|
5
|
-
|
6
|
-
attr_reader :name
|
7
|
-
|
8
|
-
def initialize(runtime_args, runtime_options = {})
|
9
|
-
super
|
10
|
-
usage if args.empty?
|
11
|
-
@name = args.shift
|
12
|
-
extract_options
|
13
|
-
end
|
14
|
-
|
15
|
-
def manifest
|
16
|
-
unless @name
|
17
|
-
puts banner
|
18
|
-
exit 1
|
19
|
-
end
|
20
|
-
record do |m|
|
21
|
-
# Ensure appropriate folder(s) exists
|
22
|
-
m.directory 'schema/migrations'
|
23
|
-
|
24
|
-
# Create stubs
|
25
|
-
highest_migration = Dir[Dir.pwd+'/schema/migrations/*'].map{|f| File.basename(f) =~ /^(\d+)/; $1}.max
|
26
|
-
filename = format("%03d_%s", (highest_migration.to_i+1), @name.snake_case)
|
27
|
-
m.template "new_migration.erb", "schema/migrations/#{filename}.rb", :assigns => { :class_name => @name , :number => (highest_migration.to_i+1) }
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
protected
|
33
|
-
def banner
|
34
|
-
<<-EOS
|
35
|
-
Creates a new migration for merb using DataMapper
|
36
|
-
|
37
|
-
USAGE: #{$0} #{spec.name} NameOfMigration
|
38
|
-
|
39
|
-
Example:
|
40
|
-
#{$0} #{spec.name} AddPeople
|
41
|
-
|
42
|
-
If you already have 3 migrations, this will create the AddPeople migration in
|
43
|
-
schema/migration/004_add_people.rb
|
44
|
-
EOS
|
45
|
-
end
|
46
|
-
|
47
|
-
def add_options!(opts)
|
48
|
-
# opts.separator ''
|
49
|
-
# opts.separator 'Options:'
|
50
|
-
# For each option below, place the default
|
51
|
-
# at the top of the file next to "default_options"
|
52
|
-
# opts.on("-a", "--author=\"Your Name\"", String,
|
53
|
-
# "Some comment about this option",
|
54
|
-
# "Default: none") { |options[:author]| }
|
55
|
-
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
56
|
-
end
|
57
|
-
|
58
|
-
def extract_options
|
59
|
-
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
60
|
-
# Templates can access these value via the attr_reader-generated methods, but not the
|
61
|
-
# raw instance variable value.
|
62
|
-
# @author = options[:author]
|
63
|
-
end
|
64
|
-
end
|