blueprint-generators-rails 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/blueprint/generators/rails/version.rb +1 -1
- data/lib/tasks/blueprint.rake +121 -5
- 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: a8a2b1efbd777c76bbbcc97dae7c27f0b76ac571
|
4
|
+
data.tar.gz: cbdef3a62bfc6dc34de02c72d0ce221b1a879d72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da94016baff471085de4cf48361b3b2a29243ac742a24176f651f2ac1b982f04a5c32b4f9692d996e7f2d4cf8bb99a4487135e9e020b73fea296aa9789043328
|
7
|
+
data.tar.gz: cebab0c1266be740438e189c49ff455c15d7952a3ab7ba865cfce46d09d862284e9369ef6b06ca65da66250ae59ffedf43f41cf133803bc2674e0118c7a7dff6
|
data/Gemfile
CHANGED
data/lib/tasks/blueprint.rake
CHANGED
@@ -2,11 +2,127 @@ namespace :blueprint do
|
|
2
2
|
|
3
3
|
@debug = false
|
4
4
|
|
5
|
+
desc 'Generate Sequence diagrams for the current Rails project (requires use of semantic tags)'
|
6
|
+
task :seq, :root_dir, :debug do |t, args|
|
7
|
+
|
8
|
+
root_dir = args[:root_dir] || '.'
|
9
|
+
@debug = args[:debug]
|
10
|
+
|
11
|
+
if @debug
|
12
|
+
puts "Debug mode #{@debug}"
|
13
|
+
puts "Root directory for analysis is: #{root_dir}"
|
14
|
+
end
|
15
|
+
|
16
|
+
# check that this is actually a Rails projects
|
17
|
+
unless File.exist?(root_dir + '/Gemfile')
|
18
|
+
puts 'No Gemfile found. Is this a Rails project?'
|
19
|
+
next
|
20
|
+
end
|
21
|
+
|
22
|
+
# if we get here than all base sanity checks are passed
|
23
|
+
|
24
|
+
# for debugging purposes
|
25
|
+
step_count = 1
|
26
|
+
|
27
|
+
model = { }
|
28
|
+
|
29
|
+
# otherwise continue analysis
|
30
|
+
Dir.chdir(root_dir) do
|
31
|
+
# list all files in the directory - we scan everything (but maybe we shouldn't)
|
32
|
+
Dir.glob('**/*.{rb,js,coffee}').each { |f|
|
33
|
+
file = File.stat f
|
34
|
+
|
35
|
+
if file.file?
|
36
|
+
|
37
|
+
File.open(f).each do |line|
|
38
|
+
|
39
|
+
# we are scanning for things like this:
|
40
|
+
# # @seq[test, a b]
|
41
|
+
# # @seq_up[test, a b, foo bar]
|
42
|
+
# # @seq_down[test, b a, bar foo]
|
43
|
+
|
44
|
+
tag = line.match(/#[\s]*(@seq[_up|down]*\[.*\])/).try(:captures).try(:first)
|
45
|
+
|
46
|
+
if tag
|
47
|
+
print_debug step_count, "Found sequence start tag: '#{tag}'"
|
48
|
+
step_count += 1
|
49
|
+
|
50
|
+
# extract the tag type and parameters
|
51
|
+
type, parameters = tag.match(/(.*)\[(.*?)\]/).try(:captures)
|
52
|
+
|
53
|
+
case type
|
54
|
+
when '@seq'
|
55
|
+
name, lanes = parameters.split(',').map(&:strip)
|
56
|
+
model[name] ||= { }
|
57
|
+
model[name][:lanes] ||= lanes.split(' ')
|
58
|
+
|
59
|
+
when '@seq_up'
|
60
|
+
name, action = parameters.split(',').map(&:strip)
|
61
|
+
(model[name][:movements] ||= [ ]) << { :direction => :up, :action => action }
|
62
|
+
|
63
|
+
when '@seq_down'
|
64
|
+
name, action = parameters.split(',').map(&:strip)
|
65
|
+
(model[name][:movements] ||= [ ]) << { :direction => :down, :action => action }
|
66
|
+
|
67
|
+
else
|
68
|
+
raise "Tag type #{type} not recognised when generating sequence diagram."
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
}
|
74
|
+
|
75
|
+
# now generate the PogoScript - there may be more than one
|
76
|
+
pogos = [ ]
|
77
|
+
|
78
|
+
model.each { |key, value|
|
79
|
+
pogo = "sequence \"#{key}\" lanes \"#{value[:lanes].uniq.join(', ')}\"\n"
|
80
|
+
|
81
|
+
unless value[:movements].nil?
|
82
|
+
value[:movements].each { |m|
|
83
|
+
case m[:direction]
|
84
|
+
when :up
|
85
|
+
pogo += " up \"#{m[:action]}\"\n"
|
86
|
+
when :down
|
87
|
+
pogo += " down \"#{m[:action]}\"\n"
|
88
|
+
when :fail
|
89
|
+
pogo += " fail down if \"#{m[:action]}\"\n"
|
90
|
+
else
|
91
|
+
raise "Direction not recognised when generating PogoScript: #{m[:direction]}"
|
92
|
+
end
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
pogos << pogo
|
97
|
+
}
|
98
|
+
|
99
|
+
puts ''
|
100
|
+
puts 'Navigate to the link below and paste the provided script into the editor found at:'
|
101
|
+
puts ''
|
102
|
+
puts ' http://anaxim.io/scratchpad/'
|
103
|
+
puts ''
|
104
|
+
puts '----'
|
105
|
+
puts '~~~~'
|
106
|
+
pogos.each { |pogo|
|
107
|
+
puts pogo
|
108
|
+
puts '~~~~'
|
109
|
+
}
|
110
|
+
puts '----'
|
111
|
+
puts ''
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
desc 'Alias for the \'seq\' task'
|
118
|
+
task :sequence => :seq do
|
119
|
+
end
|
120
|
+
|
5
121
|
desc 'Generate a Conceptual Model diagram for the current Rails project'
|
6
122
|
task :cm, :root_dir, :debug do |t, args|
|
7
123
|
|
8
124
|
root_dir = args[:root_dir] || '.'
|
9
|
-
@debug = args[:debug]
|
125
|
+
@debug = args[:debug]
|
10
126
|
|
11
127
|
if @debug
|
12
128
|
puts "Debug mode #{@debug}"
|
@@ -54,7 +170,7 @@ namespace :blueprint do
|
|
54
170
|
f.each_line do |line|
|
55
171
|
m, app_name = line.match(/(module )(.*)/).try(:captures)
|
56
172
|
unless app_name.nil?
|
57
|
-
print_debug step_count, "Application name is "
|
173
|
+
print_debug step_count, "Application name is #{app_name}"
|
58
174
|
step_count += 1
|
59
175
|
break
|
60
176
|
end
|
@@ -66,7 +182,7 @@ namespace :blueprint do
|
|
66
182
|
Dir.chdir(root_dir + '/app/models') do
|
67
183
|
|
68
184
|
# list all files in the directory
|
69
|
-
Dir.glob(
|
185
|
+
Dir.glob('**/*.rb').each { |f|
|
70
186
|
|
71
187
|
# process each file
|
72
188
|
File.open(f) do |g|
|
@@ -138,7 +254,7 @@ namespace :blueprint do
|
|
138
254
|
end
|
139
255
|
end
|
140
256
|
|
141
|
-
print_debug step_count, "Concept
|
257
|
+
print_debug step_count, "Concept #{concept_name} has one #{has_many_name}"
|
142
258
|
step_count += 1
|
143
259
|
end
|
144
260
|
|
@@ -163,7 +279,7 @@ namespace :blueprint do
|
|
163
279
|
model[habtm_name].push({ :type => 'has many', :name => concept_name })
|
164
280
|
end
|
165
281
|
|
166
|
-
print_debug step_count, "Concept
|
282
|
+
print_debug step_count, "Concept #{concept_name} has many-to-many with #{habtm_name}"
|
167
283
|
step_count += 1
|
168
284
|
end
|
169
285
|
|
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.
|
4
|
+
version: 0.2.0
|
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-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|