graphy 0.1.0 → 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: 5855af538a3e42839fb6291076af3a81d7d6e117624e0ff912dfb537599b1d78
4
- data.tar.gz: 43f3be7f19de34cf97743b03bdab151ae7cbc3d8fbe970802434dc11618dca33
3
+ metadata.gz: 316c611d1ad28902ba2d122aca06b5c270e1e99d5e2b418c302a42886192ec7d
4
+ data.tar.gz: 9f485df10f829bdec801ee928d1f8830f59d8bf3361829aa975e58780214a9a6
5
5
  SHA512:
6
- metadata.gz: 811d052517b6a4a32b354818976a62f6fd38dc695ad7df03b21601b58793f923909d7337aa1968547d55eb4e6c5a4f7f92213740210a63396376a1485de22bd1
7
- data.tar.gz: 51c60f6b786035b87ee4357358db75b7edab3d7f0ffd6f605412b3d221081fc598f12ac4261cc7e02cc80685f779f3eba53c0788830c9794c078b6746042229d
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,6 +1,16 @@
1
1
  # Graphy
2
2
 
3
- Create any diagram as code
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
+
6
+ DSL to create graph diagrams as code
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.
4
14
 
5
15
  ## Installation
6
16
 
@@ -23,20 +33,20 @@ Or install it yourself as:
23
33
  ### Module
24
34
 
25
35
  ```ruby
26
- Graphy.define 'UML View' do
36
+ 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
34
- attributes :color
44
+ attrs :color
35
45
  uses 'Friendly'
36
46
  end
37
47
 
38
48
  entity 'Cat', 'Animal' do
39
- attributes :scratch
49
+ meths :scratch
40
50
  end
41
51
  end
42
52
 
@@ -44,10 +54,21 @@ Graphy.define 'UML View' do
44
54
  end
45
55
  ```
46
56
 
57
+ ![example02.png](https://github.com/3zcurdia/graphy/blob/main/examples/example02.rb.png)
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.
64
+
47
65
  ### State machine
48
66
 
67
+ Pass `orientation: :horizontal` to lay the graph out left to right
68
+ (`rankdir=LR`); the default is top to bottom.
69
+
49
70
  ```ruby
50
- Graphy.define 'State machine' do
71
+ Graphy.define 'State machine', orientation: :horizontal do
51
72
  node 'A'
52
73
  node 'B', shape: 'diamond'
53
74
  node 'C'
@@ -62,16 +83,24 @@ Graphy.define 'State machine' do
62
83
  write(png: 'steps.png')
63
84
  end
64
85
  ```
86
+ ![example01.png](https://github.com/3zcurdia/graphy/blob/main/examples/example01.rb.png)
65
87
 
66
88
  ## Development
67
89
 
68
- 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.
69
98
 
70
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).
71
100
 
72
101
  ## Contributing
73
102
 
74
- 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).
75
104
 
76
105
 
77
106
  ## License
@@ -80,4 +109,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
80
109
 
81
110
  ## Code of Conduct
82
111
 
83
- 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).
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Graphy
4
+ # Thin wrapper around a GraphViz graph.
5
+ class Diagram
6
+ attr_reader :graph, :edges
7
+
8
+ GRAPH_ATTRIBUTES = {
9
+ ranksep: 0.5,
10
+ nodesep: 0.4,
11
+ pad: '0.4,0.4',
12
+ margin: '0,0',
13
+ concentrate: true,
14
+ labelloc: :t,
15
+ fontsize: 14,
16
+ fontname: 'Arial BoldMT',
17
+ splines: 'spline'
18
+ }.freeze
19
+
20
+ NODE_ATTRIBUTES = {
21
+ shape: 'Mrecord',
22
+ fontsize: 12,
23
+ fontname: 'ArialMT',
24
+ margin: '0.07,0.05',
25
+ penwidth: 1.0
26
+ }.freeze
27
+
28
+ EDGE_ATTRIBUTES = {
29
+ fontname: 'ArialMT',
30
+ fontsize: 10,
31
+ arrowsize: 0.9,
32
+ penwidth: 1.0,
33
+ labelangle: 32,
34
+ labeldistance: 1.8
35
+ }.freeze
36
+
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 = {}
41
+
42
+ apply_default_attributes!
43
+ @graph[:rankdir] = options[:orientation] == :horizontal ? :LR : :TB
44
+ @graph[:label] = "#{name}\\n\\n"
45
+ end
46
+
47
+ def get_node(name)
48
+ graph.search_node(name)
49
+ end
50
+
51
+ def node_exists?(name)
52
+ !!get_node(name)
53
+ end
54
+
55
+ def draw_node(name, options = {})
56
+ graph.add_nodes(name, options)
57
+ end
58
+
59
+ # NOTE: `options` stays positional here on purpose - it is forwarded
60
+ # verbatim into ruby-graphviz's positional-hash API.
61
+ def draw_edge(from, to, options)
62
+ graph.add_edges(from, to, options)
63
+ end
64
+
65
+ def draw_graph(diagram)
66
+ graph.add_graph(diagram.graph)
67
+ end
68
+
69
+ def write(**options)
70
+ graph.output(options)
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
95
+ end
96
+ end
data/lib/graphy/dsl.rb CHANGED
@@ -1,84 +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
- @registry = {}
4
- @edges = []
5
-
6
- def self.registry
7
- @registry
8
- end
6
+ attr_reader :diagram
9
7
 
