railsbuilder 0.1.22 → 0.1.23

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: c18d6ba0744b5e956aae81100b3ff503569fd2bf
4
- data.tar.gz: e347744160dfb7f6d0b5cabf1092cf2c7b8b4d3e
3
+ metadata.gz: 92e62d1557e6de3fae1ab3ca1c3c8ffc0845d0b0
4
+ data.tar.gz: 903e855bb88d44b407ecd3238a40d0a660155c87
5
5
  SHA512:
6
- metadata.gz: 55fc4e60d59a8d6aa6e1daed7a28a4190f5a37d3c905d21bf73544ce43bb004498e9d8abe1794a3df827a5eb2c01d892267b1d239b4d02f3c456eafcc32096ce
7
- data.tar.gz: 3ca691399be170dc92661d17abb982d9da05a2057c533867782197ff5092c48ac7fde728dd1de2053d7ef8d3fa7453fc12869e4fa1f9da2553a6662f276f5d48
6
+ metadata.gz: cf6017f193d072abad191962e50440a4f2978da8b1d2d7f22b5396586c96a1a9bc0125f9a9615601294e661b352717b5d52ac5f1f446853c173e5273c6b375cb
7
+ data.tar.gz: 05649af7837b8fb732ddc7cbe572a0ff226077244c573c3bd468d368de35fc541a959f76b6f91d27156f8a16114f475f4b9964d0f699be05b6c053ac722fe0ab
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/railsbuilder.rb CHANGED
@@ -20,8 +20,6 @@ class RailsBuilder
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
22
 
23
- #[:model_class, /(\w+):\s*(string|text|decimal)\s*,?(?<options>.*)/, :class_attribute],
24
-
25
23
  patterns = [
26
24
  [:root, 'app_path: :app_path', :app_path],
27
25
  [:root, 'app: :app', :app],
@@ -30,7 +28,9 @@ class RailsBuilder
30
28
  [:root, ':resource', :resource],
31
29
  [:resource, 'model', :model],
32
30
  [:model, ':class_name', :model_class],
33
- [:model_class, /^(?<name>\w+):\s*(?<type>string|text|decimal)\s*,?(?<options>.*)/, :class_attribute],
31
+ [:model_class,
32
+ /^(?<name>\w+):\s*(?<type>string|text|decimal)\s*,?(?<options>.*)/,
33
+ :class_attribute],
34
34
  [:resource, /(?:controller \+ views|actionpack:)/, :resource_cv],
35
35
  [:resource_cv, /(\w+)(?:\s+([av]{1,2}))?/, :resource_cv_av],
36
36
  [:resource_cv_av, /(markdown):\s*(.*)/, :renderer],
@@ -194,7 +194,7 @@ class RailsBuilder
194
194
  next if attributes.empty?
195
195
 
196
196
  s = class_name + ' ' + attributes\
197
- .map{|h| "%s: %s" % [h[:name], h[:type].to_s]}.join(' ')
197
+ .map{|h| "%s:%s" % [h[:name], h[:type].to_s]}.join(' ')
198
198
 
199
199
  command = "rails generate scaffold %s" % s
200
200
  puts ":: preparing to execute shell command: `#{command}`"
@@ -206,6 +206,29 @@ class RailsBuilder
206
206
  activity = "file: created app/controllers/posts_controller.rb"
207
207
  @notifications << [trigger, activity]
208
208
 
209
+ # check to see if the class attributes contains options
210
+
211
+ attributes_contain_options = attributes\
212
+ .select {|x| x[:options]}
213
+
214
+ if attributes_contain_options then
215
+
216
+ Dir.chdir File.join(app_path,%w(db migrate))
217
+
218
+ filename = Dir.glob('*.rb').first
219
+ s = File.read filename
220
+
221
+ attributes_contain_options.each do |x|
222
+
223
+ options = x[:options].map {|y| y.join(': ')}.join(', ')
224
+ s.sub!(/t\.#{x[:type].to_s}\s+:#{x[:name]}/,'\0, ' + options)
225
+
226
+ end
227
+
228
+ File.write filename, s
229
+ Dir.chdir app_path
230
+ end
231
+
209
232
  end
210
233
  # -- next command ---------------------
211
234
 
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.22
4
+ version: 0.1.23
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-02 00:00:00.000000000 Z
34
+ date: 2014-12-03 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rails
metadata.gz.sig CHANGED
@@ -1,2 +1,4 @@
1
- X~��I�M�����\-�i�ł/.ܒ����ylkFj(UkH�s�
2
- ZV5��1ݵ=u�␤��(&��$���
1
+ z���=F������L
2
+ R�G���>ӽ��:�0%�M��'dUA�R�! ���Dz���7v_��
3
+ � ���Ky!z-
4
+ MI�22������C(�EL��k�b�2(s�������h
3
- �C<�p&@�RũNL�JV@eg#1F�k�7Al{��NA�]�Nt��퀃&�t]���� q�C����%��^��5�\����������-����QG�*7S