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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/gv_fsm +24 -5
  3. data/lib/gv_fsm.rb +4 -4
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d793e3f46c8098f7fd5a5e9cdac035fc19ab6fb744886775dbc1e7a7757398c
4
- data.tar.gz: bc16702d154fddd02a2c774b0f651ada1ece6e1e76cc9845e64dfbbb3811aba9
3
+ metadata.gz: 37d68711f43acf07c3071b793721cf34301e3b16dd01dbaeeae5083346337e98
4
+ data.tar.gz: d47b62e5dcc5f7feafecc2e27744e94e2a96c8ed81ffe6f9425545558e8802d6
5
5
  SHA512:
6
- metadata.gz: d06e75af4f4d1c3d1ebf2d80293d60cceae9a75859ddeaef11e44b02bab4829b248071805174d15f5818767f3ee04164ac573174cb39a76db55d196cf649ba11
7
- data.tar.gz: bea055285d64501305796e2fb0d49d9a5e915f52facc45224c7eace99d801ebd5f4cc7b4a39e88587b262f779c250dac651beb7235826d2fb445aaca03cf2b3a
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
- SM = GV_FSM::FSM.new(ARGV[0])
6
- SM.project_name = "test project"
7
- SM.description = "FSM designed to test the generator"
6
+ sm = GV_FSM::FSM.new
8
7
 
9
- SM.generate_h
10
- SM.generate_c
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
 
@@ -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
- raise ArgumentError, "File must be in .dot format" unless File.extname(filename) == ".dot"
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 = []
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gv_fsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paolo Bosetti