blueprint-generators-rails 0.2.0 → 0.2.1

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: a8a2b1efbd777c76bbbcc97dae7c27f0b76ac571
4
- data.tar.gz: cbdef3a62bfc6dc34de02c72d0ce221b1a879d72
3
+ metadata.gz: 3d3b3ef2e9546e2767dbc32fc11ea4d3f500e39b
4
+ data.tar.gz: db178ccd1aff7cc7e2f2b17b3bd65c95f3949279
5
5
  SHA512:
6
- metadata.gz: da94016baff471085de4cf48361b3b2a29243ac742a24176f651f2ac1b982f04a5c32b4f9692d996e7f2d4cf8bb99a4487135e9e020b73fea296aa9789043328
7
- data.tar.gz: cebab0c1266be740438e189c49ff455c15d7952a3ab7ba865cfce46d09d862284e9369ef6b06ca65da66250ae59ffedf43f41cf133803bc2674e0118c7a7dff6
6
+ metadata.gz: 598abc9b2d4df75dcfa9e841667fd68cb4745d73b77e50d9427c4e29bc86e5bc82568d4c6336d2f1720f6caae75d4c735641b138613fa525c8bc96c99dc065b1
7
+ data.tar.gz: 99f28b17ee7045ffb0bbcf24f13ec84b292e67fea52ac381cef3bd3ff086059631927a48ad2086f4318de6953fcef1311921db77b8dcc7df9056d1c0d4260f58
@@ -1,7 +1,7 @@
1
1
  module Blueprint
2
2
  module Generators
3
3
  module Rails
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
6
6
  end
7
7
  end
@@ -1,5 +1,15 @@
1
1
  namespace :blueprint do
2
2
 
3
+ class String
4
+ def underscore
5
+ self.gsub(/::/, '/').
6
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
7
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
8
+ tr('-', '_').
9
+ downcase
10
+ end
11
+ end
12
+
3
13
  @debug = false
4
14
 
5
15
  desc 'Generate Sequence diagrams for the current Rails project (requires use of semantic tags)'
@@ -99,7 +109,7 @@ namespace :blueprint do
99
109
  puts ''
100
110
  puts 'Navigate to the link below and paste the provided script into the editor found at:'
101
111
  puts ''
102
- puts ' http://anaxim.io/scratchpad/'
112
+ puts ' http://anaxim.io/#/scratchpad'
103
113
  puts ''
104
114
  puts '----'
105
115
  puts '~~~~'
@@ -178,6 +188,19 @@ namespace :blueprint do
178
188
  end
179
189
  end
180
190
 
191
+ # find the remote git repository name (so that we can link to it directly in our diagrams)
192
+ git_remotes = `git remote show origin | grep 'Fetch URL: ' 2>&1`
193
+ repo_url = git_remotes.match(/Fetch URL: (.*).git/).try(:captures)
194
+ print_debug step_count, "! #{repo_url}"
195
+ remote_origin_found = !repo_url.empty?
196
+ if remote_origin_found
197
+ repo_url = repo_url[0]
198
+ print_debug step_count, "Remote repository URL is #{repo_url}"
199
+ else
200
+ print_debug step_count, 'No remote repository URL found'
201
+ end
202
+ step_count += 1
203
+
181
204
  # otherwise continue analysis
182
205
  Dir.chdir(root_dir + '/app/models') do
183
206
 
@@ -199,18 +222,23 @@ namespace :blueprint do
199
222
  concept_name = clazz.pluralize
200
223
 
201
224
  # add the concept to the model hash
202
- model[concept_name] = [ ]
225
+ if remote_origin_found
226
+ model[concept_name] = { :at => "#{repo_url}/blob/master/app/models/#{clazz.underscore}.rb#L1",
227
+ :relationships => [ ] }
228
+ else
229
+ model[concept_name] = { :relationships => [ ] }
230
+ end
203
231
 
204
- print_debug step_count, "Adding concept " + concept_name
232
+ print_debug step_count, "Adding concept #{concept_name}"
205
233
  step_count += 1
206
234
 
207
235
  unless super_clazz.strip == 'ActiveRecord::Base'
208
236
  is_a_name = super_clazz.singularize
209
237
 
210
238
  # add the node relationship to the concept
211
- model[concept_name].push({ :type => 'is a', :name => is_a_name })
239
+ model[concept_name][:relationships].push({ :type => 'is a', :name => is_a_name })
212
240
 
