lucidMachines 0.1.4 → 0.1.5
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/Gemfile.lock +1 -1
- data/lib/lucidMachines/aasm_export.rb +39 -5
- data/lib/lucidMachines/cli.rb +14 -13
- data/lib/lucidMachines/{exporter.rb → helper.rb} +0 -16
- data/lib/lucidMachines/loader.rb +1 -1
- data/lib/lucidMachines/version.rb +1 -1
- data/lib/lucidMachines.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 541a77494d9a38cfb803f3ab6e48a1c4898d96da4fcc4c424e0b99f7fd6fd585
|
4
|
+
data.tar.gz: 8b625442be7a47fae536d6b59176268dd30954380d559579b7a56e21434326b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f4ba313714b5258c165655f86a69500587f0a072d1b60cdcf120d6f91eb9ca06f22d2c094692c49d5b1e87e7956f857679164e02e69df07cb6a4ed36e6de988
|
7
|
+
data.tar.gz: 11592951f9d7942abb58b9490ef0a238b3297160fc570005db92bbc6a91f0c6ec2849464a46fe647c13fe1c93b3e6b9fd4d4f948d05760dcbcddd2e34adac1d5
|
data/Gemfile.lock
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
+
|
3
4
|
class AASMExport
|
4
5
|
|
5
6
|
EventCallbacks = ["before", "guards", "guard",
|
@@ -123,9 +124,10 @@ class AASMExport
|
|
123
124
|
end
|
124
125
|
|
125
126
|
# puts "Transitions found " + @transitions.size.to_s
|
126
|
-
|
127
127
|
end
|
128
128
|
|
129
|
+
|
130
|
+
|
129
131
|
def print_warning(event, from_states, to_state)
|
130
132
|
|
131
133
|
if(event.size != 1)
|
@@ -153,18 +155,49 @@ class AASMExport
|
|
153
155
|
def generate_state_code
|
154
156
|
states_code = ""
|
155
157
|
@states.each do |state|
|
156
|
-
|
157
158
|
code = " state :" + sanitize(state.text)
|
158
159
|
code = code + ", :initial => true" if state.initial
|
159
160
|
|
160
161
|
callback_code = generate_callback(state, "method", StateCallbacks)
|
161
|
-
|
162
162
|
states_code = states_code + code + callback_code + "\n"
|
163
163
|
end
|
164
164
|
states_code + "\n"
|
165
165
|
end
|
166
166
|
|
167
|
+
def generate_attributes_code
|
168
|
+
attributes_code = ""
|
169
|
+
|
170
|
+
|
171
|
+
attributes_code = <<-INIT
|
172
|
+
## Attributes
|
173
|
+
event_attributes = {}
|
174
|
+
INIT
|
175
|
+
|
176
|
+
events = @chart.get_blocks_of_type "event"
|
177
|
+
events.each do |event|
|
178
|
+
if event.has_links?
|
179
|
+
|
180
|
+
attributes = event.links_from_type("attribute").map do |attr|
|
181
|
+
attr.text
|
182
|
+
end
|
183
|
+
unless attributes.empty?
|
184
|
+
|
185
|
+
c = <<-START
|
186
|
+
attributes["#{event.text}"] = #{attributes.to_s}
|
187
|
+
START
|
188
|
+
|
189
|
+
attributes_code = attributes_code + c
|
190
|
+
# attributes_code = attributes_code +
|
167
191
|
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
end
|
196
|
+
attributes_code + "\n
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
|
168
201
|
|
169
202
|
def generate_events_code
|
170
203
|
|
@@ -369,8 +402,9 @@ START
|
|
369
402
|
finish = <<-END
|
370
403
|
end
|
371
404
|
END
|
372
|
-
return
|
373
|
-
|
405
|
+
return generate_attributes_code +
|
406
|
+
start + generate_state_code +
|
407
|
+
generate_events_code + finish
|
374
408
|
# generate_methods_placeholder
|
375
409
|
end
|
376
410
|
end
|
data/lib/lucidMachines/cli.rb
CHANGED
@@ -2,18 +2,21 @@ require 'thor'
|
|
2
2
|
require 'ruby-graphviz'
|
3
3
|
|
4
4
|
module LucidMachines
|
5
|
-
class CLI < Thor
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
|
7
|
+
class CLI < Thor
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
desc "convert FILE.CSV 'Name'", "Convert a CSV file"
|
10
|
+
def convert(csv_file, sheet = "")
|
12
11
|
chart = ChartLoader.new(csv_file).chart
|
13
|
-
# export_all chart
|
14
|
-
export(chart, sheet)
|
15
|
-
end
|
16
12
|
|
13
|
+
if(sheet == "")
|
14
|
+
export_all chart
|
15
|
+
else
|
16
|
+
export(chart, sheet)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
17
20
|
desc "check FILE.CSV 'sheet name' FILE.RB ClassName", "Check the methods to implement given a know class"
|
18
21
|
def update(csv_file, sheet, file, class_name)
|
19
22
|
|
@@ -29,15 +32,15 @@ module LucidMachines
|
|
29
32
|
puts c.class.to_s
|
30
33
|
@ae = AASMExport.new(subchart); nil ;
|
31
34
|
c.class_eval @ae.export
|
32
|
-
# puts @ae.generate_methods_placeholder_for(c).to_s
|
35
|
+
# puts @ae.generate_methods_placeholder_for(c).to_s
|
33
36
|
open("#{file}-updated.rb", 'w') do |f|
|
34
|
-
# f << @ae.export
|
37
|
+
# f << @ae.export
|
35
38
|
f << @ae.generate_methods_placeholder_for(c)
|
36
39
|
end
|
37
40
|
|
38
41
|
end
|
39
42
|
|
40
|
-
desc "list", "List the sheets in a CSV."
|
43
|
+
desc "list FILE.CSV'", "List the sheets in a CSV."
|
41
44
|
def list(csv_file)
|
42
45
|
|
43
46
|
chart = ChartLoader.new(csv_file).chart
|
@@ -47,5 +50,3 @@ module LucidMachines
|
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
50
|
-
|
51
|
-
|
@@ -1,10 +1,3 @@
|
|
1
|
-
class JobTest
|
2
|
-
include AASM
|
3
|
-
def tie_shoes
|
4
|
-
puts "Tying the shoes ..."
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
1
|
def export_all(chart)
|
9
2
|
chart.pages.each_value do |p|
|
10
3
|
export(chart, p.name)
|
@@ -26,14 +19,5 @@ def export(chart, page_name)
|
|
26
19
|
f << page_aasm_export.export
|
27
20
|
f << page_aasm_export.generate_methods_placeholder
|
28
21
|
end
|
29
|
-
|
30
|
-
# export GraphViz 2 (through aasm-diagram)
|
31
|
-
|
32
|
-
## Extend the JobTest class
|
33
|
-
# JobTest.class_eval page_aasm_export.export
|
34
|
-
# page_aasm_export.generate_methods_placeholder_for(JobTest)
|
35
|
-
# @j = JobTest.new
|
36
|
-
# AASMDiagram::Diagram.new(@j.aasm, "export/chart-#{page_name}-2.png")
|
37
|
-
|
38
22
|
end
|
39
23
|
|
data/lib/lucidMachines/loader.rb
CHANGED
data/lib/lucidMachines.rb
CHANGED
@@ -8,9 +8,9 @@ module LucidMachines
|
|
8
8
|
require 'lucidMachines/elements'
|
9
9
|
require 'lucidMachines/chart'
|
10
10
|
require 'lucidMachines/loader'
|
11
|
-
|
11
|
+
|
12
|
+
require 'lucidMachines/helper'
|
12
13
|
require 'lucidMachines/aasm_export'
|
13
|
-
require 'lucidMachines/exporter'
|
14
14
|
require 'lucidMachines/graphviz_export'
|
15
15
|
|
16
16
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Laviole
|
@@ -130,8 +130,8 @@ files:
|
|
130
130
|
- lib/lucidMachines/chart.rb
|
131
131
|
- lib/lucidMachines/cli.rb
|
132
132
|
- lib/lucidMachines/elements.rb
|
133
|
-
- lib/lucidMachines/exporter.rb
|
134
133
|
- lib/lucidMachines/graphviz_export.rb
|
134
|
+
- lib/lucidMachines/helper.rb
|
135
135
|
- lib/lucidMachines/loader.rb
|
136
136
|
- lib/lucidMachines/version.rb
|
137
137
|
- loader.rb
|