10
- def self.edges
11
- @edges
12
- end
8
+ def initialize(name, **, &block)
9
+ raise Error, 'Diagram name is required' if name.nil? || name.to_s.strip.empty?
13
10
 
14
- def initialize(name, options = {}, &block)
15
- @graph = GraphViz.new(name, map_options(options.merge(label: name)))
11
+ @diagram = Diagram.new(name, **)
16
12
  instance_eval(&block) if block
17
13
  end
18
14
 
19
- def namespace(name, &block)
20
- opts = { parent: graph, type: graph.type }
21
- graph.add_graph(Dsl.new(name, opts, &block).graph)
22
- end
23
-
24
- def component(name, &block)
25
- node(name, shape: 'component', &block)
26
- end
27
-
28
- def note(name, &block)
29
- node(name, shape: 'note', &block)
15
+ def namespace(name, &)
16
+ diagram.draw_graph(Dsl.new(name, parent: diagram.graph, &).diagram)
30
17
  end
31
18
 
32
- def node(name, shape: 'circle', &block)
33
- return graph.get_node(name) unless graph.get_node(name.to_s).nil?
34
-
35
- node = Node.new(name, graph: graph, shape: shape)
36
- node.instance_eval(&block) if block_given?
37
- Dsl.registry[name] = node
19
+ def component(name, &)
20
+ node(name, shape: 'component', &)
38
21
  end
39
22
 
40
- def entity(name, parent = nil, &block)
41
- return graph.get_node(name) unless graph.get_node(name.to_s).nil?
42
-
43
- entity = Entity.new(name, graph: graph)
44
- entity.add_dependency(parent, type: :parent) if parent
45
- entity.instance_eval(&block) if block_given?
46
- Dsl.registry[name] = entity
23
+ def note(name, &)
24
+ node(name, shape: 'note', &)
47
25
  end
48
26
 
49
- def step(from, to:, options: {})
50
- return if Dsl.edges.any? { |x| [from, to] == x }
51
- source = Dsl.registry[from].graph_node
52
- dest = Dsl.registry[to].graph_node
53
- return if source.nil? || dest.nil?
54
-
55
- Dsl.edges << [from, to]
56
- graph.add_edge(source, dest, options)
27
+ def node(name, shape: nil, &)
28
+ options = { diagram: diagram }
29
+ options[:shape] = shape if shape
30
+ Node.for(name, **options).build(&)
57
31
  end
58
32
 
59
- def graph
60
- build
61
- @graph
33
+ def entity(name, parent = nil, &)
34
+ entity = Entity.new(name: name, diagram: diagram)
35
+ entity.build(&)
36
+ entity.add_dependency(parent, color: 'blue') if parent
62
37
  end
63
38
 
64
- def write(options = {})
65
- graph.output(options)
66
- end
67
-
68
- private
69
-
70
- def build
71
- Dsl.registry.each do |name, node|
72
- node.dependencies.each do |dep|
73
- step(dep.ref, to: name, options: dep.edge_attributes)
74
- end
75
- end
39
+ def step(from, to:, **)
40
+ Node.for(from, diagram: diagram).add_dependency(to, **)
76
41
  end
