blueprint-generators-rails 0.1.8 → 0.1.9
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 +4 -4
- data/bin/setup +1 -1
- data/lib/blueprint/generators/rails/version.rb +1 -1
- data/lib/tasks/blueprint.rake +29 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95a1f4cef6d1d5f906de05fa614e527627f0c340
|
4
|
+
data.tar.gz: c20b7ede3ce1599b42f8cb27f8b8534bd515ae44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7eb4b734287df247204e41968a89bad29752fac86b11537504b186a1f9676639c861a797186b9e346769ccc57fc83c3e5e88c6cdb3311b122f033c0bcd98c6dc
|
7
|
+
data.tar.gz: 34c15cd295910813656024f3b586f102fe2255847ab25c335748f89928819445c51f7440b4a85574448ccdb511e0ae85c6c71dd11cf705c958a98833db3e01c7
|
data/bin/setup
CHANGED
data/lib/tasks/blueprint.rake
CHANGED
@@ -100,7 +100,6 @@ namespace :blueprint do
|
|
100
100
|
end
|
101
101
|
|
102
102
|
# search for a 'has_one' or 'belongs_to' declaration
|
103
|
-
# TODO this would find '->' symbols: (has_one) :([^,#\s]+),[\s]*->[\s]*{(.*)}
|
104
103
|
a, has_one_clazz = line.match(/(has_one|belongs_to) :([^,#\s]+)/).try(:captures)
|
105
104
|
unless has_one_clazz.nil?
|
106
105
|
has_one_name = has_one_clazz.classify.singularize.strip
|
@@ -113,13 +112,31 @@ namespace :blueprint do
|
|
113
112
|
end
|
114
113
|
|
115
114
|
# search for a 'has_many' declaration
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
115
|
+
b, has_many_symbol = line.match(/(has_many) :([^,#\s]+)/).try(:captures)
|
116
|
+
unless has_many_symbol.nil?
|
117
|
+
has_many_name = has_many_symbol.classify.pluralize.strip
|
118
|
+
|
119
|
+
# if this declaration has a class name then make sure that we use it in our model
|
120
|
+
explicit_class_name = line.match(/class_name:[\s]*'(.*)'[,]?/).try(:captures)
|
121
|
+
where_clause = line.match(/(where)/).try(:captures)
|
122
|
+
|
123
|
+
# we behave in one of two ways here (just like Rails)
|
124
|
+
# if there is an explicit class name defined then use that as the model name, otherwise use the has many symbol
|
125
|
+
# also, in the case of an explicit class name being declared, look for a 'where' clause (if we find one then
|
126
|
+
# use the has many symbole as the name of the subset that is being defined)
|
120
127
|
|
121
128
|
# add the node relationship to the concept
|
122
|
-
|
129
|
+
if explicit_class_name.nil? || explicit_class_name.empty?
|
130
|
+
model[concept_name].push({ :type => 'has many', :name => has_many_name })
|
131
|
+
else
|
132
|
+
# puts explicit_class_name.inspect
|
133
|
+
if where_clause.nil? || where_clause.empty?
|
134
|
+
model[concept_name].push({ :type => 'has many', :name => explicit_class_name.first.pluralize })
|
135
|
+
else
|
136
|
+
model[concept_name].push({ :type => 'has many', :name => explicit_class_name.first.pluralize,
|
137
|
+
:condition => has_many_symbol.capitalize.pluralize })
|
138
|
+
end
|
139
|
+
end
|
123
140
|
|
124
141
|
print_debug step_count, "Concept " + concept_name + " has one " + has_many_name
|
125
142
|
step_count += 1
|
@@ -167,7 +184,11 @@ namespace :blueprint do
|
|
167
184
|
when 'has one'
|
168
185
|
pogo << " has one \"" + r[:name] + "\"\n"
|
169
186
|
when 'has many'
|
170
|
-
|
187
|
+
if r.has_key?(:condition) && !r[:condition].nil?
|
188
|
+
pogo << " has many \"" + r[:name] + "\" that are \"" + r[:condition] + "\"\n"
|
189
|
+
else
|
190
|
+
pogo << " has many \"" + r[:name] + "\"\n"
|
191
|
+
end
|
171
192
|
else
|
172
193
|
# TODO implement
|
173
194
|
end
|
@@ -176,7 +197,7 @@ namespace :blueprint do
|
|
176
197
|
|
177
198
|
# output the result
|
178
199
|
puts ''
|
179
|
-
puts 'Navigate to the link below and paste the provided script into the editor'
|
200
|
+
puts 'Navigate to the link below and paste the provided script into the editor found at:'
|
180
201
|
puts ''
|
181
202
|
puts ' http://anaxim.io/scratchpad/'
|
182
203
|
puts ''
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blueprint-generators-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- benjii
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|