gviz 0.1.1 → 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c6238dfcf0f09e9b3afd83cb9a4815af62b517f2
4
+ data.tar.gz: cc3d2435e20ad0a9b3c83f73e87ba06bb096e4d8
5
+ SHA512:
6
+ metadata.gz: 05045c7c238b0687ec198fa275880abd944eb6311c78dff31a49e822ccf97f6a360680e1b84d479574e746582816d88d0a829e24fbc5758e84f4cd624439d9cc
7
+ data.tar.gz: 5b84db6cbc2b4baf86d005726490ded619dd0fab929e7334ad791d873bad875e5202aeaf88198293787b45ef972d44578114e100622b61d12ac217022432f0dd
data/bin/gviz CHANGED
@@ -53,12 +53,12 @@ class OptionParser
53
53
  def print_manual(man)
54
54
  attrs = %w(graph node edge subgraph cluster)
55
55
  consts = %w(color_names color_schemes full_color_names
56
- full_color_schemes arrows shapes output_formats
57
- svg_color_names dark_colors)
56
+ full_color_schemes arrows shapes layouts
57
+ output_formats svg_color_names dark_colors)
58
58
  man_man = ~<<-EOS
59
59
  \e[35m--man(-m) accepts any of them:\e[0m
60
60
  graph, node, edge, subgraph, cluster,
61
- arrows, shapes, output_formats
61
+ arrows, shapes, layouts, output_formats
62
62
  color_names, color_schemes,
63
63
  full_color_names, full_color_schemes,
64
64
  svg_color_names, dark_colors
data/lib/gviz/core.rb CHANGED
@@ -64,7 +64,7 @@ class Gviz
64
64
  #
65
65
  # You can define a endpoint to a node, by adding a point identifier
66
66
  # with a colon after the each node. You must specify the identifiers
67
- # it the label of the corresponding nodes.
67
+ # in the label of the corresponding nodes.
68
68
  #
69
69
  # gv.edge("a:x_b:y")
70
70
  # gv.node(:a, label:"<x> 1 | 2 | 3")
@@ -29,6 +29,8 @@ ARROWS = ["box", "lbox", "rbox", "obox", "olbox", "orbox", "crow", "lcrow", "rcr
29
29
  # http://www.graphviz.org/content/node-shapes
30
30
  SHAPES = ["box", "polygon", "ellipse", "oval", "circle", "point", "egg", "triangle", "plaintext", "diamond", "trapezium", "parallelogram", "house", "pentagon", "hexagon", "septagon", "octagon", "doublecircle", "doubleoctagon", "tripleoctagon", "invtriangle", "invtrapezium", "invhouse", "Mdiamond", "Msquare", "Mcircle", "rect", "rectangle", "square", "none", "note", "tab", "folder", "box3d", "component", "promoter", "cds", "terminator", "utr", "primersite", "restrictionsite", "fivepoverhang", "threepoverhang", "noverhang", "assembly", "signature", "insulator", "ribosite", "rnastab", "proteasesite", "proteinstab", "rpromoter", "rarrow", "larrow", "lpromoter"]
31
31
 
32
+ # Graph Layouts
33
+ LAYOUTS = %w(circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi)
32
34
 
33
35
  # Output Formats
34
36
  # http://www.graphviz.org/content/output-formats
@@ -48,4 +50,4 @@ def self.ATTR(target)
48
50
  .map { |_, name, *desc| [name, desc] }
49
51
  end
50
52
 
51
- end
53
+ end
@@ -20,6 +20,13 @@ class Object
20
20
  def to_id
21
21
  to_s.hash.to_s.intern
22
22
  end
23
+
24
+ # Returns a wrapped string with specific wrappers
25
+ # for building a label using record shape.
26
+ # Default wrapper is '{ }'
27
+ def wrap(by=['{','}'])
28
+ by.insert(1, self).join
29
+ end
23
30
  end
24
31
 
25
32
  class String
@@ -43,6 +50,18 @@ class Array
43
50
  cnt = 0
44
51
  end
45
52
  end
53
+ res << q.join(sep) unless q.empty?
46
54
  res
47
55
  end
56
+
57
+ # Returns a tileized string for building
58
+ # a label using record shape.
59
+ #
60
+ # [[[:a, :b], :c], [1, 2, 3]].tileize # => "{{{a|b}|c}|{1|2|3}}"
61
+ #
62
+ def tileize
63
+ self.map do |x|
64
+ x.is_a?(Array) ? x.tileize : x
65
+ end.join('|').wrap
66
+ end
48
67
  end
data/lib/gviz/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Gviz
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -48,19 +48,26 @@ describe "gviz command" do
48
48
  end
49
49
 
50
50
  context "when -m with correct attr passed" do
51
- subject { syscmd "#{ROOT}/bin/gviz -m arrows" }
52
- it { should eql Gviz::ARROWS.join(", ") + "\n" }
51
+ subject { syscmd("#{ROOT}/bin/gviz -m arrows") }
52
+ it do
53
+ should eql ~<<-EOS
54
+ \e[35mArrows:\e[0m
55
+ box, lbox, rbox, obox, olbox, orbox, crow, lcrow, rcrow, diamond, ldiamond, rdiamond
56
+ oldiamond, ordiamond, dot, odot, inv, linv, rinv, oinv, olinv, orinv, none, normal, lnormal
57
+ EOS
58
+ end
53
59
  end
54
60
 
55
61
  context "when -m with man word passed" do
56
62
  subject { syscmd "#{ROOT}/bin/gviz -m man" }
57
63
  it do
58
64
  should eql ~<<-EOS
59
- --man(-m) accepts any of them:
65
+ \e[35m--man(-m) accepts any of them:\e[0m
60
66
  graph, node, edge, subgraph, cluster,
61
67
  arrows, shapes, output_formats
62
68
  color_names, color_schemes,
63
69
  full_color_names, full_color_schemes,
70
+ svg_color_names, dark_colors
64
71
  EOS
65
72
  end
66
73
  end
@@ -70,11 +77,12 @@ describe "gviz command" do
70
77
  it do
71
78
  should eql ~<<-EOS
72
79
  Error: unknown subcommand 'abc' for --man
73
- --man(-m) accepts any of them:
80
+ \e[35m--man(-m) accepts any of them:\e[0m
74
81
  graph, node, edge, subgraph, cluster,
75
82
  arrows, shapes, output_formats
76
83
  color_names, color_schemes,
77
84
  full_color_names, full_color_schemes,
85
+ svg_color_names, dark_colors
78
86
  EOS
79
87
  end
80
88
  end
@@ -56,4 +56,29 @@ describe Object do
56
56
  end
57
57
  end
58
58
  end
59
+
60
+ describe "#wrap" do
61
+ it "works for any object" do
62
+ 'a'.wrap(['(',')']).should eql '(a)'
63
+ 10.wrap(['<','>']).should eql '<10>'
64
+ :a.wrap(['/','/']).should eql '/a/'
65
+ end
66
+
67
+ it "wrap with '{}' in default" do
68
+ 'a'.wrap.should eql '{a}'
69
+ 10.wrap.should eql '{10}'
70
+ :a.wrap.should eql '{a}'
71
+ end
72
+ end
59
73
  end
74
+
75
+ describe Array do
76
+ describe "#tileize" do
77
+ it "build label for record shape" do
78
+ [:a, :b].tileize.should eql "{a|b}"
79
+ [[:a, :b], [1, 2]].tileize.should eql "{{a|b}|{1|2}}"
80
+ [[:a, :b], [1, 2], [:x, :y]].tileize.should eql "{{a|b}|{1|2}|{x|y}}"
81
+ [[[:a, :b], :c], [1, 2, 3]].tileize.should eql "{{{a|b}|c}|{1|2|3}}"
82
+ end
83
+ end
84
+ end
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gviz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - kyoendo
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-10-20 00:00:00.000000000 Z
11
+ date: 2013-04-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: trollop
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description: Ruby's interface of graphviz
@@ -81,27 +76,26 @@ files:
81
76
  - spec/system_extension_spec.rb
82
77
  homepage: https://github.com/melborne/Gviz
83
78
  licenses: []
79
+ metadata: {}
84
80
  post_install_message:
85
81
  rdoc_options: []
86
82
  require_paths:
87
83
  - lib
88
84
  required_ruby_version: !ruby/object:Gem::Requirement
89
- none: false
90
85
  requirements:
91
- - - ! '>='
86
+ - - '>='
92
87
  - !ruby/object:Gem::Version
93
88
  version: 1.9.3
94
89
  required_rubygems_version: !ruby/object:Gem::Requirement
95
- none: false
96
90
  requirements:
97
- - - ! '>='
91
+ - - '>='
98
92
  - !ruby/object:Gem::Version
99
93
  version: '0'
100
94
  requirements: []
101
95
  rubyforge_project:
102
- rubygems_version: 1.8.24
96
+ rubygems_version: 2.0.3
103
97
  signing_key:
104
- specification_version: 3
98
+ specification_version: 4
105
99
  summary: Ruby's interface of graphviz. It generate a dot file with simple ruby's syntax.
106
100
  test_files:
107
101
  - spec/graph.ru
@@ -111,4 +105,3 @@ test_files:
111
105
  - spec/gviz_spec.rb
112
106
  - spec/spec_helper.rb
113
107
  - spec/system_extension_spec.rb
114
- has_rdoc: