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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b546a592c51d2e8a4f7792cad307585e0c182b1
4
- data.tar.gz: eacfbee50e3beca731df7ef78e0754673b93cd89
3
+ metadata.gz: 532ee816c29027e4a271eb61fff21d0c1233a064
4
+ data.tar.gz: b6464756d6d3c266a40c700110459144d2f3c69a
5
5
  SHA512:
6
- metadata.gz: acdf3bbef87e31f9c199c19834a9147eb2f5e0698464bcc1027a294964505d6a4212a7ecdc60ba1572045bc490396319d96fe6e430384602ae04cfe5c8738129
7
- data.tar.gz: 110c180f6f4575957fcd93ede187e76ac4389dbd4bb86b88ee128577dad6d6287c9c4b0f7b4d7b91750ecdcef9ee0bf3ad4f1fe6287b9419f367fca80a11b01d
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, ' \1')\
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
- # does the controller exitst?
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
- unless File.exists? controller_file then
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
- command = "rails g controller %s" % resource
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
- shell command
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
- trigger = "config: model found for a controller which " + "doesn't yet exist"
149
- activity = "file: created app/controllers/posts_controller.rb"
150
- @notifications << [trigger, activity]
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
- # if the model fields are defined let's generate the model
154
- model = child.element('model_class')
155
- next unless model
159
+ class_name = model.attributes[:class_name]
160
+ next unless class_name
156
161
 
157
- class_name = model.attributes[:class_name]
158
- next unless class_name
162
+ attributes = model.xpath('.').map {|x| x.attributes.values}
159
163
 
160
- attributes = model.xpath('.').map {|x| x.attributes.values}
164
+ next if attributes.empty?
161
165
 
162
- next if attributes.empty?
166
+ s = class_name + ' ' + attributes.map{|x| x.join ':'}.join(' ')
163
167
 
164
- s = class_name + ' ' + attributes.map{|x| x.join ':'}.join(' ')
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
- command = "rails generate model %s" % s
167
- puts ":: preparing to execute shell command: `#{command}`"
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
- r = shell command
171
- next if r == :abort
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
- trigger = "config: a new model with associated entries has "\
174
- + "been found"
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.19
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-11-29 00:00:00.000000000 Z
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