railsbuilder 0.1.20 → 0.1.21

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 532ee816c29027e4a271eb61fff21d0c1233a064
4
- data.tar.gz: b6464756d6d3c266a40c700110459144d2f3c69a
3
+ metadata.gz: c78cc57d3f08d6b09f920163e8aa5a11acd34f46
4
+ data.tar.gz: bd728be7d7f5af4cfd78fd76087cdef86a38ac49
5
5
  SHA512:
6
- metadata.gz: b7ec7528656b1cc34c6b77d97bdff9fa2ae434c94c079c32c83a2c8928a688071a24a8446dc742888accc6e47d9a2f4aeb9b3002a516f33d0ece94647323a704
7
- data.tar.gz: 7b3d978f7c827255e5e52cf68408be88d263000bef3ba70b0bc1a7ce94b9770d168a550f1127728e0999de2f8a5be4bb3137759a094481a4e26b6b7943cc3d89
6
+ metadata.gz: 7e9ff7a40a74a4f89771776b3376a9eb9694b8551ae31359094f55b0f42a5623dbc78256273d8f44f6558c7bc2f1978087fad794f1828862021f248910037364
7
+ data.tar.gz: 4d9b022ba547927708552f1fb776f6e9be603c9e4e42ce4a0619e7b87b9dfe08e820ff686b4fa613fda71728b868f353d767e2820eb9339b1ee41789103c8962
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/railsbuilder.rb CHANGED
@@ -19,6 +19,8 @@ class RailsBuilder
19
19
 
20
20
  @config = RXFHelper.read(s)[0].gsub(/^(\s{,5})#/,'\1;') if s
21
21
  @tmp_path = @journal = journal == true ? Dir.tmpdir : journal if journal
22
+
23
+ #[:model_class, /(\w+):\s*(string|text|decimal)\s*,?(?<options>.*)/, :class_attribute],
22
24
 
23
25
  patterns = [
24
26
  [:root, 'app_path: :app_path', :app_path],
@@ -28,7 +30,7 @@ class RailsBuilder
28
30
  [:root, ':resource', :resource],
29
31
  [:resource, 'model', :model],
30
32
  [:model, ':class_name', :model_class],
31
- [:model_class, /(\w+):\s*(string|text)/, :class_attribute],
33
+ [:model_class, /^(?<name>\w+):\s*(?<type>string|text|decimal)\s*,?(?<options>.*)/, :class_attribute],
32
34
  [:resource, /(?:controller \+ views|actionpack:)/, :resource_cv],
33
35
  [:resource_cv, /(\w+)(?:\s+([av]{1,2}))?/, :resource_cv_av],
34
36
  [:resource_cv_av, /(markdown):\s*(.*)/, :renderer],
@@ -72,7 +74,7 @@ class RailsBuilder
72
74
  @app_path = app_path = doc.element('app_path/@app_path') ||
73
75
  File.join(@parent_path, app)
74
76
 
75
- puts 'changing director to ' + app_path.inspect
77
+ puts 'changing directory to ' + app_path.inspect
76
78
  Dir.chdir app_path
77
79
 
78
80
  # select the :resource records
@@ -159,11 +161,13 @@ class RailsBuilder
159
161
  class_name = model.attributes[:class_name]
160
162
  next unless class_name
161
163
 
162
- attributes = model.xpath('.').map {|x| x.attributes.values}
164
+ #attributes = model.xpath('.').map {|x| x.attributes.values}
165
+ attributes = model.xpath('.').map {|x| field_attributes x}
163
166
 
164
167
  next if attributes.empty?
165
168
 
166
- s = class_name + ' ' + attributes.map{|x| x.join ':'}.join(' ')
169
+ s = class_name + ' ' + attributes\
170
+ .map{|h| "%s: %s" % [h[:name], h[:type]]}.join(' ')
167
171
 
168
172
  command = "rails generate model %s" % s
169
173
  puts ":: preparing to execute shell command: `#{command}`"
@@ -185,11 +189,12 @@ class RailsBuilder
185
189
  class_name = model.attributes[:class_name]
186
190
  next unless class_name
187
191
 
188
- attributes = model.xpath('.').map {|x| x.attributes.values}
192
+ attributes = model.xpath('.').map {|x| field_attributes x}
189
193
 
190
194
  next if attributes.empty?
191
195
 
192
- s = class_name + ' ' + attributes.map{|x| x.join ':'}.join(' ')
196
+ s = class_name + ' ' + attributes\
197
+ .map{|h| "%s: %s" % [h[:name], h[:type]]}.join(' ')
193
198
 
194
199
  command = "rails generate scaffold %s" % s
195
200
  puts ":: preparing to execute shell command: `#{command}`"
@@ -391,6 +396,20 @@ class RailsBuilder
391
396
 
392
397
  private
393
398
 
399
+ def field_attributes(e)
400
+
401
+ h = {
402
+ name: e.attributes[:name],
403
+ type: e.attributes[:type],
404
+ }
405
+ raw_opt = e.attributes[:options]
406
+ if raw_opt.length > 0 then
407
+ h[:options] = raw_opt.split(/\s*,?\s*\b(?=\w+:)/)[1..-1]\
408
+ .map {|x| x.split(':',2).map(&:lstrip)}
409
+ end
410
+ h
411
+ end
412
+
394
413
  def parse(patterns, s=nil)
395
414
 
396
415
  if s.nil? then
data.tar.gz.sig CHANGED
Binary file
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.20
4
+ version: 0.1.21
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-12-01 00:00:00.000000000 Z
34
+ date: 2014-12-02 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rails
metadata.gz.sig CHANGED
Binary file