cgraph 0.0.1 → 0.0.2

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.
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  *.png
2
+ pkg/
data/cgraph.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
13
  gem.name = "cgraph"
14
14
  gem.require_paths = ["lib"]
15
- gem.version = "0.0.1"
15
+ gem.version = "0.0.2"
16
16
  gem.add_development_dependency "guard-minitest"
17
17
  gem.add_development_dependency "minitest"
18
18
 
data/lib/cgraph.rb CHANGED
@@ -33,10 +33,12 @@ module Cgraph
33
33
 
34
34
  class Graph
35
35
  attr_reader :entities, :connections
36
- def initialize data, info
36
+ def initialize data, info, options={}
37
37
  Entity.clear_namelist
38
38
  @connections = []
39
39
  @entities = []
40
+ @root = options[:root] || ""
41
+ @no_penwidth = options[:penwidth] || false
40
42
  generate_entities data, info
41
43
  generate_connections data
42
44
  end
@@ -64,18 +66,41 @@ module Cgraph
64
66
  return e if e.name == name
65
67
  end
66
68
  end
69
+ def add_entities graph
70
+ @entities.each do |e|
71
+ if e.picture
72
+ graph.add_nodes e.name,label: "",image: e.picture
73
+ else
74
+ graph.add_nodes e.name, label: e.label
75
+ end
76
+ end
77
+ graph
78
+ end
67
79
  def generate_graph
68
- graph = GraphViz.new(:G, :type => :digraph)
80
+ if @root
81
+ graph = GraphViz.new(:G, :type => :digraph, :root => @root)
82
+ else
83
+ graph = GraphViz.new(:G, :type => :digraph)
84
+ end
69
85
  graph = add_connections_to_graph graph
70
- graph.output(:png => "test.png")
86
+ graph = add_entities graph
71
87
  graph
72
88
  end
89
+ def to_png
90
+ graph.output(:png => "test.png")
91
+ end
73
92
  def add_connections_to_graph graph
74
93
  @connections.each do |conn|
75
- p conn
76
94
  tupel = conn.first
95
+ options = {}
96
+
97
+ if @no_penwidth
98
+ options = {}
99
+ else
100
+ #options = {penwidth: conn[1][:count]}
101
+ true
102
+ end
77
103
 
78
- options = {penwidth: conn[1][:count]}
79
104
  graph.add_edges tupel[0],tupel[1],options
80
105
  end
81
106
  graph
data/spec/cgraph_spec.rb CHANGED
@@ -60,8 +60,7 @@ describe Graph do
60
60
  g.generate_graph.to_s.must_match /digraph/
61
61
  end
62
62
  it "should use the info data to enhance the entities" do
63
- g.find_entity("peter").label.must_equal "Peter Pan"
63
+ g.generate_graph.find_node("peter").output
64
64
  g.find_entity("paul").picture.must_equal "logo_url"
65
-
66
65
  end
67
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cgraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-31 00:00:00.000000000 Z
12
+ date: 2012-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard-minitest
16
- requirement: &20170240 !ruby/object:Gem::Requirement
16
+ requirement: &21683800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *20170240
24
+ version_requirements: *21683800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: minitest
27
- requirement: &20186200 !ruby/object:Gem::Requirement
27
+ requirement: &21699760 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *20186200
35
+ version_requirements: *21699760
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ruby-graphviz
38
- requirement: &20185780 !ruby/object:Gem::Requirement
38
+ requirement: &21699340 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *20185780
46
+ version_requirements: *21699340
47
47
  description: ''
48
48
  email:
49
49
  - martin.schneider@pludoni.de