simple-hd-graph 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c9b0d3ded87feb7413df4ddeba6059e109be00644737ded9a4e814f8e9a1e67
4
- data.tar.gz: 9c677cc4cd05e216464afe2b3c04ba8b321a595dedb5932292bfd5ec4dbd7c90
3
+ metadata.gz: 4c98a6c57f3e6e31d829c886f1354d0483f449a1cd683865df9e68574f2472d6
4
+ data.tar.gz: a961f75432eb08c7a72507a06eb7e10c6a498f2911910b4c174fb6f8c2938207
5
5
  SHA512:
6
- metadata.gz: 99df519c7c3e8927c09ed17e6b6a8dd9d0533cd7885ff59592d2da9f614ea2c2bff15d4473095f108b19bd1b045b07de3013d2a3a94b1025af878280bce6d159
7
- data.tar.gz: 81d0c1f6c5359f88cca05d4f3beaeb6c55ce73a19cbd966c3a8086fc8553e690b77a8ad96af359a186940958b2733f187067f8df58351cb631db2738bc3f314b
6
+ metadata.gz: 8e621ce8f0f2680a5ecac741e56ec96180bc7899fd4ec2156fd9725a3f38d5377350aa27356728d59aaf4f09909c2b109b19528fbe572aa696b671b4de0ea13b
7
+ data.tar.gz: 73132da6fd3a16f0353dac3c55108e81157c4d052cddb3117c44ea40ab3e4b07d3ce6fdfb0042ce6f17f6f24dbc729434d7725ad6680a286473ae61b02911565
@@ -9,12 +9,12 @@ module SimpleHdGraph
9
9
  #
10
10
  # @param parser [Parser]
11
11
  # @param reader [Reader]
12
- # @param renderer [Renderer]
12
+ # @param renderer [Symbol]
13
13
  #
14
- def initialize(parser: Parser.new, reader: Reader.new, renderer: Renderer::PlantUML::Context.new)
14
+ def initialize(parser: Parser.new, reader: Reader.new, renderer: :plantuml)
15
15
  @parser = parser
16
16
  @reader = reader
17
- @renderer = renderer
17
+ @renderer = SimpleHdGraph::Renderer.method(renderer.to_s)
18
18
  end
19
19
  attr_reader :parser, :reader, :renderer
20
20
 
@@ -49,9 +49,7 @@ module SimpleHdGraph
49
49
  def start
50
50
  nodes = parser.parse(stream)
51
51
 
52
- puts nodes.map { |node|
53
- renderer.render(node)
54
- }.join
52
+ @renderer.call(nodes)
55
53
  end
56
54
 
57
55
  #
@@ -74,6 +72,13 @@ module SimpleHdGraph
74
72
  raise FileNotExist, value
75
73
  end
76
74
  }
75
+ opt.on('-r RENDERER', '--renderer', 'renderer') { |value|
76
+ begin
77
+ @renderer = SimpleHdGraph::Renderer.method(value)
78
+ rescue NameError
79
+ STDERR.puts "[Warining] renderer `#{value}` not found. falling back to :plantuml"
80
+ end
81
+ }
77
82
  end
78
83
  end
79
84
  end
@@ -0,0 +1,16 @@
1
+ Dir.glob(File.join(__dir__, '**/*.rb')).each { |f| require f }
2
+
3
+ module SimpleHdGraph
4
+ module Renderer
5
+ #
6
+ # @param nodes [Array]
7
+ #
8
+ def plantuml(nodes)
9
+ context = self::PlantUML::Context.new
10
+ puts nodes.map { |node|
11
+ context.render(node)
12
+ }.join
13
+ end
14
+ module_function :plantuml
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module SimpleHdGraph
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-hd-graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - wtnabe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-17 00:00:00.000000000 Z
11
+ date: 2021-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-inflector
@@ -134,6 +134,7 @@ files:
134
134
  - lib/simple-hd-graph/node.rb
135
135
  - lib/simple-hd-graph/parser.rb
136
136
  - lib/simple-hd-graph/reader.rb
137
+ - lib/simple-hd-graph/renderer/plantuml.rb
137
138
  - lib/simple-hd-graph/renderer/plantuml/context.rb
138
139
  - lib/simple-hd-graph/renderer/plantuml/resource.rb
139
140
  - lib/simple-hd-graph/resource.rb