railsbuilder 0.1.7 → 0.1.8
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 +44 -9
- metadata +1 -1
- metadata.gz.sig +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 311649e88f84c35d430a4b1f24cdca457f92ecd6
|
4
|
+
data.tar.gz: 535b72090974228bc0a3cc7a1e68557e8162ef4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da3f71bd78cffccd22fb2ec0ee035aa3d9da638801b6bb9f1cdae08b271652f52df491f800eae8f2c3dca40efb5ddd48920bc33414603887f2167bc005e5a977
|
7
|
+
data.tar.gz: 23e16e223972febb71b427bad4ecaddd0cb610c7e20c3d841871e723f66948eb43cf76ae8a69d80226f67b2d9d3269dcee505f27283b5cd94459466c20065c46
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/railsbuilder.rb
CHANGED
@@ -21,6 +21,7 @@ class RailsBuilder
|
|
21
21
|
[:root, ':resource', :resource],
|
22
22
|
[:resource, 'model', :model],
|
23
23
|
[:model, ':class_name', :model_class],
|
24
|
+
[:model_class, /(\w+):\s*(string|text)/, :class_attribute],
|
24
25
|
[:resource, /controller \+ views/, :resource_cv],
|
25
26
|
[:resource_cv, /(\w+)(?:\s+[av]{1,2})?/, :resource_cv_av],
|
26
27
|
[:all, /^\s*#/, :comment]
|
@@ -71,7 +72,8 @@ class RailsBuilder
|
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
74
|
-
resources = doc.element('resources/@resources')
|
75
|
+
resources = doc.element('resources/@resources')
|
76
|
+
puts 'resources :' + resources.inspect
|
75
77
|
|
76
78
|
if resources then
|
77
79
|
|
@@ -90,7 +92,6 @@ class RailsBuilder
|
|
90
92
|
|
91
93
|
resource = node.attributes[:resource]
|
92
94
|
|
93
|
-
puts 'resource : ' + resource.inspect
|
94
95
|
next unless resource
|
95
96
|
|
96
97
|
controller = resource + '_controller.rb'
|
@@ -113,6 +114,28 @@ class RailsBuilder
|
|
113
114
|
shell command
|
114
115
|
end
|
115
116
|
|
117
|
+
# if the model fields are defined let's generate the model
|
118
|
+
model = child.element('model_class')
|
119
|
+
|
120
|
+
class_name = model.attributes[:class_name]
|
121
|
+
attributes = model.xpath('.').map {|x| x.attributes.values}
|
122
|
+
s = class_name + ' ' + attributes.map{|x| x.join ':'}.join(' ')
|
123
|
+
|
124
|
+
command = "rails generate model %s" % s
|
125
|
+
puts ":: preparing to execute shell command: `#{command}`"
|
126
|
+
puts 'Are you sure you want to generate a model? (Y/n)'
|
127
|
+
|
128
|
+
shell command
|
129
|
+
|
130
|
+
# -- next command ---------------------
|
131
|
+
|
132
|
+
command = "rake db:migrate"
|
133
|
+
|
134
|
+
puts ":: preparing to execute shell command: `#{command}`"
|
135
|
+
puts 'Are you sure you want to commit this database operation? (Y/n)'
|
136
|
+
|
137
|
+
shell command
|
138
|
+
|
116
139
|
when :resource_cv
|
117
140
|
|
118
141
|
# fetch the action name
|
@@ -122,7 +145,7 @@ class RailsBuilder
|
|
122
145
|
|
123
146
|
page = action + '.html.erb'
|
124
147
|
view_file = File.join('app','views', resource, page)
|
125
|
-
|
148
|
+
|
126
149
|
# if the controller exists don't try to generate the view,
|
127
150
|
# instead add the entry to the controller file and
|
128
151
|
# create the view file
|
@@ -133,12 +156,24 @@ class RailsBuilder
|
|
133
156
|
buffer = File.read controller_file
|
134
157
|
|
135
158
|
regex = /class \w+Controller < ApplicationController/
|
136
|
-
|
137
|
-
File.
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
159
|
+
|
160
|
+
unless File.exists? view_file then
|
161
|
+
File.write view_file, ''
|
162
|
+
puts ':: created ' + page
|
163
|
+
end
|
164
|
+
|
165
|
+
child.elements.each do |av|
|
166
|
+
|
167
|
+
action = av.attributes[:captures0]
|
168
|
+
next unless action
|
169
|
+
page = action + '.html.erb'
|
170
|
+
|
171
|
+
unless buffer[/\bdef #{action}/] then
|
172
|
+
buffer.sub!(regex) {|x| x + "\n def #{action}\n end\n" }
|
173
|
+
File.write controller_file, buffer
|
174
|
+
puts ':: updated ' + controller
|
175
|
+
end
|
176
|
+
end
|
142
177
|
|
143
178
|
else
|
144
179
|
|
metadata
CHANGED
metadata.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<*!�&Mҁ��+��TlvI�Xd�O4%B���,���?�����q ����bݫD"Wo'~�'�pѺ��(a_�,*�vW��=�b~���̥t��5LhSzŪB�h��>���Q7Ǽ=�Á.ۃmz��v��"Yaaw�>lh{v��P;�&>�3�68t��{��N�melk)�[����;���`��$wpi/R����R��b�H�[��"�ʿ<�d
|
2
|
+
e���g���]+\�H{R���W
|