gviz 0.0.2 → 0.0.3
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/lib/gviz/system_extension.rb +6 -0
- data/lib/gviz/version.rb +1 -1
- data/lib/gviz.rb +6 -0
- data/spec/gviz_spec.rb +18 -0
- data/spec/system_extension_spec.rb +33 -0
- metadata +5 -2
data/lib/gviz/version.rb
CHANGED
data/lib/gviz.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative "gviz/system_extension"
|
2
|
+
|
1
3
|
class Gviz
|
2
4
|
class Node < Struct.new(:id, :attrs)
|
3
5
|
def initialize(id, attrs={})
|
@@ -193,6 +195,10 @@ class Gviz
|
|
193
195
|
end
|
194
196
|
end
|
195
197
|
|
198
|
+
def Graph(name, &blk)
|
199
|
+
Gviz.new(name).graph(&blk)
|
200
|
+
end
|
201
|
+
|
196
202
|
if __FILE__ == $0
|
197
203
|
g = Gviz.new
|
198
204
|
g.graph do
|
data/spec/gviz_spec.rb
CHANGED
@@ -398,4 +398,22 @@ describe Gviz do
|
|
398
398
|
EOS
|
399
399
|
end
|
400
400
|
end
|
401
|
+
|
402
|
+
context "Graph class method" do
|
403
|
+
it "create a gviz object" do
|
404
|
+
g = Graph(:X) do
|
405
|
+
add :a => [:b, :c]
|
406
|
+
end
|
407
|
+
g.should be_a_instance_of Gviz
|
408
|
+
g.to_s.should eql ~<<-EOS
|
409
|
+
digraph X {
|
410
|
+
a;
|
411
|
+
b;
|
412
|
+
c;
|
413
|
+
a -> b;
|
414
|
+
a -> c;
|
415
|
+
}
|
416
|
+
EOS
|
417
|
+
end
|
418
|
+
end
|
401
419
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Numeric do
|
4
|
+
context "norm" do
|
5
|
+
it "normalize a integer into range of 0.0-1.0" do
|
6
|
+
5.norm(0..10).should eql 0.5
|
7
|
+
2.norm(0..10).should eql 0.2
|
8
|
+
0.norm(0..10).should eql 0.0
|
9
|
+
10.norm(0..10).should eql 1.0
|
10
|
+
5.norm(5..10).should eql 0.0
|
11
|
+
10.norm(5..10).should eql 1.0
|
12
|
+
7.norm(5..10).should eql 0.4
|
13
|
+
end
|
14
|
+
|
15
|
+
it "normalize a float into range of 0.0-1.0" do
|
16
|
+
2.5.norm(0..10).should eql 0.25
|
17
|
+
7.4.norm(0..10).should eql 0.74
|
18
|
+
0.0.norm(0..10).should eql 0.0
|
19
|
+
10.0.norm(0..10).should eql 1.0
|
20
|
+
15.0.norm(10..20).should eql 0.5
|
21
|
+
end
|
22
|
+
|
23
|
+
it "can take target range other than 0.0-1.0" do
|
24
|
+
5.norm(0..10, 0..20).should eql 10.0
|
25
|
+
2.norm(0..10, 10..20).should eql 12.0
|
26
|
+
0.norm(0..10, 10..15).should eql 10.0
|
27
|
+
10.norm(0..10, 10..15).should eql 15.0
|
28
|
+
5.norm(0..10, 10..15).should eql 12.5
|
29
|
+
2.5.norm(0..10, 0..5).should eql 1.25
|
30
|
+
2.5.norm(0..10, 5..10).should eql 6.25
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gviz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-01 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Ruby's interface of graphviz
|
15
15
|
email:
|
@@ -32,9 +32,11 @@ files:
|
|
32
32
|
- examples/shapes.rb
|
33
33
|
- gviz.gemspec
|
34
34
|
- lib/gviz.rb
|
35
|
+
- lib/gviz/system_extension.rb
|
35
36
|
- lib/gviz/version.rb
|
36
37
|
- spec/gviz_spec.rb
|
37
38
|
- spec/spec_helper.rb
|
39
|
+
- spec/system_extension_spec.rb
|
38
40
|
homepage: https://github.com/melborne/Gviz
|
39
41
|
licenses: []
|
40
42
|
post_install_message:
|
@@ -62,4 +64,5 @@ summary: Ruby's interface of graphviz. It generate a dot file with simple ruby's
|
|
62
64
|
test_files:
|
63
65
|
- spec/gviz_spec.rb
|
64
66
|
- spec/spec_helper.rb
|
67
|
+
- spec/system_extension_spec.rb
|
65
68
|
has_rdoc:
|