77
42
 
78
- def map_options(options = {})
79
- align = options.delete(:align)
80
- rankdir = align == :horizontal ? 'LR' : nil
81
- options.merge(rankdir: rankdir).compact
43
+ def write(**)
44
+ diagram.write(**)
82
45
  end
83
46
  end
84
47
  end
data/lib/graphy/entity.rb CHANGED
@@ -1,16 +1,31 @@
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
- def initialize(name, graph:)
4
- super(name, graph: graph, shape: 'record')
7
+ def initialize(**params)
8
+ super(**params.merge(shape: 'Mrecord'))
5
9
  @attributes = []
6
10
  end
7
11
 
8
- def attributes(*values)
12
+ # Replaces the attribute list shown in the record label.
13
+ def attrs(*values)
9
14
  @attributes = values
10
15
  end
11
16
 
17
+ # Appends method entries ("name()") to the record label.
18
+ def meths(*values)
19
+ @attributes.concat(values.map { |value| "#{value}()" })
20
+ end
21
+
12
22
  protected
13
23
 
24
+ # Inheritance edge: parent -> child (reversed from Node#draw_dependency_edge).
25
+ def draw_dependency_edge(dependency, **options)
26
+ diagram.draw_edge(dependency.gnode, gnode, options)
27
+ end
28
+
14
29
  def label
15
30
  "{ #{name} #{attributes_label} }"
16
31
  end
@@ -18,8 +33,9 @@ module Graphy
18
33
  private
19
34
 
20
35
  def attributes_label
21
- return if @attributes.empty?
22
- "| #{@attributes.join("\n")}"
36
+ return '' if @attributes.empty?
37
+
38
+ "| #{@attributes.join("\n")}"
23
39
  end
24
40
  end
25
41
  end
data/lib/graphy/node.rb CHANGED
@@ -1,38 +1,70 @@
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 :graph, :name, :shape, :penwidth, :fontsize, :style, :fillcolor, :dependencies
4
- def initialize(name, graph:, shape: 'circle')
5
- @name = name
6
- @graph = graph
7
- @shape = shape
8
- @dependencies = []
7
+ attr_reader :name, :shape, :diagram
8
+
9
+ def self.for(node, **params)
10
+ case node
11
+ when Entity, Node then node
12
+ when String then new(**params, name: node)
13
+ else raise Error, "Invalid node: #{node.inspect} (#{node.class})"
14
+ end
15
+ end
16
+
17
+ def initialize(**params)
18
+ @name = params[:name].to_s
19
+ @diagram = params[:diagram]
20
+ @shape = params.fetch(:shape, 'circle')
9
21
  end
10
22
 
11
- def graph_node
12
- @graph_node ||= graph.add_nodes(name, node_attributes)
23
+ # Draws the edge self -> dependency, once per diagram.
24
+ def add_dependency(dependency, **)
25
+ dependency = self.class.for(dependency, diagram: diagram)
26
+ return if diagram.edge_drawn?(self, dependency)
27
+
28
+ diagram.track_edge(self, dependency)
29
+ draw_dependency_edge(dependency, **)
30
+ end
31
+ alias uses add_dependency
32
+
33
+ def build(&block)
34
+ instance_eval(&block) if block
35
+ gnode
13
36
  end
14
37
 
15
- def add_dependency(dependency, type: nil)
16
- @dependencies << Dependency.for(dependency, type: type)
38
+ def gnode
39
+ @gnode ||= find_or_draw
40
+ end
41
+
42
+ def to_s
43
+ "#{self.class}<#{name}>"
17
44
  end
18
- alias :uses :add_dependency
19
45
 
20
46
  protected
21
47
 
22
- def node_attributes
23
- {
24
- shape: shape,
25
- penwidth: penwidth,
26
- fontsize: fontsize,
27
- fontname: 'Helvetica',
28
- style: style,
29
- fillcolor: fillcolor,
30
- label: label
31
- }.compact
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)
51
+ diagram.draw_edge(gnode, dependency.gnode, options)
52
+ end
53
+
54
+ private
55
+
56
+ def node_params
57
+ { label: label, shape: shape }
32
58
  end
33
59
 
34
60
  def label
35
61
  "#{name}\n"
36
62
  end