213
- print_debug step_count, "Concept " + concept_name + " is a " + is_a_name
241
+ print_debug step_count, "Concept #{concept_name} is a #{is_a_name}"
214
242
  step_count += 1
215
243
  end
216
244
  end
@@ -221,9 +249,9 @@ namespace :blueprint do
221
249
  has_one_name = has_one_clazz.classify.singularize.strip
222
250
 
223
251
  # add the node relationship to the concept
224
- model[concept_name].push({ :type => 'has one', :name => has_one_name })
252
+ model[concept_name][:relationships].push({ :type => 'has one', :name => has_one_name })
225
253
 
226
- print_debug step_count, "Concept " + concept_name + " has one " + has_one_name
254
+ print_debug step_count, "Concept #{concept_name} has one #{has_one_name}"
227
255
  step_count += 1
228
256
  end
229
257
 
@@ -243,14 +271,14 @@ namespace :blueprint do
243
271
 
244
272
  # add the node relationship to the concept
245
273
  if explicit_class_name.nil? || explicit_class_name.empty?
246
- model[concept_name].push({ :type => 'has many', :name => has_many_name })
274
+ model[concept_name][:relationships].push({ :type => 'has many', :name => has_many_name })
247
275
  else
248
276
  # puts explicit_class_name.inspect
249
277
  if where_clause.nil? || where_clause.empty?
250
- model[concept_name].push({ :type => 'has many', :name => explicit_class_name.first.pluralize })
278
+ model[concept_name][:relationships].push({ :type => 'has many', :name => explicit_class_name.first.pluralize })
251
279
  else
252
- model[concept_name].push({ :type => 'has many', :name => explicit_class_name.first.pluralize,
253
- :condition => has_many_symbol.capitalize.pluralize })
280
+ model[concept_name][:relationships].push({ :type => 'has many', :name => explicit_class_name.first.pluralize,
281
+ :condition => has_many_symbol.capitalize.pluralize })
254
282
  end
255
283
  end
256
284
 
@@ -265,8 +293,8 @@ namespace :blueprint do
265
293
  habtm_name = habtm_clazz.classify.pluralize.strip
266
294
 
267
295
  # add the first side of the 'has many' if it does not already exist
268
- if model[concept_name].find { |v| v[:type] == 'has many' && v[:name] == habtm_name }.nil?
269
- model[concept_name].push({ :type => 'has many', :name => habtm_name })
296
+ if model[concept_name][:relationships].find { |v| v[:type] == 'has many' && v[:name] == habtm_name }.nil?
297
+ model[concept_name][:relationships].push({ :type => 'has many', :name => habtm_name })
270
298
  end
271
299
 
272
300
  # if the model hash doesn't have any entry for the many side of the relationship, create it
@@ -275,8 +303,8 @@ namespace :blueprint do
275
303
  end
276
304
 
277
305
  # add the second side of the 'has many' if it does not already exist
278
- if model[habtm_name].find { |v| v[:type] == 'has many' && v[:name] == concept_name }.nil?
279
- model[habtm_name].push({ :type => 'has many', :name => concept_name })
306
+ if model[habtm_name][:relationships].find { |v| v[:type] == 'has many' && v[:name] == concept_name }.nil?
307
+ model[habtm_name][:relationships].push({ :type => 'has many', :name => concept_name })
280
308
  end
281
309
 
282
310
  print_debug step_count, "Concept #{concept_name} has many-to-many with #{habtm_name}"
@@ -290,10 +318,11 @@ namespace :blueprint do
290
318
 
291
319
  # now generate the PogoScript
292
320
  pogo = "conceptual model for \"" + app_name + "\""
293
- model.each { |name, relationships|
321
+ model.each { |name, data|
294
322
  pogo << "\n concept \"" + name + "\"\n"
323
+ pogo << " at \"" + data[:at] + "\"\n" unless data[:at].blank?
295
324
 
296
- relationships.each { |r|
325
+ data[:relationships].each { |r|
297
326
  case r[:type]
298
327
  when 'is a'
299
328
  pogo << " is a \"" + r[:name] + "\"\n"
@@ -315,7 +344,7 @@ namespace :blueprint do
315
344
  puts ''
316
345
  puts 'Navigate to the link below and paste the provided script into the editor found at:'
317
346
  puts ''
318
- puts ' http://anaxim.io/scratchpad/'
347
+ puts ' http://anaxim.io/#/scratchpad'
319
348
  puts ''
320
349
  puts '~~~~'
321
350
  puts pogo
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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - benjii
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-13 00:00:00.000000000 Z
11
+ date: 2015-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler