lucidMachines 0.1.6 → 0.1.7
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/lib/lucidMachines/aasm_export.rb +18 -20
- data/lib/lucidMachines/cli.rb +4 -5
- data/lib/lucidMachines/helper.rb +24 -12
- data/lib/lucidMachines/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb8dd82691cb61b58f739af99ca7844b5bca2f8de5b0c2ebc6573a842637457a
|
4
|
+
data.tar.gz: 62798b5ccde38af244466fd4b799459d092aa0f2ff411fe46f75d22294eba364
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2066c5e7003d39cb460f027264c4d7804c5a51428cf8002a191571eb3caac898e7b785c6e260ad20fd3b4a6b2a9ec808a872440da7cd8189bd5351719e661df8
|
7
|
+
data.tar.gz: ae02eeb8e23efeda189e0d3d5dd545a9861bc8098b28cf8bc1baa28acff5c3a0fc871edfbcf3ce0ec5def8ef7341569a01586cc8fbd082369042905c65a412cf
|
@@ -25,6 +25,7 @@ class AASMExport
|
|
25
25
|
@chart = chart
|
26
26
|
init_method_names
|
27
27
|
create
|
28
|
+
@spaces = " "
|
28
29
|
end
|
29
30
|
|
30
31
|
def init_method_names
|
@@ -155,7 +156,7 @@ class AASMExport
|
|
155
156
|
def generate_state_code
|
156
157
|
states_code = ""
|
157
158
|
@states.each do |state|
|
158
|
-
code = "
|
159
|
+
code = @spaces*2 + "state :" + sanitize(state.text)
|
159
160
|
code = code + ", :initial => true" if state.initial
|
160
161
|
|
161
162
|
callback_code = generate_callback(state, "method", StateCallbacks)
|
@@ -169,8 +170,9 @@ class AASMExport
|
|
169
170
|
|
170
171
|
|
171
172
|
attributes_code = <<-INIT
|
172
|
-
|
173
|
-
|
173
|
+
|
174
|
+
#{@spaces}def event_attributes
|
175
|
+
#{@spaces*2}attributes = {}
|
174
176
|
INIT
|
175
177
|
|
176
178
|
events = @chart.get_blocks_of_type "event"
|
@@ -183,7 +185,7 @@ INIT
|
|
183
185
|
unless attributes.empty?
|
184
186
|
|
185
187
|
c = <<-START
|
186
|
-
|
188
|
+
#{@spaces*3}attributes["#{event.text}"] = #{attributes.to_s}
|
187
189
|
START
|
188
190
|
|
189
191
|
attributes_code = attributes_code + c
|
@@ -193,11 +195,7 @@ START
|
|
193
195
|
|
194
196
|
end
|
195
197
|
end
|
196
|
-
attributes_code +
|
197
|
-
return attributes
|
198
|
-
end
|
199
|
-
|
200
|
-
END
|
198
|
+
attributes_code + "#{@spaces*2}return attributes\n#{@spaces}end\n\n"
|
201
199
|
|
202
200
|
end
|
203
201
|
|
@@ -218,9 +216,9 @@ END
|
|
218
216
|
name = sanitize(link.text)
|
219
217
|
|
220
218
|
code = <<-SMALL_EVENT
|
221
|
-
|
222
|
-
|
223
|
-
|
219
|
+
#{@spaces*2}event :#{name} do
|
220
|
+
#{@spaces*3}transitions :from => :#{@chart.blocks[link.source].text}, :to => :#{@chart.blocks[link.destination].text}
|
221
|
+
#{@spaces*2}end
|
224
222
|
|
225
223
|
SMALL_EVENT
|
226
224
|
|
@@ -229,7 +227,7 @@ SMALL_EVENT
|
|
229
227
|
end
|
230
228
|
|
231
229
|
@events.each do |event|
|
232
|
-
code = "
|
230
|
+
code = @spaces*2 + "event :" + sanitize(event.text)
|
233
231
|
|
234
232
|
## Add event :before :after...
|
235
233
|
callback_code = generate_callback(event, "method", EventCallbacks)
|
@@ -273,7 +271,7 @@ SMALL_EVENT
|
|
273
271
|
end
|
274
272
|
end
|
275
273
|
|
276
|
-
code = code + "
|
274
|
+
code = code + @spaces*2 + "end\n\n"
|
277
275
|
events_code = events_code + code
|
278
276
|
end
|
279
277
|
|
@@ -367,10 +365,10 @@ SMALL_EVENT
|
|
367
365
|
method_names().each do |method_name|
|
368
366
|
|
369
367
|
code = code + <<-METH
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
368
|
+
#{@spaces}def #{method_name}
|
369
|
+
#{@spaces*2}puts "Please implement the method #{method_name}"
|
370
|
+
#{@spaces*2}true
|
371
|
+
#{@spaces}end
|
374
372
|
|
375
373
|
METH
|
376
374
|
end
|
@@ -400,11 +398,11 @@ METH
|
|
400
398
|
# methods called by it.
|
401
399
|
def export
|
402
400
|
start = <<-START
|
403
|
-
|
401
|
+
#{@spaces}aasm do
|
404
402
|
START
|
405
403
|
|
406
404
|
finish = <<-END
|
407
|
-
|
405
|
+
#{@spaces}end
|
408
406
|
END
|
409
407
|
return generate_attributes_code +
|
410
408
|
start + generate_state_code +
|
data/lib/lucidMachines/cli.rb
CHANGED
@@ -3,17 +3,16 @@ require 'ruby-graphviz'
|
|
3
3
|
|
4
4
|
module LucidMachines
|
5
5
|
|
6
|
-
|
7
6
|
class CLI < Thor
|
8
7
|
|
9
|
-
desc "convert FILE.CSV 'Name'", "Convert a CSV file"
|
10
|
-
def convert(csv_file, sheet = "")
|
8
|
+
desc "convert FILE.CSV 'Name' 'CLASS'", "Convert a CSV file to file with the given CLASS name."
|
9
|
+
def convert(csv_file, sheet = "", class_name = "MyClass")
|
11
10
|
chart = ChartLoader.new(csv_file).chart
|
12
11
|
|
13
12
|
if(sheet == "")
|
14
13
|
export_all chart
|
15
14
|
else
|
16
|
-
|
15
|
+
export(chart, sheet, class_name)
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
@@ -30,7 +29,7 @@ module LucidMachines
|
|
30
29
|
|
31
30
|
c = Object.const_get(class_name)
|
32
31
|
puts c.class.to_s
|
33
|
-
@ae = AASMExport.new(subchart)
|
32
|
+
@ae = AASMExport.new(subchart)
|
34
33
|
c.class_eval @ae.export
|
35
34
|
# puts @ae.generate_methods_placeholder_for(c).to_s
|
36
35
|
open("#{file}-updated.rb", 'w') do |f|
|
data/lib/lucidMachines/helper.rb
CHANGED
@@ -1,23 +1,35 @@
|
|
1
|
-
def export_all(chart)
|
2
|
-
chart.pages.each_value do |p|
|
3
|
-
export(chart, p.name)
|
4
|
-
end
|
5
|
-
end
|
6
1
|
|
7
|
-
def export(chart, page_name)
|
8
|
-
p_ex2 = chart.page page_name
|
9
|
-
page = chart.subchart_for_page p_ex2
|
10
2
|
|
3
|
+
def export(chart, sheet, class_name = "MyClass")
|
4
|
+
p_ex2 = chart.page sheet
|
5
|
+
page = chart.subchart_for_page p_ex2
|
6
|
+
|
11
7
|
# export GraphViz 1
|
12
|
-
GraphVizExport.new(page).build_graph("export/chart-#{
|
13
|
-
|
8
|
+
GraphVizExport.new(page).build_graph("export/chart-#{sheet}.png")
|
9
|
+
|
14
10
|
# export AASM
|
15
11
|
page_aasm_export = AASMExport.new(page)
|
16
|
-
|
12
|
+
|
13
|
+
b = <<-CODE_BEGIN
|
14
|
+
class #{class_name}
|
15
|
+
CODE_BEGIN
|
16
|
+
|
17
|
+
e = <<-CODE_END
|
18
|
+
end
|
19
|
+
CODE_END
|
20
|
+
|
17
21
|
# export to a file
|
18
|
-
open("export/#{
|
22
|
+
open("export/#{sheet}_generated.rb", 'w') do |f|
|
23
|
+
f << b
|
19
24
|
f << page_aasm_export.export
|
20
25
|
f << page_aasm_export.generate_methods_placeholder
|
26
|
+
f << e
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def export_all(chart)
|
31
|
+
chart.pages.each_value do |p|
|
32
|
+
export(chart, p.name)
|
21
33
|
end
|
22
34
|
end
|
23
35
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lucidMachines
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Laviole
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
160
|
- !ruby/object:Gem::Version
|
161
161
|
version: '0'
|
162
162
|
requirements: []
|
163
|
-
rubygems_version: 3.0.
|
163
|
+
rubygems_version: 3.0.3
|
164
164
|
signing_key:
|
165
165
|
specification_version: 4
|
166
166
|
summary: Creates AASM state machines from LucidChart diagrams.
|