63
+
64
+ def find_or_draw
65
+ return diagram.get_node(name) if diagram.node_exists?(name)
66
+
67
+ diagram.draw_node(name, node_params)
68
+ end
37
69
  end
38
70
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Graphy
2
- VERSION = '0.1.0'.freeze
4
+ VERSION = '0.2.0'
3
5
  end
data/lib/graphy.rb CHANGED
@@ -1,13 +1,24 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'graphviz'
2
- require 'graphy/node'
3
- require 'graphy/entity'
4
- require 'graphy/dependency'
5
- require 'graphy/dsl'
6
- 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'
7
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
8
18
  module Graphy
9
19
  class Error < StandardError; end
10
- def self.define(name=nil, options={}, &block)
11
- Dsl.new(name, options, &block)
20
+
21
+ def self.define(name, **, &)
22
+ Dsl.new(name, **, &)
12
23
  end
13
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.0
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-21 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,32 +23,20 @@ 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
- - Gemfile.lock
39
36
  - LICENSE.txt
40
37
  - README.md
41
- - Rakefile
42
- - bin/console
43
- - bin/setup
44
- - examples/example00.rb
45
- - examples/example00.rb.png
46
- - examples/example01.rb
47
- - examples/example01.rb.png
48
- - examples/example02.rb
49
- - examples/example02.rb.png
50
- - graphy.gemspec
51
38
  - lib/graphy.rb
52
- - lib/graphy/dependency.rb
39
+ - lib/graphy/diagram.rb
53
40
  - lib/graphy/dsl.rb
54
41
  - lib/graphy/entity.rb
55
42
  - lib/graphy/node.rb
@@ -60,7 +47,9 @@ licenses:
60
47
  metadata:
61
48
  homepage_uri: https://github.com/3zcurdia/graphy
62
49
  source_code_uri: https://github.com/3zcurdia/graphy
63
- 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'
64
53
  rdoc_options: []
65
54
  require_paths:
66
55
  - lib
@@ -68,15 +57,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
57
  requirements:
69
58
  - - ">="
70
59
  - !ruby/object:Gem::Version
71
- version: 2.3.0
60
+ version: 3.3.0
72
61
  required_rubygems_version: !ruby/object:Gem::Requirement
73
62
  requirements:
74
63
  - - ">="
75
64
  - !ruby/object:Gem::Version
76
65
  version: '0'
77
66
  requirements: []
78
- rubygems_version: 3.1.3
79
- signing_key:
67
+ rubygems_version: 3.6.9
80
68
  specification_version: 4
81
69
  summary: Create diagrams as code.
82
70
  test_files: []
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
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/Gemfile.lock DELETED
@@ -1,25 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- arq (0.1.0)
5
- ruby-graphviz (~> 1.2.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- minitest (5.14.2)
11
- rake (12.3.3)
12
- rexml (3.2.4)
13
- ruby-graphviz (1.2.5)
14
- rexml
15
-
16
- PLATFORMS
17
- ruby
18
-
19
- DEPENDENCIES
20
- arq!
21
- minitest (~> 5.0)
22
- rake (~> 12.0)
23
-
24
- BUNDLED WITH
25
- 2.1.4
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 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,20 +0,0 @@
1
- require 'bundler/setup'
2
- require 'graphy'
3
-
4
- Graphy.define 'Life View' do
5
- entity 'Friendly'
6
- entity 'Animal' do
7
- attributes :name, :other
8
- end
9
-
10
- entity 'Dog', 'Animal' do
11
- attributes :color
12
- uses 'Friendly'
13
- end
14
-
15
- entity 'Cat', 'Animal' do
16
- attributes :scratch
17
- end
18
-
19
- write png: "#{$0}.png"
20
- 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,29 +0,0 @@
1
- module Graphy
2
- class Dependency
3
- def self.for(reference, type: nil)
4
- case type
5
- when :parent
6
- Parent
7
- else
8
- Default
9
- end.new(reference)
10
- end
11
-
12
- class Default
13
- attr_accessor :ref
14
- def initialize(ref)
15
- @ref = ref
16
- end
17
-
18
- def edge_attributes
19
- {}
20
- end
21
- end
22
-
23
- class Parent < Default
24
- def edge_attributes
25
- { style: 'dotted', color: 'blue' }
26
- end
27
- end
28
- end
29
- end