mikado_graph_generator 0.2.2 → 0.3.0
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/.envrc +3 -0
- data/.envrc.sample +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +34 -5
- data/example_usage_horizontal.rb +14 -0
- data/{example_usage.rb → example_usage_vertical.rb} +1 -1
- data/lib/mikado_graph/generator.rb +14 -4
- data/lib/mikado_graph/version.rb +1 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3c75276f5053c1f45d6fd5e88ff3a0c276eaae1
|
4
|
+
data.tar.gz: dbea48efaa1e281a7909bf990f9c6fb5a7f81160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb5d06068c26ef4a6cbf7ac97f471c8f642046bc6159c55df1c77a61b42481eea02e124b43403ad0f8fd9ec9c5f02ea6887b2fab2e3369caa0fe0f58554b9b10
|
7
|
+
data.tar.gz: 36f1d8b650b48d2aa28fd57ff35d01477bcee22a6303a0ab6956c0350e7580faaa797f9e32f1a950b7bdf88696bd19c9e7d9813bd18076fb80ef75db71705bd4
|
data/.envrc
ADDED
data/.envrc.sample
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -44,21 +44,50 @@ MikadoGraph::Generator.define do
|
|
44
44
|
state("State G")
|
45
45
|
end
|
46
46
|
end
|
47
|
-
end.generate("png", "img/
|
47
|
+
end.generate("png", "img/example_usage_vertical.png") # generate takes GraphViz format and output path
|
48
48
|
```
|
49
49
|
|
50
|
-
Save this file to `
|
50
|
+
Save this file to `example_usage_vertical.rb` and then you can then execute this file in the terminal using:
|
51
51
|
|
52
52
|
```bash
|
53
|
-
ruby
|
53
|
+
ruby example_usage_vertical.rb
|
54
54
|
```
|
55
55
|
|
56
|
-
This will utilize
|
56
|
+
This will utilize *GraphViz* to create this PNG output of the above Mikado Graph generator definition:
|
57
57
|
|
58
|
-

|
59
59
|
|
60
60
|
NOTE: If you don't provide any parameters to `generate`, it'll default to a `dot` output in the STDOUT.
|
61
61
|
|
62
|
+
If you want to instead do a horizontal orientation of your graph, simply provide the direction flag to `#generate` like so:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
generate(direction: :horizontal)
|
66
|
+
```
|
67
|
+
|
68
|
+
Here is an example usage:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
require "mikado_graph"
|
72
|
+
|
73
|
+
MikadoGraph::Generator.define do
|
74
|
+
state("State A").depends_on do
|
75
|
+
state("State B").depends_on do
|
76
|
+
state("State D")
|
77
|
+
state("State E")
|
78
|
+
end
|
79
|
+
state("State C").depends_on do
|
80
|
+
state("State F")
|
81
|
+
state("State G")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end.generate(format: "png", path: "img/example_usage_horizontal.png", direction: :horizontal)
|
85
|
+
```
|
86
|
+
|
87
|
+
This will generate this graph:
|
88
|
+
|
89
|
+

|
90
|
+
|
62
91
|
## Development
|
63
92
|
|
64
93
|
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.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "mikado_graph"
|
2
|
+
|
3
|
+
MikadoGraph::Generator.define do
|
4
|
+
state("State A").depends_on do
|
5
|
+
state("State B").depends_on do
|
6
|
+
state("State D")
|
7
|
+
state("State E")
|
8
|
+
end
|
9
|
+
state("State C").depends_on do
|
10
|
+
state("State F")
|
11
|
+
state("State G")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end.generate(format: "png", path: "img/example_usage_horizontal.png", direction: :horizontal)
|
@@ -10,10 +10,10 @@ module MikadoGraph
|
|
10
10
|
generator_instance
|
11
11
|
end
|
12
12
|
|
13
|
-
def generate(
|
13
|
+
def generate(options = {})
|
14
14
|
add_states_to_graph(dependencies.dependent_states)
|
15
|
-
|
16
|
-
output_options
|
15
|
+
arrange_graph_direction(options)
|
16
|
+
output_options = build_output_options(options)
|
17
17
|
graph.output(output_options)
|
18
18
|
end
|
19
19
|
|
@@ -26,7 +26,6 @@ module MikadoGraph
|
|
26
26
|
|
27
27
|
def initialize_graph
|
28
28
|
@graph = GraphViz.new(nil)
|
29
|
-
@graph[:rankdir] = "LR"
|
30
29
|
@graph.node[:shape] = "box"
|
31
30
|
end
|
32
31
|
|
@@ -46,5 +45,16 @@ module MikadoGraph
|
|
46
45
|
dependent_state_node = graph.add_nodes(dependent_state.name)
|
47
46
|
graph.add_edges(dependent_state_node, state_node)
|
48
47
|
end
|
48
|
+
|
49
|
+
def arrange_graph_direction(options)
|
50
|
+
direction = options.fetch(:direction, :vertical)
|
51
|
+
graph[:rankdir] = "LR" if direction == :horizontal
|
52
|
+
end
|
53
|
+
|
54
|
+
def build_output_options(options)
|
55
|
+
output_options = {}
|
56
|
+
output_options[options.fetch(:format, "dot")] = options.fetch(:path, nil)
|
57
|
+
output_options
|
58
|
+
end
|
49
59
|
end
|
50
60
|
end
|
data/lib/mikado_graph/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mikado_graph_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shahriyar Nasir
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -145,6 +145,8 @@ extra_rdoc_files: []
|
|
145
145
|
files:
|
146
146
|
- ".codeclimate.yml"
|
147
147
|
- ".editorconfig"
|
148
|
+
- ".envrc"
|
149
|
+
- ".envrc.sample"
|
148
150
|
- ".gitignore"
|
149
151
|
- ".rspec"
|
150
152
|
- ".rubocop"
|
@@ -161,8 +163,10 @@ files:
|
|
161
163
|
- Rakefile
|
162
164
|
- bin/console
|
163
165
|
- bin/setup
|
164
|
-
-
|
165
|
-
-
|
166
|
+
- example_usage_horizontal.rb
|
167
|
+
- example_usage_vertical.rb
|
168
|
+
- img/example_usage_horizontal.png
|
169
|
+
- img/example_usage_vertical.png
|
166
170
|
- lib/mikado_graph.rb
|
167
171
|
- lib/mikado_graph/dependencies.rb
|
168
172
|
- lib/mikado_graph/generator.rb
|