graphy 0.1.2 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90422fd37ee6183c87ab531c8841bfea10d9da59385f10f9d440b4095aeb24a8
4
- data.tar.gz: 8bcb771712386cbeb5f9d2fb2e9e76030c9a6a18e79d8550f3bf28610d7d4624
3
+ metadata.gz: 316c611d1ad28902ba2d122aca06b5c270e1e99d5e2b418c302a42886192ec7d
4
+ data.tar.gz: 9f485df10f829bdec801ee928d1f8830f59d8bf3361829aa975e58780214a9a6
5
5
  SHA512:
6
- metadata.gz: 5980d5b6a4c0ef3ef5867a11cf91b8c927431803c8f2d74b6b091b2d789b06fa1715cce4b6b6db927708bafb61c405e47027945388a087fc4e1c35232401d102
7
- data.tar.gz: 3526fbda93e7ad3a960eb4e722024a89d1633414f45eeac5309ca7f8f2d7e223c9a900954d9ef05db4de543e256fc0d437ed33ec9bb3084f0e8daa92a08ac3cd
6
+ metadata.gz: b0e725fe2bc68b7f67c39d3ac47a477e47d53dcf1c244603878b8157c0be43a29df2817c50a6f58df7984f225b38152b5a902c1723c469d66c0e1e83fee93a84
7
+ data.tar.gz: e545bcadd4d032fa367ec25451d44eb53349f5458d5f6aa5a92651c7c78b05c2bb0d569cea0f91eadc48a315c0cb0f7d5ac0cec6f5317018ac8e3b038ebc66a4
data/CHANGELOG.md ADDED
@@ -0,0 +1,64 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.2.0] - Unreleased
9
+
10
+ ### Breaking changes
11
+
12
+ - `orientation: :horizontal` is now the only accepted spelling of the horizontal
13
+ layout option. The misspelled `:horizonal` is gone and has no effect.
14
+ - Edge de-duplication is now scoped to each diagram instead of a process-wide
15
+ singleton. `Graphy::Registry` was removed; building several diagrams in one
16
+ process no longer loses edges between them.
17
+ - Public DSL entry points use keyword arguments
18
+ (`Graphy.define(name, **options)`). Passing an explicit options Hash
19
+ positionally is no longer supported.
20
+ - `Node`, `Entity` and `Dsl` expose readers instead of accessors: `name`,
21
+ `shape` and `diagram` can no longer be reassigned after creation.
22
+ - `Graphy.define` requires a non-blank name, and invalid node input raises
23
+ `Graphy::Error` instead of a bare `RuntimeError`.
24
+
25
+ ### Fixed
26
+
27
+ - `orientation: :horizontal` from the README now renders left-to-right
28
+ (`rankdir=LR`). It was silently ignored because of an internal misspelling.
29
+ - The README module example called a non-existent `attributes` API; the
30
+ documented method is `attrs`.
31
+
32
+ ### Added
33
+
34
+ - Full Minitest suite covering the DSL, `Node`, `Entity`, `Diagram`,
35
+ integration with both README examples, and regression tests for the
36
+ orientation and cross-diagram edge bugs.
37
+ - GitHub Actions CI (Ruby 3.3 / 3.4 / 4.0 / head plus a RuboCop job),
38
+ replacing the defunct Travis CI configuration.
39
+ - RuboCop as a development dependency with a project configuration.
40
+ - `CHANGELOG.md`, plus `changelog_uri`, `bug_tracker_uri` and
41
+ `rubygems_mfa_required` gem metadata.
42
+
43
+ ### Changed
44
+
45
+ - Minimum supported Ruby is 3.3 (`required_ruby_version >= 3.3.0`). Ruby 3.2
46
+ reached end of life in March 2026, and `parallel` 2.x — a RuboCop
47
+ dependency — already requires Ruby >= 3.3.
48
+ - Gem file list is explicit (`Dir[...]`) instead of `git ls-files`, and the
49
+ dead `bindir`/`executables` entries were removed.
50
+ - Development dependencies live in the Gemfile only: `rake ~> 13.0`,
51
+ `minitest ~> 5.27`, `rubocop ~> 1.75`. `Gemfile.lock` is committed so CI
52
+ builds are reproducible.
53
+ - Internal requires use `require_relative`, and every file carries
54
+ `# frozen_string_literal: true`.
55
+
56
+ ### Known issues
57
+
58
+ - `ruby-graphviz` 1.2.5 (last released 2016) mutates string literals, so
59
+ Ruby 3.4+ prints `literal string will be frozen in the future` warnings
60
+ when it builds a graph. `rake test` runs with warnings enabled, so
61
+ `test/test_helper.rb` filters that exact upstream message by gem path;
62
+ warnings from this project's own files are unaffected. If Ruby ever makes
63
+ frozen string literals the default, this dependency will need a patch or a
64
+ replacement — tracked as the main remaining risk for future Ruby releases.
data/README.md CHANGED
@@ -1,7 +1,17 @@
1
1
  # Graphy
