blueprint-generators-rails 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blueprint/generators/rails/version.rb +1 -1
- data/lib/tasks/blueprint.rake +184 -30
- 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: 1dd712f8f1b7539509b06b248346e9f472500de2
|
4
|
+
data.tar.gz: 1cf019fa7f46e990266eab413ba8928aafbb50e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ded0b307aabc8783e5c61a33094f97e44429c1b00490a99f6ebe96241af2ad86bcf9b2bf649611f920f13ec021be92247bfea07c30dd90b4b8b4b6c9ddfa394
|
7
|
+
data.tar.gz: 361b070755dbbc05a24d2c8467a42d293cdb5e57302520a02d4d80a28f913e8ab3fc6591dac8efc7f79d9ef1d0ccd7c8e0d3e72eecf4eaa671902406921d671a
|
data/lib/tasks/blueprint.rake
CHANGED
@@ -10,8 +10,9 @@ namespace :blueprint do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
SEQUENCE_TAG_REGEX = /#[\s]*(:seq[_up|down]*\(.*\))/
|
14
13
|
CONCEPT_STATE_REGEX = /#[\s]*(:state*\(.*\))/
|
14
|
+
SEQUENCE_TAG_REGEX = /#[\s]*(:seq[_up|down]*\(.*\))/
|
15
|
+
ACTIVITY_TAG_REGEX = /#[\s]*(:act[_perform|decide|yes|no|end]*\(.*\))/
|
15
16
|
|
16
17
|
PARAMS_REGEX = /(.*)\((.*?)\)/
|
17
18
|
|
@@ -117,20 +118,7 @@ namespace :blueprint do
|
|
117
118
|
pogos << pogo.strip
|
118
119
|
}
|
119
120
|
|
120
|
-
|
121
|
-
puts 'Navigate to the link below and paste the provided script into the editor found at:'
|
122
|
-
puts ''
|
123
|
-
puts ' http://anaxim.io/#/scratchpad'
|
124
|
-
puts ''
|
125
|
-
puts '----'
|
126
|
-
puts '~~~~'
|
127
|
-
pogos.each { |pogo|
|
128
|
-
puts pogo
|
129
|
-
puts '~~~~'
|
130
|
-
}
|
131
|
-
puts '----'
|
132
|
-
puts ''
|
133
|
-
|
121
|
+
print_results pogos
|
134
122
|
end
|
135
123
|
end
|
136
124
|
|
@@ -174,7 +162,7 @@ namespace :blueprint do
|
|
174
162
|
tag = line.match(SEQUENCE_TAG_REGEX).try(:captures).try(:first)
|
175
163
|
|
176
164
|
if tag
|
177
|
-
print_debug step_count, "Found sequence
|
165
|
+
print_debug step_count, "Found sequence tag: '#{tag}'"
|
178
166
|
step_count += 1
|
179
167
|
|
180
168
|
# extract the tag type and parameters
|
@@ -226,20 +214,7 @@ namespace :blueprint do
|
|
226
214
|
pogos << pogo
|
227
215
|
}
|
228
216
|
|
229
|
-
|
230
|
-
puts 'Navigate to the link below and paste the provided script into the editor found at:'
|
231
|
-
puts ''
|
232
|
-
puts ' http://anaxim.io/#/scratchpad'
|
233
|
-
puts ''
|
234
|
-
puts '----'
|
235
|
-
puts '~~~~'
|
236
|
-
pogos.each { |pogo|
|
237
|
-
puts pogo
|
238
|
-
puts '~~~~'
|
239
|
-
}
|
240
|
-
puts '----'
|
241
|
-
puts ''
|
242
|
-
|
217
|
+
print_results pogos
|
243
218
|
end
|
244
219
|
end
|
245
220
|
|
@@ -247,6 +222,169 @@ namespace :blueprint do
|
|
247
222
|
task :sequence => :seq do
|
248
223
|
end
|
249
224
|
|
225
|
+
desc 'Generate Activity diagrams for the current Rails project (requires use of semantic tags)'
|
226
|
+
task :act, :root_dir, :debug do |t, args|
|
227
|
+
root_dir = args[:root_dir] || '.'
|
228
|
+
@debug = args[:debug]
|
229
|
+
|
230
|
+
if @debug
|
231
|
+
puts "Debug mode #{@debug}"
|
232
|
+
puts "Root directory for analysis is: #{root_dir}"
|
233
|
+
end
|
234
|
+
|
235
|
+
# check that this is actually a Rails projects
|
236
|
+
unless File.exist?(root_dir + '/Gemfile')
|
237
|
+
puts 'No Gemfile found. Is this a Rails project?'
|
238
|
+
next
|
239
|
+
end
|
240
|
+
|
241
|
+
# if we get here than all base sanity checks are passed
|
242
|
+
|
243
|
+
# for debugging purposes
|
244
|
+
step_count = 1
|
245
|
+
|
246
|
+
# find the remote git repository name (so that we can link to it directly in our diagrams)
|
247
|
+
repo_url = determine_remote_repository root_dir
|
248
|
+
remote_origin_found = repo_url.present?
|
249
|
+
|
250
|
+
print_debug step_count, remote_origin_found ? "Remote repository URL is #{repo_url}" : 'No remote repository URL found'
|
251
|
+
step_count += 1
|
252
|
+
|
253
|
+
model = { }
|
254
|
+
|
255
|
+
# otherwise continue analysis
|
256
|
+
Dir.chdir(root_dir) do
|
257
|
+
# list all files in the directory - we scan everything (but maybe we shouldn't)
|
258
|
+
Dir.glob('**/*.{rb,js,coffee}').each { |f|
|
259
|
+
file = File.stat f
|
260
|
+
|
261
|
+
if file.file?
|
262
|
+
line_no = 1
|
263
|
+
|
264
|
+
File.open(f).each do |line|
|
265
|
+
|
266
|
+
# we are scanning for things like this:
|
267
|
+
# # :act(Test, start)
|
268
|
+
# # :act_perform(Test, action)
|
269
|
+
# # :act_decide(Test, condition)
|
270
|
+
# # :act_yes(Test, good outcome)
|
271
|
+
# # :act_no(Test, bad outcome)
|
272
|
+
# # :act_end(Test, done)
|
273
|
+
|
274
|
+
tag = line.match(ACTIVITY_TAG_REGEX).try(:captures).try(:first)
|
275
|
+
|
276
|
+
if tag
|
277
|
+
print_debug step_count, "Found activity tag: '#{tag}'"
|
278
|
+
step_count += 1
|
279
|
+
|
280
|
+
# extract the tag type and parameters
|
281
|
+
type, parameters = tag.match(PARAMS_REGEX).try(:captures)
|
282
|
+
|
283
|
+
case type
|
284
|
+
when ':act'
|
285
|
+
name, start_state = parameters.split(',').map(&:strip)
|
286
|
+
model[name] ||= { }
|
287
|
+
|
288
|
+
if remote_origin_found
|
289
|
+
model[name][:start] ||= { :state => start_state, :at => "#{repo_url}/blob/master/#{f}#L#{line_no}" }
|
290
|
+
else
|
291
|
+
model[name][:start] ||= { :state => start_state }
|
292
|
+
end
|
293
|
+
|
294
|
+
|
295
|
+
when ':act_perform'
|
296
|
+
name, action = parameters.split(',').map(&:strip)
|
297
|
+
if remote_origin_found
|
298
|
+
(model[name][:actions] ||= [ ]) << { :type => 'action', :action => action, :at => "#{repo_url}/blob/master/#{f}#L#{line_no}" }
|
299
|
+
else
|
300
|
+
(model[name][:actions] ||= [ ]) << { :type => 'action', :action => action }
|
301
|
+
end
|
302
|
+
|
303
|
+
when ':act_decide'
|
304
|
+
name, condition = parameters.split(',').map(&:strip)
|
305
|
+
if remote_origin_found
|
306
|
+
(model[name][:actions] ||= [ ]) << { :type => 'decision', :condition => condition, :at => "#{repo_url}/blob/master/#{f}#L#{line_no}" }
|
307
|
+
else
|
308
|
+
(model[name][:actions] ||= [ ]) << { :type => 'decision', :condition => condition }
|
309
|
+
end
|
310
|
+
|
311
|
+
when ':act_yes'
|
312
|
+
name, action = parameters.split(',').map(&:strip)
|
313
|
+
if remote_origin_found
|
314
|
+
(model[name][:actions] ||= [ ]) << { :type => 'yes', :action => action, :at => "#{repo_url}/blob/master/#{f}#L#{line_no}" }
|
315
|
+
else
|
316
|
+
(model[name][:actions] ||= [ ]) << { :type => 'yes', :action => action }
|
317
|
+
end
|
318
|
+
|
319
|
+
when ':act_no'
|
320
|
+
name, action = parameters.split(',').map(&:strip)
|
321
|
+
if remote_origin_found
|
322
|
+
(model[name][:actions] ||= [ ]) << { :type => 'no', :action => action, :at => "#{repo_url}/blob/master/#{f}#L#{line_no}" }
|
323
|
+
else
|
324
|
+
(model[name][:actions] ||= [ ]) << { :type => 'no', :action => action }
|
325
|
+
end
|
326
|
+
|
327
|
+
when ':act_end'
|
328
|
+
name, state = parameters.split(',').map(&:strip)
|
329
|
+
if remote_origin_found
|
330
|
+
(model[name][:actions] ||= [ ]) << { :type => 'end', :state => state, :at => "#{repo_url}/blob/master/#{f}#L#{line_no}" }
|
331
|
+
else
|
332
|
+
(model[name][:actions] ||= [ ]) << { :type => 'end', :state => state }
|
333
|
+
end
|
334
|
+
|
335
|
+
else
|
336
|
+
raise "Tag type #{type} not recognised when generating activity diagram."
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
line_no += 1
|
341
|
+
end
|
342
|
+
end
|
343
|
+
}
|
344
|
+
|
345
|
+
# now generate the PogoScript - there may be more than one
|
346
|
+
pogos = [ ]
|
347
|
+
|
348
|
+
model.each { |key, value|
|
349
|
+
pogo = "activity \"#{key}\" starts with \"#{value[:start][:state]}\"\n"
|
350
|
+
|
351
|
+
unless value[:actions].nil?
|
352
|
+
value[:actions].each { |a|
|
353
|
+
case a[:type]
|
354
|
+
when 'action'
|
355
|
+
pogo += " perform \"#{a[:action]}\"\n"
|
356
|
+
pogo += " at \"#{a[:at]}\"\n" if a[:at].present?
|
357
|
+
when 'decision'
|
358
|
+
pogo += " decide \"#{a[:condition]}\"\n"
|
359
|
+
pogo += " at \"#{a[:at]}\"\n" if a[:at].present?
|
360
|
+
when 'yes'
|
361
|
+
pogo += " yes \"#{a[:action]}\"\n"
|
362
|
+
pogo += " at \"#{a[:at]}\"\n" if a[:at].present?
|
363
|
+
when 'no'
|
364
|
+
pogo += " no \"#{a[:action]}\"\n"
|
365
|
+
pogo += " at \"#{a[:at]}\"\n" if a[:at].present?
|
366
|
+
when 'end'
|
367
|
+
pogo += " end \"#{a[:state]}\"\n"
|
368
|
+
pogo += " at \"#{a[:at]}\"\n" if a[:at].present?
|
369
|
+
else
|
370
|
+
raise "Direction not recognised when generating PogoScript: #{a[:type]}"
|
371
|
+
end
|
372
|
+
|
373
|
+
pogo += "\n"
|
374
|
+
}
|
375
|
+
end
|
376
|
+
|
377
|
+
pogos << pogo.strip
|
378
|
+
}
|
379
|
+
|
380
|
+
print_results pogos
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
desc 'Alias for the \'act\' task'
|
385
|
+
task :activity => :act do
|
386
|
+
end
|
387
|
+
|
250
388
|
desc 'Generate a Conceptual Model diagram for the current Rails project'
|
251
389
|
task :cm, :root_dir, :debug do |t, args|
|
252
390
|
|
@@ -497,4 +635,20 @@ namespace :blueprint do
|
|
497
635
|
end
|
498
636
|
end
|
499
637
|
|
638
|
+
def self.print_results(pogos)
|
639
|
+
puts ''
|
640
|
+
puts 'Navigate to the link below and paste the provided script into the editor found at:'
|
641
|
+
puts ''
|
642
|
+
puts ' http://anaxim.io/#/scratchpad'
|
643
|
+
puts ''
|
644
|
+
puts '----'
|
645
|
+
puts '~~~~'
|
646
|
+
pogos.each { |pogo|
|
647
|
+
puts pogo
|
648
|
+
puts '~~~~'
|
649
|
+
}
|
650
|
+
puts '----'
|
651
|
+
puts ''
|
652
|
+
end
|
653
|
+
|
500
654
|
end
|
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.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- benjii
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|