state_machines-graphviz 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b375be8fce2b404843e60ffc947edb7d7b37a5e4
4
- data.tar.gz: e46a7734205fd1ff0946dacb72195e82e1863d5a
3
+ metadata.gz: 7816ed9a804fa1c1d96d1bb33ee7c06b8f46b6cc
4
+ data.tar.gz: 9732fe05fdafb7b65cc69da7e9c9824a9d831262
5
5
  SHA512:
6
- metadata.gz: db7731a6a0236d51ca0a888870ab4f0bf1670ade1832051b2e84bd7220290b8ac5b86d473c089608aeb667388c70665fb9f2acf10cc89d59ee57d7f76fe59965
7
- data.tar.gz: 854bb07b3eff8a50165b6bbc7012e2304259711d768238d5a0fbf88f02898f6e5a9730f36971a5c5d6f810cc87d30a649e9bfbf33a62230e1ff1ef99c7eda6c8
6
+ metadata.gz: 9e2a02602e0ac22e1890d944ea9e4f24cd69cd7d6b428ad145fd01f359f4c893b4090a9af03da1d1635c288b28a13a29592d1983c7816dc6f9d3d83014edb981
7
+ data.tar.gz: dbbbdf235db77bca214d0a5f21297da629d9d1868f86590d0c1173f4d304ab0258e4acdbc277035bce5a3813e50b92574104cbff94563ff58e18702b3107b344
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ .idea
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
  install: sudo apt-get install graphviz -y
3
- before_install: gem install bundler
3
+ before_install:
4
+ - gem install bundler
5
+ - bundle install
4
6
  script: bundle exec rake
5
7
  rvm:
6
8
  - 1.9.3
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in state_machine2-graphviz.gemspec
4
- gemspec
4
+ gemspec
data/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # StateMachines::Graphviz
2
2
 