2
2
 
3
+ [![CI](https://github.com/3zcurdia/graphy/actions/workflows/ci.yml/badge.svg)](https://github.com/3zcurdia/graphy/actions/workflows/ci.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/graphy.svg)](https://badge.fury.io/rb/graphy)
5
+
3
6
  DSL to create graph diagrams as code
4
7
 
8
+ ## Requirements
9
+
10
+ - Ruby >= 3.3 (the suite runs on 3.3, 3.4 and 4.0)
11
+ - [Graphviz](https://graphviz.org) with `dot` in your `PATH` — only needed to
12
+ render files with `write`. Building a diagram and inspecting its DOT source
13
+ requires nothing else.
14
+
5
15
  ## Installation
6
16
 
7
17
  Add this line to your application's Gemfile:
@@ -27,7 +37,7 @@ Graphy.define 'Life View' do
27
37
  entity 'Friendly'
28
38
  namespace "Animal Kingdom" do
29
39
  entity 'Animal' do
30
- attributes :name
40
+ attrs :name
31
41
  end
32
42
 
33
43
  entity 'Dog', 'Animal' do
@@ -44,13 +54,21 @@ Graphy.define 'Life View' do
44
54
  end
45
55
  ```
46
56
 
47
- ![example02.png](https://github.com/3zcurdia/graphy/blob/master/examples/example02.rb.png)
57
+ ![example02.png](https://github.com/3zcurdia/graphy/blob/main/examples/example02.rb.png)
48
58
 
59
+ Inside an `entity` block, `attrs` **replaces** the attribute list shown in the
60
+ record label, while `meths` **appends** `name()` method entries. An `entity`
61
+ declared with a parent (`entity 'Dog', 'Animal'`) draws the inheritance arrow
62
+ from parent to child; `uses` draws the arrow from the entity towards its
63
+ dependency.
49
64
 
50
65
  ### State machine
51
66
 
67
+ Pass `orientation: :horizontal` to lay the graph out left to right
68
+ (`rankdir=LR`); the default is top to bottom.
69
+
52
70
  ```ruby
53
- Graphy.define 'State machine', orientation: :horizontal do
71
+ Graphy.define 'State machine', orientation: :horizontal do
54
72
  node 'A'
55
73
  node 'B', shape: 'diamond'
56
74
  node 'C'
@@ -65,17 +83,24 @@ Graphy.define 'State machine', orientation: :horizontal do
65
83
  write(png: 'steps.png')
66
84
  end
67
85
  ```
68
- ![example01.png](https://github.com/3zcurdia/graphy/blob/master/examples/example01.rb.png)
86
+ ![example01.png](https://github.com/3zcurdia/graphy/blob/main/examples/example01.rb.png)
69
87
 
70
88
  ## Development
71
89
 
72
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
90
+ After checking out the repo, run `bin/setup` to install dependencies. Then run
91
+ `rake test` to run the suite and `bundle exec rubocop` to lint. You can also
92
+ run `bin/console` for an interactive prompt that will allow you to
93
+ experiment.
94
+
95
+ Rendering tests skip themselves when Graphviz is not installed. Install it
96
+ (`brew install graphviz` on macOS, or your platform's package manager) to run
97
+ the whole suite.
73
98
 
74
99
  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).
75
100
 
76
101
  ## Contributing
77
102
 
78
- Bug reports and pull requests are welcome on GitHub at https://github.com/3zcurdia/graphy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/3zcurdia/graphy/blob/master/CODE_OF_CONDUCT.md).
103
+ Bug reports and pull requests are welcome on GitHub at https://github.com/3zcurdia/graphy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/3zcurdia/graphy/blob/main/CODE_OF_CONDUCT.md).
79
104
 
80
105
 
81
106
  ## License
@@ -84,4 +109,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
84
109
 
85
110
  ## Code of Conduct
86
111
 
87
- Everyone interacting in the Arq project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/3zcurdia/graphy/blob/master/CODE_OF_CONDUCT.md).
112
+ Everyone interacting in the graphy project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/3zcurdia/graphy/blob/main/CODE_OF_CONDUCT.md).
@@ -1,51 +1,47 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Graphy
2
- ## GraphViz wrapper
4
+ # Thin wrapper around a GraphViz graph.
3
5
  class Diagram
4
- attr_accessor :graph, :edges
6
+ attr_reader :graph, :edges
5
7
 
6
8
  GRAPH_ATTRIBUTES = {
7
- ranksep: 0.5,
8
- nodesep: 0.4,
9
- pad: '0.4,0.4',
10
- margin: '0,0',
9
+ ranksep: 0.5,
10
+ nodesep: 0.4,
11
+ pad: '0.4,0.4',
12
+ margin: '0,0',
11
13
  concentrate: true,
12
- labelloc: :t,
13
- fontsize: 14,
14
- fontname: 'Arial BoldMT',
15
- splines: 'spline'
16
- }
14
+ labelloc: :t,
15
+ fontsize: 14,
16
+ fontname: 'Arial BoldMT',
17
+ splines: 'spline'
18
+ }.freeze
17
19
 
18
20
  NODE_ATTRIBUTES = {
19
- shape: "Mrecord",
21
+ shape: 'Mrecord',
20
22
  fontsize: 12,
21
- fontname: "ArialMT",
22
- margin: "0.07,0.05",
23
+ fontname: 'ArialMT',
24
+ margin: '0.07,0.05',
23
25
  penwidth: 1.0
24
- }
26
+ }.freeze
25
27
 
26
28
  EDGE_ATTRIBUTES = {
27
- fontname: "ArialMT",
28
- fontsize: 10,
29
- arrowsize: 0.9,
30
- penwidth: 1.0,
31
- labelangle: 32,
32
- labeldistance: 1.8,
33
- }
34
-
35
- def initialize(name, options = {})
36
- graph_opts = {
37
- parent: options[:parent],
38
- type: options[:parent]&.type
39
- }.compact
40
- @graph = GraphViz.new(name, **graph_opts)
29
+ fontname: 'ArialMT',
30
+ fontsize: 10,
31
+ arrowsize: 0.9,
32
+ penwidth: 1.0,
33
+ labelangle: 32,
34
+ labeldistance: 1.8
35
+ }.freeze
41
36
 
42
- GRAPH_ATTRIBUTES.each { |attribute, value| @graph[attribute] = value }
43
- NODE_ATTRIBUTES.each { |attribute, value| @graph.node[attribute] = value }
44
- EDGE_ATTRIBUTES.each { |attribute, value| @graph.edge[attribute] = value }
37
+ def initialize(name, **options)
38
+ graph_opts = { parent: options[:parent], type: options[:parent]&.type }.compact
39
+ @graph = GraphViz.new(name, **graph_opts)
40
+ @edges = {}
45
41
 
46
- @graph[:rankdir] = options[:orientation] == :horizonal ? :LR : :TB
42
+ apply_default_attributes!
43
+ @graph[:rankdir] = options[:orientation] == :horizontal ? :LR : :TB
47
44
  @graph[:label] = "#{name}\\n\\n"
48
- @edges = []
49
45
  end
50
46
 
51
47
  def get_node(name)
@@ -60,6 +56,8 @@ module Graphy
60
56
  graph.add_nodes(name, options)
61
57
  end
62
58
 
59
+ # NOTE: `options` stays positional here on purpose - it is forwarded
60
+ # verbatim into ruby-graphviz's positional-hash API.
63
61
  def draw_edge(from, to, options)
64
62
  graph.add_edges(from, to, options)
65
63
  end
@@ -68,8 +66,31 @@ module Graphy
68
66
  graph.add_graph(diagram.graph)
69
67
  end
70
68
 
71
- def write(options = {})
69
+ def write(**options)
72
70
  graph.output(options)
73
71
  end
72
+
73
+ # Per-diagram edge bookkeeping (replaces the former process-wide
74
+ # Graphy::Registry singleton). Keys are `Node#to_s` pairs, matching the
75
+ # old registry's semantics but scoped to this diagram.
76
+ def edge_drawn?(source, target)
77
+ edges.key?(edge_key(source, target))
78
+ end
79
+
80
+ def track_edge(source, target)
81
+ edges[edge_key(source, target)] = true
82
+ end
83
+
84
+ private
85
+
86
+ def apply_default_attributes!
87
+ GRAPH_ATTRIBUTES.each { |attribute, value| @graph[attribute] = value }
88
+ NODE_ATTRIBUTES.each { |attribute, value| @graph.node[attribute] = value }
89
+ EDGE_ATTRIBUTES.each { |attribute, value| @graph.edge[attribute] = value }
90
+ end
91
+
92
+ def edge_key(source, target)
93
+ "#{source}->#{target}"
94
+ end
74
95
  end
75
96
  end
data/lib/graphy/dsl.rb CHANGED
@@ -1,41 +1,47 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Graphy
4
+ # The public DSL surface. The block is instance_eval'd against the Dsl.
2
5
  class Dsl
3
- attr_accessor :diagram
6
+ attr_reader :diagram
7
+
8
+ def initialize(name, **, &block)
9
+ raise Error, 'Diagram name is required' if name.nil? || name.to_s.strip.empty?
4
10
 
5
- def initialize(name, options = {}, &block)
6
- @diagram = Diagram.new(name, options, &block)
7
- instance_eval(&block) if block_given?
11
+ @diagram = Diagram.new(name, **)
12
+ instance_eval(&block) if block
8
13
  end
9
14
 
10
- def namespace(name, &block)
11
- diagram.draw_graph(Dsl.new(name, { parent: diagram.graph }, &block).diagram)
15
+ def namespace(name, &)
16
+ diagram.draw_graph(Dsl.new(name, parent: diagram.graph, &).diagram)
12
17
  end
13
18
 
14
- def component(name, &block)
15
- node(name, shape: 'component', &block)
19
+ def component(name, &)
20
+ node(name, shape: 'component', &)
16
21
  end
17
22
 
18
- def note(name, &block)
19
- node(name, shape: 'note', &block)
23
+ def note(name, &)
24
+ node(name, shape: 'note', &)
20
25
  end
21
26
 
22
- def node(name, shape: 'circle', &block)
23
- options = {diagram: diagram, shape: shape}
24
- Node.for(name, **options).build(&block)
27
+ def node(name, shape: nil, &)
28
+ options = { diagram: diagram }
29
+ options[:shape] = shape if shape
30
+ Node.for(name, **options).build(&)
25
31
  end
26
32
 
27
- def entity(name, parent = nil, &block)
33
+ def entity(name, parent = nil, &)
28
34
  entity = Entity.new(name: name, diagram: diagram)
29
- entity.build(&block)
35
+ entity.build(&)
30
36
  entity.add_dependency(parent, color: 'blue') if parent
31
37
  end
32
38
 
33
- def step(from, to:, **options)
34
- Node.for(from, diagram: diagram).add_dependency(to, **options)
39
+ def step(from, to:, **)
40
+ Node.for(from, diagram: diagram).add_dependency(to, **)
35
41
  end
36
42
 
37
- def write(options = {})
38
- diagram.write(options)
43
+ def write(**)
44
+ diagram.write(**)
39
45
  end
40
46
  end
41
47
  end
data/lib/graphy/entity.rb CHANGED
@@ -1,21 +1,28 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Graphy
4
+ # UML-ish record node. Entities draw the inheritance arrow reversed:
5
+ # parent -> child.
2
6
  class Entity < Node
3
7
  def initialize(**params)
4
8
  super(**params.merge(shape: 'Mrecord'))
5
9
  @attributes = []
6
10
  end
7
11
 
12
+ # Replaces the attribute list shown in the record label.
8
13
  def attrs(*values)
9
14
  @attributes = values
10
15
  end
11
16
 
17
+ # Appends method entries ("name()") to the record label.
12
18
  def meths(*values)
13
- @attributes << values.map { |x| "#{x}()"}
19
+ @attributes.concat(values.map { |value| "#{value}()" })
14
20
  end
15
21
 
16
22
  protected
17
23
 
18
- def draw_edge(dependency, **options)
24
+ # Inheritance edge: parent -> child (reversed from Node#draw_dependency_edge).
25
+ def draw_dependency_edge(dependency, **options)
19
26
  diagram.draw_edge(dependency.gnode, gnode, options)
20
27
  end
21
28
 
@@ -26,7 +33,8 @@ module Graphy
26
33
  private
27
34
 
28
35
  def attributes_label
29
- return if @attributes.empty?
36
+ return '' if @attributes.empty?
37
+
30
38
  "| #{@attributes.join("\n")}"
31
39
  end
32
40
  end
data/lib/graphy/node.rb CHANGED
@@ -1,15 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Graphy
4
+ # A node in the diagram. `.for` resolves Strings into Node instances and
5
+ # passes through existing Node/Entity objects.
2
6
  class Node
3
- attr_accessor :name, :shape, :diagram
7
+ attr_reader :name, :shape, :diagram
4
8
 
5
9
  def self.for(node, **params)
6
10
  case node
7
- when Entity, Node
8
- node
9
- when String
10
- self.new(**params.merge(name: node))
11
- else
12
- raise 'Invalid node class'
11
+ when Entity, Node then node
12
+ when String then new(**params, name: node)
13
+ else raise Error, "Invalid node: #{node.inspect} (#{node.class})"
13
14
  end
14
15
  end
15
16
 
@@ -19,17 +20,18 @@ module Graphy
19
20
  @shape = params.fetch(:shape, 'circle')
20
21
  end
21
22
 
22
- def add_dependency(dependency, **options)
23
+ # Draws the edge self -> dependency, once per diagram.
24
+ def add_dependency(dependency, **)
23
25
  dependency = self.class.for(dependency, diagram: diagram)
24
- return if Registry.edge?(self, dependency)
26
+ return if diagram.edge_drawn?(self, dependency)
25
27
 
26
- Registry.add_edge(self, dependency)
27
- draw_edge(dependency, **options)
28
+ diagram.track_edge(self, dependency)
29
+ draw_dependency_edge(dependency, **)
28
30
  end
29
- alias :uses :add_dependency
31
+ alias uses add_dependency
30
32
 
31
33
  def build(&block)
32
- instance_eval(&block) if block_given?
34
+ instance_eval(&block) if block
33
35
  gnode
34
36
  end
35
37
 
@@ -43,25 +45,25 @@ module Graphy
43
45
 
44
46
  protected
45
47
 
46
- def draw_edge(dependency, **options)
48
+ # Draws self -> dependency. Entity overrides this to draw the inheritance
49
+ # arrow the other way around (parent -> child).
50
+ def draw_dependency_edge(dependency, **options)
47
51
  diagram.draw_edge(gnode, dependency.gnode, options)
48
52
  end
49
53
 
54
+ private
55
+
50
56
  def node_params
51
- {
52
- label: label,
53
- shape: shape
54
- }
57
+ { label: label, shape: shape }
55
58
  end
56
59
 
57
60
  def label
58
61
  "#{name}\n"
59
62
  end
60
63
 
61
- private
62
-
63
64
  def find_or_draw
64
65
  return diagram.get_node(name) if diagram.node_exists?(name)
66
+
65
67
  diagram.draw_node(name, node_params)
66
68
  end
67
69
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Graphy
2
- VERSION = '0.1.2'.freeze
4
+ VERSION = '0.2.0'
3
5
  end
data/lib/graphy.rb CHANGED
@@ -1,14 +1,24 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'graphviz'
2
- require 'graphy/node'
3
- require 'graphy/entity'
4
- require 'graphy/diagram'
5
- require 'graphy/dsl'
6
- require 'graphy/registry'
7
- require 'graphy/version'
4
+ require_relative 'graphy/node'
5
+ require_relative 'graphy/entity'
6
+ require_relative 'graphy/diagram'
7
+ require_relative 'graphy/dsl'
8
+ require_relative 'graphy/version'
8
9
 
10
+ # A small DSL for declaring graph diagrams as code and rendering them with
11
+ # Graphviz, built on top of the ruby-graphviz gem.
12
+ #
13
+ # Graphy.define('Life View') do
14
+ # entity 'Animal'
15
+ # entity 'Dog', 'Animal'
16
+ # write png: 'life.png'
17
+ # end
9
18
  module Graphy
10
19
  class Error < StandardError; end
11
- def self.define(name=nil, options={}, &block)
12
- Dsl.new(name, options, &block)
20
+
21
+ def self.define(name, **, &)
22
+ Dsl.new(name, **, &)
13
23
  end
14
24
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis Ezcurdia Razo
8
- autorequire:
9
- bindir: exe
8
+ bindir: bin
10
9
  cert_chain: []
11
- date: 2020-09-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: ruby-graphviz
@@ -24,37 +23,23 @@ dependencies:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
25
  version: 1.2.0
27
- description: Create any graph diagram as code.
26
+ description: A small DSL on top of ruby-graphviz to declare graph diagrams as code
27
+ and render them with Graphviz.
28
28
  email:
29
29
  - ing.ezcurdia@gmail.com
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - ".gitignore"
35
- - ".travis.yml"
34
+ - CHANGELOG.md
36
35
  - CODE_OF_CONDUCT.md
37
- - Gemfile
38
36
  - LICENSE.txt
39
37
  - README.md
40
- - Rakefile
41
- - bin/console
42
- - bin/setup
43
- - examples/example00.rb
44
- - examples/example00.rb.png
45
- - examples/example01.rb
46
- - examples/example01.rb.png
47
- - examples/example02.rb
48
- - examples/example02.rb.png
49
- - examples/example03.rb
50
- - examples/example03.rb.png
51
- - graphy.gemspec
52
38
  - lib/graphy.rb
53
39
  - lib/graphy/diagram.rb
54
40
  - lib/graphy/dsl.rb
55
41
  - lib/graphy/entity.rb
56
42
  - lib/graphy/node.rb
57
- - lib/graphy/registry.rb
58
43
  - lib/graphy/version.rb
59
44
  homepage: https://github.com/3zcurdia/graphy
60
45
  licenses:
@@ -62,7 +47,9 @@ licenses:
62
47
  metadata:
63
48
  homepage_uri: https://github.com/3zcurdia/graphy
64
49
  source_code_uri: https://github.com/3zcurdia/graphy
65
- post_install_message:
50
+ changelog_uri: https://github.com/3zcurdia/graphy/blob/main/CHANGELOG.md
51
+ bug_tracker_uri: https://github.com/3zcurdia/graphy/issues
52
+ rubygems_mfa_required: 'true'
66
53
  rdoc_options: []
67
54
  require_paths:
68
55
  - lib
@@ -70,15 +57,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
57
  requirements:
71
58
  - - ">="
72
59
  - !ruby/object:Gem::Version
73
- version: 2.3.0
60
+ version: 3.3.0
74
61
  required_rubygems_version: !ruby/object:Gem::Requirement
75
62
  requirements:
76
63
  - - ">="
77
64
  - !ruby/object:Gem::Version
78
65
  version: '0'
79
66
  requirements: []
80
- rubygems_version: 3.1.3
81
- signing_key:
67
+ rubygems_version: 3.6.9
82
68
  specification_version: 4
83
69
  summary: Create diagrams as code.
84
70
  test_files: []
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- Gemfile.lock
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7.1
6
- before_install: gem install bundler -v 2.1.4
data/Gemfile DELETED
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in Graphy.gemspec
4
- gemspec
5
-
6
- gem 'minitest', '~> 5.0'
7
- gem 'rake', '~> 12.0'
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << 'test'
6
- t.libs << 'lib'
7
- t.test_files = FileList['test/**/*_test.rb']
8
- end
9
-
10
- task default: :test
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'graphy'
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 DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,13 +0,0 @@
1
- require 'bundler/setup'
2
- require 'graphviz/dsl'
3
-
4
- digraph :example do
5
- cluster_0 do
6
- graph[label: 'Animal Kingdom']
7
- animal << dog
8
- animal << cat
9
- end
10
- friendly << dog
11
-
12
- output(png: "#{$0}.png")
13
- end
Binary file
@@ -1,17 +0,0 @@
1
- require 'bundler/setup'
2
- require 'graphy'
3
-
4
- Graphy.define 'State machine', orientation: :horizonal do
5
- node 'A'
6
- node 'B', shape: 'diamond'
7
- node 'C'
8
- node 'D', shape: 'egg'
9
-
10
- step 'A', to: 'B'
11
- step 'B', to: 'C'
12
- step 'C', to: 'A'
13
- step 'C', to: 'D'
14
- step 'D', to: 'C'
15
-
16
- write png: "#{$0}.png"
17
- end
Binary file
@@ -1,19 +0,0 @@
1
- require 'bundler/setup'
2
- require 'graphy'
3
-
4
- Graphy.define 'Life View' do
5
- entity 'Animal' do
6
- attrs :name, :other
7
- end
8
-
9
- entity 'Dog', 'Animal' do
10
- attrs :color
11
- uses 'Friendly'
12
- end
13
-
14
- entity 'Cat', 'Animal' do
15
- meths :scratch
16
- end
17
-
18
- write png: "#{$0}.png"
19
- end
Binary file
@@ -1,15 +0,0 @@
1
- require 'bundler/setup'
2
- require 'graphy'
3
-
4
- Graphy.define 'Life View' do
5
- entity 'Friendly'
6
- namespace 'Animal Kingdom' do
7
- entity 'Animal'
8
- entity 'Dog', 'Animal' do
9
- uses 'Friendly'
10
- end
11
- entity 'Cat', 'Animal'
12
- end
13
-
14
- write png: "#{$0}.png"
15
- end
Binary file
data/graphy.gemspec DELETED
@@ -1,31 +0,0 @@
1
- require_relative 'lib/graphy/version'
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = 'graphy'
5
- spec.version = Graphy::VERSION
6
- spec.authors = ['Luis Ezcurdia Razo']
7
- spec.email = ['ing.ezcurdia@gmail.com']
8
-
9
- spec.summary = 'Create diagrams as code.'
10
- spec.description = 'Create any graph diagram as code.'
11
- spec.homepage = 'https://github.com/3zcurdia/graphy'
12
- spec.license = 'MIT'
13
- spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
14
-
15
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
16
-
17
- spec.metadata['homepage_uri'] = spec.homepage
18
- spec.metadata['source_code_uri'] = 'https://github.com/3zcurdia/graphy'
19
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
20
-
21
- # Specify which files should be added to the gem when it is released.
22
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
- end
26
- spec.bindir = 'exe'
27
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
- spec.require_paths = ['lib']
29
-
30
- spec.add_dependency 'ruby-graphviz', '~> 1.2.0'
31
- end
@@ -1,28 +0,0 @@
1
- require 'singleton'
2
-
3
- module Graphy
4
- class Registry
5
- include Singleton
6
- attr_accessor :edges
7
-
8
- def self.edge?(source, destiny)
9
- instance.edge?(source, destiny)
10
- end
11
-
12
- def self.add_edge(source, destiny)
13
- instance.add_edge(source, destiny)
14
- end
15
-
16
- def initialize
17
- @edges = {}
18
- end
19
-
20
- def edge?(source, destiny)
21
- edges.key?("#{source}->#{destiny}")
22
- end
23
-
24
- def add_edge(source, destiny, options = {})
25
- self.edges["#{source}->#{destiny}"] = options
26
- end
27
- end
28
- end