gv_fsm 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/gv_fsm +24 -5
- data/lib/gv_fsm.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37d68711f43acf07c3071b793721cf34301e3b16dd01dbaeeae5083346337e98
|
4
|
+
data.tar.gz: d47b62e5dcc5f7feafecc2e27744e94e2a96c8ed81ffe6f9425545558e8802d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06b70b565f5e2aacea2840528cbc7da9150f7bba5d680502d1e8103986f8b9f9162bde162ee217fa9f0a6c8d8ee635a1c41db068f5b5df198200e414af01b0cb
|
7
|
+
data.tar.gz: fc11849dda745e5e0fc3d3ade2356c1ec6d201e50c9093db98f2d01878e2c7b3e0f1871762811d590ad62b34d5307527f983e896d3aa10de4e36ee43796b0fb0
|
data/bin/gv_fsm
CHANGED
@@ -1,11 +1,30 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "gv_fsm"
|
4
|
+
require 'optparse'
|
4
5
|
|
5
|
-
|
6
|
-
SM.project_name = "test project"
|
7
|
-
SM.description = "FSM designed to test the generator"
|
6
|
+
sm = GV_FSM::FSM.new
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
options = {}
|
9
|
+
OptionParser.new do |parser|
|
10
|
+
parser.on("-p", "--project PROJECT_NAME",
|
11
|
+
"Set the project name to PROJECT_NAME") do |pn|
|
12
|
+
sm.project_name = pn
|
13
|
+
end
|
14
|
+
|
15
|
+
parser.on("-d", "--description DESCRIPTION", "Use DESCRITION string in header") do |desc|
|
16
|
+
sm.description = desc
|
17
|
+
end
|
18
|
+
|
19
|
+
parser.on("-o", "--output_file NAME", "Use NAME for generated .c and .h files") do |f|
|
20
|
+
sm.cname = f
|
21
|
+
end
|
22
|
+
end.parse!
|
23
|
+
|
24
|
+
raise ArgumentError, "I need the path to a Graphviz file!" unless ARGV[0]
|
25
|
+
raise ArgumentError, "#{ARGV[0]} does not look like a Graphviz file!" unless File.extname(ARGV[0]) == ".dot"
|
26
|
+
|
27
|
+
sm.parse(ARGV[0])
|
28
|
+
sm.generate_h
|
29
|
+
sm.generate_c
|
11
30
|
|
data/lib/gv_fsm.rb
CHANGED
@@ -12,13 +12,13 @@ module GV_FSM
|
|
12
12
|
attr_accessor :project_name, :description, :cname
|
13
13
|
include GV_FSM::Templates
|
14
14
|
|
15
|
-
def initialize(filename)
|
16
|
-
|
17
|
-
@cname = File.basename(filename, ".dot")
|
18
|
-
parse(filename)
|
15
|
+
def initialize(filename = nil)
|
16
|
+
parse(filename) if filename
|
19
17
|
end
|
20
18
|
|
21
19
|
def parse(filename)
|
20
|
+
raise ArgumentError, "File must be in .dot format" unless File.extname(filename) == ".dot"
|
21
|
+
@cname = File.basename(filename, ".dot") unless (@cname and ! @cname.empty?)
|
22
22
|
@dotfile = filename
|
23
23
|
@states = []
|
24
24
|
@transitions = []
|