3
- TODO: Write a gem description
3
+ This adds support for generating di-graphs based on the
4
+ events, states, and transitions defined for a state machine using [GraphViz](http://www.graphviz.org).
4
5
 
5
6
  ## Installation
6
7
 
7
8
  Add this line to your application's Gemfile:
8
9
 
9
- gem 'state_machine2-graphviz' , group: :development
10
+ gem 'state_machines-graphviz' , group: :development
10
11
 
11
12
  And then execute:
12
13
 
@@ -14,15 +15,68 @@ And then execute:
14
15
 
15
16
  Or install it yourself as:
16
17
 
17
- $ gem install state_machine2-graphviz
18
+ $ gem install state_machines-graphviz
18
19
 
19
20
  ## Usage
20
21
 
21
- TODO: Write usage instructions here
22
+ #### Examples
23
+
24
+ To generate a graph for a specific file / class:
25
+
26
+ ```bash
27
+ rake state_machines:draw FILE=vehicle.rb CLASS=Vehicle
28
+ ```
29
+ From a Rails app directory:
30
+
31
+ ```bash
32
+ rake state_machines:draw CLASS=Vehicle
33
+ ```
34
+
35
+ To save files to a specific path:
36
+
37
+ ```bash
38
+ rake state_machines:draw FILE=vehicle.rb CLASS=Vehicle TARGET=files
39
+ ```
40
+
41
+ To customize the image format / orientation:
42
+
43
+ ```bash
44
+ rake state_machines:draw FILE=vehicle.rb CLASS=Vehicle FORMAT=jpg ORIENTATION=landscape
45
+ ```
46
+
47
+ See http://rdoc.info/github/glejeune/Ruby-Graphviz/GraphViz/Constants for the list of
48
+ supported image formats. If resolution is an issue, the svg format may offer
49
+ better results.
50
+
51
+ To generate multiple state machine graphs:
52
+
53
+ ```bash
54
+ rake state_machines:draw FILE=vehicle.rb,car.rb CLASS=Vehicle,Car
55
+ ```
56
+
57
+ To use human state / event names:
58
+
59
+ ```bash
60
+ rake state_machines:draw FILE=vehicle.rb CLASS=Vehicle HUMAN_NAMES=true
61
+ ```
62
+
63
+ **Note** that this will generate a different file for every state machine defined
64
+ in the class. The generated files will use an output filename of the format
65
+ `#{class_name}_#{machine_name}.#{format}`.
66
+
67
+ For examples of actual images generated using this task, see those under the
68
+ examples folder.
69
+
70
+ ### Interactive graphs
71
+
72
+ Jean Bovet's [Visual Automata Simulator](http://www.cs.usfca.edu/~jbovet/vas.html)
73
+ is a great tool for "simulating, visualizing and transforming finite state
74
+ automata and Turing Machines". It can help in the creation of states and events
75
+ for your models. It is cross-platform, written in Java.
22
76
 
23
77
  ## Contributing
24
78
 
25
- 1. Fork it ( https://github.com/seuros/state_machine2-graphviz/fork )
79
+ 1. Fork it ( https://github.com/seuros/state_machines-graphviz/fork )
26
80
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
81
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
82
  4. Push to the branch (`git push origin my-new-feature`)
data/Rakefile CHANGED
@@ -1,5 +1,4 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
1
+ require 'bundler/gem_tasks'
3
2
 
4
3
  require 'rspec/core/rake_task'
5
4
  RSpec::Core::RakeTask.new do |t|
@@ -7,4 +6,8 @@ RSpec::Core::RakeTask.new do |t|
7
6
  end
8
7
 
9
8
  desc 'Default: run all tests.'
10
- task :default => :spec
9
+ task :default => :spec
10
+ task :test => :spec
11
+
12
+
13
+ load File.dirname(__FILE__) + '/lib/state_machines/tasks/state_machines.rake'
@@ -0,0 +1 @@
1
+ require 'state_machines/graphviz'
@@ -3,3 +3,5 @@ require 'graphviz'
3
3
  require 'state_machines/graphviz/monkeypatch'
4
4
  require 'state_machines/graphviz/graph'
5
5
  require 'state_machines/graphviz/version'
6
+
7
+ require 'state_machines/tasks/railtie' if defined?(Rails)
@@ -1,6 +1,6 @@
1
1
  module StateMachines
2
2
  # Gem version
3
3
  module Graphviz
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
6
6
  end
@@ -0,0 +1,10 @@
1
+ require 'state_machines/graphviz'
2
+ require 'rails'
3
+ module StateMachines
4
+ # https://gist.github.com/josevalim/af7e572c2dc973add221
5
+ class Railtie < Rails::Railtie
6
+ rake_tasks do
7
+ load 'state_machines/tasks/state_machines.rake'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ require 'state_machines/graphviz'
2
+
3
+ require File.join("#{File.dirname(__FILE__)}/state_machines")
@@ -0,0 +1,32 @@
1
+ # Test with:
2
+ # rake state_machines:draw FILE=./spec/files/switch.rb CLASS=Switch
3
+ namespace :state_machines do
4
+ desc 'Draws state machines using GraphViz (options: CLASS=User,Vehicle; FILE=user.rb,vehicle.rb [not required in Rails / Merb]; FONT=Arial; FORMAT=png; ORIENTATION=portrait; HUMAN_NAMES=true'
5
+ task :draw do
6
+ # Build drawing options
7
+ options = {}
8
+ options[:file] = ENV['FILE'] if ENV['FILE']
9
+ options[:path] = ENV['TARGET'] if ENV['TARGET']
10
+ options[:format] = ENV['FORMAT'] if ENV['FORMAT']
11
+ options[:font] = ENV['FONT'] if ENV['FONT']
12
+ options[:orientation] = ENV['ORIENTATION'] if ENV['ORIENTATION']
13
+ options[:human_names] = ENV['HUMAN_NAMES'] == 'true' if ENV['HUMAN_NAMES']
14
+
15
+ if defined?(Rails)
16
+ puts "Files are automatically loaded in Rails; ignoring FILE option" if options.delete(:file)
17
+ Rake::Task['environment'].invoke
18
+ elsif defined?(Merb)
19
+ puts "Files are automatically loaded in Merb; ignoring FILE option" if options.delete(:file)
20
+ Rake::Task['merb_env'].invoke
21
+
22
+ # Fix ruby-graphviz being incompatible with Merb's process title
23
+ $0 = 'rake'
24
+ else
25
+ # Load the library
26
+ $:.unshift(File.dirname(__FILE__) + '/..')
27
+ require 'state_machines'
28
+ end
29
+
30
+ StateMachines::Machine.draw(ENV['CLASS'], options)
31
+ end
32
+ end
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = StateMachines::Graphviz::VERSION
9
9
  spec.authors = ['Abdelkader Boudih', 'Aaron Pfeifer']
10
10
  spec.email = ['terminale@gmail.com']
11
- spec.summary = %q(Drawing module for state machine2)
12
- spec.description = %q(Graphviz module for state machine2)
11
+ spec.summary = %q(Drawing module for state machines)
12
+ spec.description = %q(Graphviz module for state machines)
13
13
  spec.homepage = 'https://github.com/seuros/state_machines-graphviz'
14
14
  spec.license = 'MIT'
15
15
 
@@ -21,5 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency 'ruby-graphviz'
22
22
  spec.add_development_dependency 'bundler'
23
23
  spec.add_development_dependency 'rake'
24
- spec.add_development_dependency 'rspec' , '3.0.0.beta2'
24
+ spec.add_development_dependency 'rspec' , '>=3.0.0'
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state_machines-graphviz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-27 00:00:00.000000000 Z
12
+ date: 2015-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: state_machines
@@ -71,17 +71,17 @@ dependencies:
71
71
  name: rspec
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
- version: 3.0.0.beta2
76
+ version: 3.0.0
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - '='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: 3.0.0.beta2
84
- description: Graphviz module for state machine2
83
+ version: 3.0.0
84
+ description: Graphviz module for state machines
85
85
  email:
86
86
  - terminale@gmail.com
87
87
  executables: []
@@ -90,15 +90,19 @@ extra_rdoc_files: []
90
90
  files:
91
91
  - ".gitignore"
92
92
  - ".rspec"
93
- - ".travis.yaml"
93
+ - ".travis.yml"
94
94
  - Gemfile
95
95
  - LICENSE.txt
96
96
  - README.md
97
97
  - Rakefile
98
+ - lib/state_machines-graphviz.rb
98
99
  - lib/state_machines/graphviz.rb
99
100
  - lib/state_machines/graphviz/graph.rb
100
101
  - lib/state_machines/graphviz/monkeypatch.rb
101
102
  - lib/state_machines/graphviz/version.rb
103
+ - lib/state_machines/tasks/railtie.rb
104
+ - lib/state_machines/tasks/state_machines.rake
105
+ - lib/state_machines/tasks/state_machines.rb
102
106
  - spec/files/switch.rb
103
107
  - spec/graph_spec.rb
104
108
  - spec/machine_drawing_spec.rb
@@ -126,9 +130,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
130
  version: '0'
127
131
  requirements: []
128
132
  rubyforge_project:
129
- rubygems_version: 2.2.2
133
+ rubygems_version: 2.4.5
130
134
  signing_key:
131
135
  specification_version: 4
132
- summary: Drawing module for state machine2
136
+ summary: Drawing module for state machines
133
137
  test_files: []
134
- has_rdoc: