mikado_graph_generator 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +13 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +35 -0
- data/LICENSE.txt +21 -0
- data/README.md +72 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/img/multi_level_mikado_graph.png +0 -0
- data/lib/mikado_graph.rb +8 -0
- data/lib/mikado_graph/dependencies.rb +15 -0
- data/lib/mikado_graph/generator.rb +44 -0
- data/lib/mikado_graph/state.rb +23 -0
- data/lib/mikado_graph/version.rb +3 -0
- data/mikado_graph.gemspec +25 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9d40123be1c0da8c638c131cbf9950308e0d5e65
|
4
|
+
data.tar.gz: 2868134bffaa3ac330a39fc874276a5498236d38
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: af89d6afa1fc13b87c5fdc2dbc105467c905d8941a8668011482f4e9b0b65a4a8c9fc0430a2cece900662ea178cc6c7097165ccf577ffb2c115b208c8896cf5a
|
7
|
+
data.tar.gz: d8c6e2b6a8840bd531bab60bb806642b070082a7bc0af910e52180770cc7f6146bf358f8926c9bfd8c7e22ed3181765ff6463856cb12d3c75ed0cbd1a6445624
|
data/.editorconfig
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mikado_graph_generator (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rake (10.5.0)
|
11
|
+
rspec (3.5.0)
|
12
|
+
rspec-core (~> 3.5.0)
|
13
|
+
rspec-expectations (~> 3.5.0)
|
14
|
+
rspec-mocks (~> 3.5.0)
|
15
|
+
rspec-core (3.5.4)
|
16
|
+
rspec-support (~> 3.5.0)
|
17
|
+
rspec-expectations (3.5.0)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.5.0)
|
20
|
+
rspec-mocks (3.5.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.5.0)
|
23
|
+
rspec-support (3.5.0)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (~> 1.14)
|
30
|
+
mikado_graph_generator!
|
31
|
+
rake (~> 10.0)
|
32
|
+
rspec (~> 3.0)
|
33
|
+
|
34
|
+
BUNDLED WITH
|
35
|
+
1.14.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Shahriyar Nasir
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Mikado Graph Generator
|
2
|
+
|
3
|
+
Welcome to a DSL for creating Mikado Graphs using *GraphViz*.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem "mikado_graph"
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install mikado_graph
|
20
|
+
|
21
|
+
### Prerequisites
|
22
|
+
|
23
|
+
Ensure you have *GraphViz* installed. On macOS you can install it using Homebrew with the following command:
|
24
|
+
|
25
|
+
```bash
|
26
|
+
brew install graphviz
|
27
|
+
```
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
You can use this gem's DSL in the following way to create a Mikado Graph generator definition file:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require "mikado_graph"
|
35
|
+
|
36
|
+
MikadoGraph::Generator.generate do
|
37
|
+
state("State A").depends_on do
|
38
|
+
state("State B").depends_on do
|
39
|
+
state("State D")
|
40
|
+
state("State E")
|
41
|
+
end
|
42
|
+
state("State C").depends_on do
|
43
|
+
state("State F")
|
44
|
+
state("State G")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
You can then execute this file in the terminal using:
|
51
|
+
|
52
|
+
```bash
|
53
|
+
ruby multi_level_mikado_graph_generator.rb | dot -Tpng -o img/multi_level_mikado_graph.png
|
54
|
+
```
|
55
|
+
|
56
|
+
This will utilize the *GraphViz* `dot` command to create this PNG output of the above Mikado Graph generator definition:
|
57
|
+
|
58
|
+
![Multi-Level Mikado Graph](https://github.com/snasirca/mikado_graph_generator/blob/master/img/multi_level_mikado_graph.png)
|
59
|
+
|
60
|
+
## Development
|
61
|
+
|
62
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
63
|
+
|
64
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
65
|
+
|
66
|
+
## Contributing
|
67
|
+
|
68
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/snasirca/mikado_graph_generator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
69
|
+
|
70
|
+
## License
|
71
|
+
|
72
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "mikado_graph"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
Binary file
|
data/lib/mikado_graph.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module MikadoGraph
|
2
|
+
class Dependencies
|
3
|
+
attr_reader :dependent_states
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@dependent_states = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def state(state_name)
|
10
|
+
new_state = State.new(state_name)
|
11
|
+
dependent_states << new_state
|
12
|
+
new_state
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module MikadoGraph
|
2
|
+
module Generator
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def generate(&block)
|
6
|
+
dependencies = Dependencies.new
|
7
|
+
dependencies.instance_eval(&block)
|
8
|
+
convert(dependencies.dependent_states)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def convert(states)
|
14
|
+
convert_header
|
15
|
+
convert_states_and_dependencies(states)
|
16
|
+
convert_footer
|
17
|
+
end
|
18
|
+
|
19
|
+
def convert_header
|
20
|
+
puts "digraph {"
|
21
|
+
puts " node [shape=box];"
|
22
|
+
puts " rankdir=\"LR\";"
|
23
|
+
end
|
24
|
+
|
25
|
+
def convert_states_and_dependencies(states)
|
26
|
+
states.each { |state| convert_dependencies(state) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def convert_dependencies(state)
|
30
|
+
state.dependent_states.each do |dependent_state|
|
31
|
+
convert_dependency(state, dependent_state)
|
32
|
+
convert_dependencies(dependent_state)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def convert_dependency(state, dependent_state)
|
37
|
+
puts " \"#{dependent_state.name}\" -> \"#{state.name}\";"
|
38
|
+
end
|
39
|
+
|
40
|
+
def convert_footer
|
41
|
+
puts "}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module MikadoGraph
|
2
|
+
class State
|
3
|
+
attr_reader :name
|
4
|
+
|
5
|
+
def initialize(name)
|
6
|
+
@name = name
|
7
|
+
end
|
8
|
+
|
9
|
+
def depends_on(&block)
|
10
|
+
dependencies = Dependencies.new
|
11
|
+
dependencies.instance_eval(&block)
|
12
|
+
@dependent_states = dependencies.dependent_states
|
13
|
+
end
|
14
|
+
|
15
|
+
def dependent_states
|
16
|
+
@dependent_states || []
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
name
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "mikado_graph/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mikado_graph_generator"
|
8
|
+
spec.version = MikadoGraph::VERSION
|
9
|
+
spec.authors = ["Shahriyar Nasir"]
|
10
|
+
spec.email = ["contact@snasir.ca"]
|
11
|
+
|
12
|
+
spec.summary = "Mikado Graph generator"
|
13
|
+
spec.description = "Provides a simple DSL for generating Mikado Graphs using GraphViz."
|
14
|
+
spec.homepage = "https://github.com/snasirca/mikado_graph_generator"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mikado_graph_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shahriyar Nasir
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Provides a simple DSL for generating Mikado Graphs using GraphViz.
|
56
|
+
email:
|
57
|
+
- contact@snasir.ca
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".editorconfig"
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- Gemfile.lock
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- bin/console
|
72
|
+
- bin/setup
|
73
|
+
- img/multi_level_mikado_graph.png
|
74
|
+
- lib/mikado_graph.rb
|
75
|
+
- lib/mikado_graph/dependencies.rb
|
76
|
+
- lib/mikado_graph/generator.rb
|
77
|
+
- lib/mikado_graph/state.rb
|
78
|
+
- lib/mikado_graph/version.rb
|
79
|
+
- mikado_graph.gemspec
|
80
|
+
homepage: https://github.com/snasirca/mikado_graph_generator
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.6.10
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: Mikado Graph generator
|
104
|
+
test_files: []
|