railsbuilder 0.1.19 → 0.1.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/railsbuilder.rb +56 -29
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 532ee816c29027e4a271eb61fff21d0c1233a064
|
4
|
+
data.tar.gz: b6464756d6d3c266a40c700110459144d2f3c69a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7ec7528656b1cc34c6b77d97bdff9fa2ae434c94c079c32c83a2c8928a688071a24a8446dc742888accc6e47d9a2f4aeb9b3002a516f33d0ece94647323a704
|
7
|
+
data.tar.gz: 7b3d978f7c827255e5e52cf68408be88d263000bef3ba70b0bc1a7ce94b9770d168a550f1127728e0999de2f8a5be4bb3137759a094481a4e26b6b7943cc3d89
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/railsbuilder.rb
CHANGED
@@ -72,6 +72,7 @@ class RailsBuilder
|
|
72
72
|
@app_path = app_path = doc.element('app_path/@app_path') ||
|
73
73
|
File.join(@parent_path, app)
|
74
74
|
|
75
|
+
puts 'changing director to ' + app_path.inspect
|
75
76
|
Dir.chdir app_path
|
76
77
|
|
77
78
|
# select the :resource records
|
@@ -90,8 +91,7 @@ class RailsBuilder
|
|
90
91
|
if buffer[regex] or not buffer[/root '#{root}'/] then
|
91
92
|
|
92
93
|
puts ':: updating ' + routes
|
93
|
-
File.write routes, buffer.sub(regex, '
|
94
|
-
.sub(/'[^']+'/,"'" + root + "'")
|
94
|
+
File.write routes, buffer.sub(regex, " root '" + root + "'")
|
95
95
|
|
96
96
|
trigger = "config: new root added or changed"
|
97
97
|
activity = "file: config/routes.rb modified"
|
@@ -135,46 +135,73 @@ class RailsBuilder
|
|
135
135
|
|
136
136
|
when :model
|
137
137
|
|
138
|
-
#
|
138
|
+
# if there is no controller entry then apply the scaffold command
|
139
|
+
if resource != '*' then
|
140
|
+
|
141
|
+
# does the controller exitst?
|
142
|
+
unless File.exists? controller_file then
|
139
143
|
|
140
|
-
|
144
|
+
command = "rails g controller %s" % resource
|
145
|
+
puts ":: preparing to execute shell command: `#{command}`"
|
146
|
+
puts 'Are you sure you want to generate a controller? (Y/n)'
|
141
147
|
|
142
|
-
|
143
|
-
puts ":: preparing to execute shell command: `#{command}`"
|
144
|
-
puts 'Are you sure you want to generate a controller? (Y/n)'
|
148
|
+
shell command
|
145
149
|
|
146
|
-
|
150
|
+
trigger = "config: model found for a controller which " + "doesn't yet exist"
|
151
|
+
activity = "file: created app/controllers/posts_controller.rb"
|
152
|
+
@notifications << [trigger, activity]
|
153
|
+
end
|
147
154
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
end
|
155
|
+
# if the model fields are defined let's generate the model
|
156
|
+
model = child.element('model_class')
|
157
|
+
next unless model
|
152
158
|
|
153
|
-
|
154
|
-
|
155
|
-
next unless model
|
159
|
+
class_name = model.attributes[:class_name]
|
160
|
+
next unless class_name
|
156
161
|
|
157
|
-
|
158
|
-
next unless class_name
|
162
|
+
attributes = model.xpath('.').map {|x| x.attributes.values}
|
159
163
|
|
160
|
-
|
164
|
+
next if attributes.empty?
|
161
165
|
|
162
|
-
|
166
|
+
s = class_name + ' ' + attributes.map{|x| x.join ':'}.join(' ')
|
163
167
|
|
164
|
-
|
168
|
+
command = "rails generate model %s" % s
|
169
|
+
puts ":: preparing to execute shell command: `#{command}`"
|
170
|
+
puts 'Are you sure you want to generate a model? (Y/n)'
|
165
171
|
|
166
|
-
|
167
|
-
|
168
|
-
puts 'Are you sure you want to generate a model? (Y/n)'
|
172
|
+
r = shell command
|
173
|
+
next if r == :abort
|
169
174
|
|
170
|
-
|
171
|
-
|
175
|
+
trigger = "config: a new model with associated entries has "\
|
176
|
+
+ "been found"
|
177
|
+
activity = "file: created app/models/#{class_name.downcase}.rb"
|
178
|
+
@notifications << [trigger, activity]
|
179
|
+
|
180
|
+
elsif not File.exists? controller_file then
|
181
|
+
|
182
|
+
model = child.element('model_class')
|
183
|
+
next unless model
|
172
184
|
|
173
|
-
|
174
|
-
|
175
|
-
activity = "file: created app/models/#{class_name.downcase}.rb"
|
176
|
-
@notifications << [trigger, activity]
|
185
|
+
class_name = model.attributes[:class_name]
|
186
|
+
next unless class_name
|
177
187
|
|
188
|
+
attributes = model.xpath('.').map {|x| x.attributes.values}
|
189
|
+
|
190
|
+
next if attributes.empty?
|
191
|
+
|
192
|
+
s = class_name + ' ' + attributes.map{|x| x.join ':'}.join(' ')
|
193
|
+
|
194
|
+
command = "rails generate scaffold %s" % s
|
195
|
+
puts ":: preparing to execute shell command: `#{command}`"
|
196
|
+
puts 'Are you sure you want to generate a scaffold? (Y/n)'
|
197
|
+
|
198
|
+
shell command
|
199
|
+
|
200
|
+
trigger = "config: model found for a resouce called *"
|
201
|
+
activity = "file: created app/controllers/posts_controller.rb"
|
202
|
+
@notifications << [trigger, activity]
|
203
|
+
|
204
|
+
end
|
178
205
|
# -- next command ---------------------
|
179
206
|
|
180
207
|
command = "rake db:migrate"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railsbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
bNcCWso1cJhifoTCytPAyf9YVuyU4HjqC3eqx3p00NCg0VoELwMEkyhkpvYOGz2l
|
32
32
|
NSkTRB6yCN+xzQ==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2014-
|
34
|
+
date: 2014-12-01 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rails
|
metadata.gz.sig
CHANGED
Binary file
|