rubyvis 0.6.1 → 0.7.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 +5 -5
- data/.travis.yml +6 -6
- data/Gemfile +1 -1
- data/Gemfile.lock +27 -21
- data/History.txt +10 -0
- data/lib/rubyvis.rb +1 -4
- data/lib/rubyvis/mark/panel.rb +1 -1
- data/lib/rubyvis/scene/svg_line.rb +0 -1
- data/lib/rubyvis/scene/svg_panel.rb +3 -0
- data/lib/rubyvis/scene/svg_rule.rb +0 -1
- data/lib/rubyvis/sceneelement.rb +1 -0
- data/lib/rubyvis/version.rb +6 -0
- data/rubyvis.gemspec +1 -2
- data/spec/anchor_spec.rb +11 -11
- data/spec/area_spec.rb +10 -10
- data/spec/bar_spec.rb +13 -13
- data/spec/color_spec.rb +24 -24
- data/spec/dom_spec.rb +77 -77
- data/spec/dot_spec.rb +3 -3
- data/spec/flatten_spec.rb +2 -2
- data/spec/histogram_spec.rb +5 -5
- data/spec/image_spec.rb +2 -2
- data/spec/internal_spec.rb +58 -58
- data/spec/javascript_behaviour_spec.rb +14 -14
- data/spec/label_spec.rb +9 -9
- data/spec/layout_arc_spec.rb +5 -5
- data/spec/layout_cluster_spec.rb +4 -4
- data/spec/layout_grid_spec.rb +5 -5
- data/spec/layout_horizon_spec.rb +5 -5
- data/spec/layout_indent_spec.rb +3 -3
- data/spec/layout_matrix_spec.rb +6 -6
- data/spec/layout_pack_spec.rb +2 -2
- data/spec/layout_partition_spec.rb +4 -4
- data/spec/layout_stack_spec.rb +11 -11
- data/spec/layout_tree_spec.rb +4 -4
- data/spec/layout_treemap_spec.rb +2 -2
- data/spec/line_spec.rb +14 -14
- data/spec/mark_spec.rb +7 -7
- data/spec/nest_spec.rb +3 -3
- data/spec/panel_spec.rb +10 -10
- data/spec/readme_spec.rb +6 -6
- data/spec/ruby_api_spec.rb +4 -4
- data/spec/rule_spec.rb +3 -3
- data/spec/scale_linear_datetime_spec.rb +23 -23
- data/spec/scale_linear_spec.rb +37 -37
- data/spec/scale_log_spec.rb +28 -28
- data/spec/scale_ordinal_spec.rb +21 -21
- data/spec/scale_spec.rb +2 -2
- data/spec/spec_helper.rb +6 -5
- data/spec/vector_spec.rb +8 -8
- data/spec/wedge_spec.rb +4 -4
- data/web/build_site.rb +1 -1
- metadata +4 -4
data/spec/scale_log_spec.rb
CHANGED
@@ -21,27 +21,27 @@ describe Rubyvis::Scale::Log do
|
|
21
21
|
it "domain() implemented equally" do
|
22
22
|
@y.domain(@v1)
|
23
23
|
@rt.evaluate("y.domain(v1)")
|
24
|
-
@y.domain.
|
24
|
+
expect(@y.domain).to eq(@rt.evaluate("y.domain()").to_a)
|
25
25
|
@y.domain(@v1,@v2,@v3)
|
26
26
|
@rt.evaluate("y.domain(v1,v2,v3)")
|
27
|
-
@y.domain.
|
27
|
+
expect(@y.domain).to eq(@rt.evaluate("y.domain()").to_a)
|
28
28
|
end
|
29
29
|
it "scale() implemented equally for complex domain" do
|
30
30
|
@y.domain(@v1,@v2,@v3)
|
31
31
|
@rt.evaluate("y.domain(v1,v2,v3)")
|
32
|
-
@y.scale(@v1+1).
|
33
|
-
@y.scale(@v2+1).
|
34
|
-
@y.scale(@v3+1).
|
32
|
+
expect(@y.scale(@v1+1)).to eq(@rt.evaluate("y(v1+1)"))
|
33
|
+
expect(@y.scale(@v2+1)).to eq(@rt.evaluate("y(v2+1)"))
|
34
|
+
expect(@y.scale(@v3+1)).to eq(@rt.evaluate("y(v3+1)"))
|
35
35
|
end
|
36
36
|
it "invert() implemented equally" do
|
37
37
|
@y.domain(@v1,@v2,@v3)
|
38
38
|
@rt.evaluate("y.domain(v1,v2,v3)")
|
39
|
-
@y.invert(@v1+1).
|
40
|
-
@y.invert(@v2+1).
|
41
|
-
@y.invert(@v3+1).
|
39
|
+
expect(@y.invert(@v1+1)).to eq(@rt.evaluate("y.invert(v1+1)"))
|
40
|
+
expect(@y.invert(@v2+1)).to eq(@rt.evaluate("y.invert(v2+1)"))
|
41
|
+
expect(@y.invert(@v3+1)).to eq(@rt.evaluate("y.invert(v3+1)"))
|
42
42
|
end
|
43
43
|
it "ticks() implemented equally for numbers" do
|
44
|
-
@y.ticks.
|
44
|
+
expect(@y.ticks).to eq(@rt.evaluate("y.ticks()").to_a)
|
45
45
|
|
46
46
|
end
|
47
47
|
it "nice() implemented equally" do
|
@@ -49,7 +49,7 @@ describe Rubyvis::Scale::Log do
|
|
49
49
|
@rt.evaluate("y.domain(v1,v2)")
|
50
50
|
@y.nice
|
51
51
|
@rt.evaluate("y.nice()")
|
52
|
-
@y.domain.
|
52
|
+
expect(@y.domain).to eq(@rt.evaluate("y.domain()").to_a)
|
53
53
|
end
|
54
54
|
|
55
55
|
end
|
@@ -66,35 +66,35 @@ describe Rubyvis::Scale::Log do
|
|
66
66
|
@y = Rubyvis.Scale.log(1, @h_dom).range(1,@h)
|
67
67
|
end
|
68
68
|
it "y should be a Scale" do
|
69
|
-
@y.
|
69
|
+
expect(@y).to be_a(Rubyvis::Scale::Log)
|
70
70
|
end
|
71
71
|
it "should respond to domain" do
|
72
|
-
@y.domain.
|
72
|
+
expect(@y.domain).to eq([1, 1000])
|
73
73
|
@y.domain(1)
|
74
|
-
@y.domain.
|
74
|
+
expect(@y.domain).to eq([1,1])
|
75
75
|
@y.domain(1,100,300)
|
76
|
-
@y.domain.
|
76
|
+
expect(@y.domain).to eq([1,100,300])
|
77
77
|
end
|
78
78
|
it "should respond to range" do
|
79
|
-
@y.range.
|
79
|
+
expect(@y.range).to eq([1, 280])
|
80
80
|
@y.range(1)
|
81
|
-
@y.range.
|
81
|
+
expect(@y.range).to eq([1,1])
|
82
82
|
@y.range(1,100,300)
|
83
|
-
@y.range.
|
83
|
+
expect(@y.range).to eq([1,100,300])
|
84
84
|
end
|
85
85
|
it "should returns correct scale" do
|
86
|
-
@y.scale(@h_dom).
|
87
|
-
@y[@h_dom].
|
86
|
+
expect(@y.scale(@h_dom)).to eq(280)
|
87
|
+
expect(@y[@h_dom]).to eq(280)
|
88
88
|
val=20
|
89
|
-
@y.scale(val).
|
89
|
+
expect(@y.scale(val)).to be_within( 0.001).of(121.995)
|
90
90
|
end
|
91
91
|
it "should returns correct invert" do
|
92
|
-
@y.invert(100).
|
93
|
-
@y.invert(200).
|
92
|
+
expect(@y.invert(100)).to be_within( 0.001).of(11.601)
|
93
|
+
expect(@y.invert(200)).to be_within( 0.001).of(137.970)
|
94
94
|
end
|
95
95
|
it "should returns correct ticks" do
|
96
96
|
t=1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100,200,300,400,500,600,700,800,900,1000
|
97
|
-
@y.ticks.
|
97
|
+
expect(@y.ticks).to eq(t)
|
98
98
|
end
|
99
99
|
it "should return :ArgumentError on domain that includes 0 or less" do
|
100
100
|
h=280
|
@@ -104,17 +104,17 @@ describe Rubyvis::Scale::Log do
|
|
104
104
|
end
|
105
105
|
it "should returns correct ticks with subdivisions" do
|
106
106
|
t=1,5,10,50,100,500,1000
|
107
|
-
@y.ticks(2).
|
107
|
+
expect(@y.ticks(2)).to eq(t)
|
108
108
|
t=1,2.5,5,7.5,10,25,50,75,100,250,500,750,1000
|
109
|
-
@y.ticks(4).
|
109
|
+
expect(@y.ticks(4)).to eq(t)
|
110
110
|
t=1,2,4,6,8,10,20,40,60,80,100,200,400,600,800,1000
|
111
|
-
@y.ticks(5).
|
111
|
+
expect(@y.ticks(5)).to eq(t)
|
112
112
|
t=1,10,100,1000
|
113
|
-
@y.ticks(1).
|
113
|
+
expect(@y.ticks(1)).to eq(t)
|
114
114
|
end
|
115
115
|
it "should nice nicely" do
|
116
116
|
@y.domain([0.20147987687960267, 0.996679553296417])
|
117
117
|
@y.nice
|
118
|
-
@y.domain().
|
118
|
+
expect(@y.domain()).to eq([0.1,1])
|
119
119
|
end
|
120
120
|
end
|
data/spec/scale_ordinal_spec.rb
CHANGED
@@ -21,17 +21,17 @@ describe Rubyvis::Scale::Ordinal do
|
|
21
21
|
it "domain() implemented equally" do
|
22
22
|
@y.domain(@base[0])
|
23
23
|
@rt.evaluate("y.domain(domain[0])")
|
24
|
-
@y.domain.
|
24
|
+
expect(@y.domain).to eq(@rt.evaluate("y.domain()").to_a)
|
25
25
|
@y.domain(@base[0],@base[1])
|
26
26
|
@rt.evaluate("y.domain(domain[0],domain[1])")
|
27
|
-
@y.domain.
|
27
|
+
expect(@y.domain).to eq(@rt.evaluate("y.domain()").to_a)
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
describe "on ruby domain" do
|
33
33
|
it "should be created as Javascript" do
|
34
|
-
|
34
|
+
expect {y = Rubyvis.Scale.ordinal(%w{a b c}).range(%w{red blue black})}.not_to raise_exception
|
35
35
|
end
|
36
36
|
|
37
37
|
before do
|
@@ -40,45 +40,45 @@ describe Rubyvis::Scale::Ordinal do
|
|
40
40
|
@y = Rubyvis.Scale.ordinal(@domain).range(@range)
|
41
41
|
end
|
42
42
|
it "y should be a Scale::Ordinal" do
|
43
|
-
@y.
|
43
|
+
expect(@y).to be_a(Rubyvis::Scale::Ordinal)
|
44
44
|
end
|
45
45
|
it "should respond to domain" do
|
46
|
-
@y.domain.
|
46
|
+
expect(@y.domain).to eq(%w{a b c})
|
47
47
|
@y.domain(%w{a})
|
48
|
-
@y.domain.
|
48
|
+
expect(@y.domain).to eq(%w{a})
|
49
49
|
@y.domain(1,100,300)
|
50
|
-
@y.domain.
|
50
|
+
expect(@y.domain).to eq([1,100,300])
|
51
51
|
end
|
52
52
|
it "should respond to range" do
|
53
|
-
@y.range.
|
53
|
+
expect(@y.range).to eq(@range.map {|c| pv.color(c)})
|
54
54
|
@y.range('red')
|
55
|
-
@y.range.
|
55
|
+
expect(@y.range).to eq([pv.color('red')])
|
56
56
|
@y.range('black','white')
|
57
|
-
@y.range.
|
57
|
+
expect(@y.range).to eq([pv.color('black'), pv.color('white')])
|
58
58
|
end
|
59
59
|
it "should returns correct scale with unknown values" do
|
60
|
-
@y.scale(1).
|
61
|
-
@y.scale('x').
|
62
|
-
@y.scale(9).
|
63
|
-
@y.scale(1).
|
60
|
+
expect(@y.scale(1)).to eq(pv.color('red'))
|
61
|
+
expect(@y.scale('x')).to eq(pv.color('white'))
|
62
|
+
expect(@y.scale(9)).to eq(pv.color('blue'))
|
63
|
+
expect(@y.scale(1)).to eq(pv.color('red'))
|
64
64
|
end
|
65
65
|
it "should return the same using [] and scale()" do
|
66
66
|
a=rand()
|
67
|
-
@y[a].
|
67
|
+
expect(@y[a]).to eq(@y.scale(a))
|
68
68
|
end
|
69
69
|
it "should returns correct scale with known values" do
|
70
|
-
@y.scale('a').
|
71
|
-
@y.scale('b').
|
72
|
-
@y.scale('c').
|
70
|
+
expect(@y.scale('a')).to eq(pv.color('red'))
|
71
|
+
expect(@y.scale('b')).to eq(pv.color('white'))
|
72
|
+
expect(@y.scale('c')).to eq(pv.color('blue'))
|
73
73
|
end
|
74
74
|
it "should return correct by" do
|
75
75
|
@y = Rubyvis.Scale.ordinal(@domain).range(@range).by(lambda {|v| v.nombre})
|
76
76
|
a=OpenStruct.new({:nombre=>'c'})
|
77
77
|
b=OpenStruct.new({:nombre=>'b'})
|
78
78
|
c=OpenStruct.new({:nombre=>'a'})
|
79
|
-
@y.call(a).
|
80
|
-
@y.call(b).
|
81
|
-
@y.call(c).
|
79
|
+
expect(@y.call(a)).to eq(pv.color('blue'))
|
80
|
+
expect(@y.call(b)).to eq(pv.color('white'))
|
81
|
+
expect(@y.call(c)).to eq(pv.color('red'))
|
82
82
|
|
83
83
|
end
|
84
84
|
end
|
data/spec/scale_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
|
|
2
2
|
describe Rubyvis::Scale do
|
3
3
|
it "should return a correct numeric interpolator" do
|
4
4
|
i=Rubyvis::Scale.interpolator(0,20)
|
5
|
-
i[10].
|
6
|
-
i[20].
|
5
|
+
expect(i[10]).to eq(200)
|
6
|
+
expect(i[20]).to eq(400)
|
7
7
|
end
|
8
8
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -14,6 +14,7 @@ require 'rubyvis'
|
|
14
14
|
require 'pp'
|
15
15
|
require 'nokogiri'
|
16
16
|
|
17
|
+
RSpec::Expectations.configuration.warn_about_potential_false_positives = false
|
17
18
|
|
18
19
|
$PROTOVIS_DIR=File.dirname(__FILE__)+"/../vendor/protovis/src"
|
19
20
|
module Rubyvis
|
@@ -95,11 +96,11 @@ end
|
|
95
96
|
RSpec::Matchers.define :have_svg_attributes do |exp|
|
96
97
|
match do |obs|
|
97
98
|
exp.each {|k,v|
|
98
|
-
obs.attributes[k].
|
99
|
-
obs.attributes[k].value.
|
99
|
+
expect(obs.attributes[k]).to be_truthy
|
100
|
+
expect(obs.attributes[k].value).to eq(v)
|
100
101
|
}
|
101
102
|
end
|
102
|
-
|
103
|
+
failure_message do |obs|
|
103
104
|
"\n#{exp} attributes expected, but xml doesn't contains them \n#{obs.to_s}"
|
104
105
|
end
|
105
106
|
end
|
@@ -197,7 +198,7 @@ RSpec::Matchers.define :have_same_svg_elements do |exp|
|
|
197
198
|
end
|
198
199
|
correct
|
199
200
|
end
|
200
|
-
|
201
|
+
failure_message do |obs|
|
201
202
|
"#{@error[:type]}: #{@error[:exp].to_s} expected, but #{@error[:obs]} retrieved, on #{@error[:attr]} -> #{@error[:i]} : '#{@error[:exp_attr]}' <> '#{@error[:obs_attr]}'"
|
202
203
|
end
|
203
204
|
|
@@ -242,7 +243,7 @@ RSpec::Matchers.define :have_path_data_close_to do |exp|
|
|
242
243
|
}
|
243
244
|
correct
|
244
245
|
end
|
245
|
-
|
246
|
+
failure_message do |obs|
|
246
247
|
obs_array=path_scan(obs.attributes["d"].value)
|
247
248
|
exp_array=path_scan(exp)
|
248
249
|
"\n#{obs_array} path should be equal to \n#{exp_array}"
|
data/spec/vector_spec.rb
CHANGED
@@ -6,31 +6,31 @@ describe Rubyvis::Vector do
|
|
6
6
|
@v2=Rubyvis::Vector.new(@x2,@y2)
|
7
7
|
end
|
8
8
|
it "should return the same as Rubyvis.vector" do
|
9
|
-
Rubyvis.vector(@x1,@y1).
|
9
|
+
expect(Rubyvis.vector(@x1,@y1)).to eq(@v1)
|
10
10
|
end
|
11
11
|
it "method perp" do
|
12
|
-
@v1.perp.
|
12
|
+
expect(@v1.perp).to eq(Rubyvis::Vector.new(-@y1,@x1))
|
13
13
|
end
|
14
14
|
it "method times" do
|
15
15
|
times=rand(10)+1
|
16
|
-
@v1.times(times).
|
16
|
+
expect(@v1.times(times)).to eq(Rubyvis::Vector.new(@x1*times,@y1*times))
|
17
17
|
end
|
18
18
|
it "method length" do
|
19
19
|
l=Math.sqrt(@x1*@x1+@y1*@y1)
|
20
|
-
@v1.length.
|
20
|
+
expect(@v1.length).to eq l
|
21
21
|
end
|
22
22
|
it "method norm" do
|
23
23
|
l=@v1.length
|
24
|
-
@v1.norm.
|
24
|
+
expect(@v1.norm).to eq(@v1.times(1/l.to_f))
|
25
25
|
end
|
26
26
|
it "method plus" do
|
27
|
-
@v1.plus(@v2).
|
27
|
+
expect(@v1.plus(@v2)).to eq(Rubyvis::Vector.new(@x1+@x2,@y1+@y2))
|
28
28
|
end
|
29
29
|
it "method minus" do
|
30
|
-
@v1.minus(@v2).
|
30
|
+
expect(@v1.minus(@v2)).to eq(Rubyvis::Vector.new(@x1-@x2,@y1-@y2))
|
31
31
|
end
|
32
32
|
it "method dot" do
|
33
|
-
@v1.dot(@v2).
|
33
|
+
expect(@v1.dot(@v2)).to eq(@x1*@x2+@y1*@y2)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
data/spec/wedge_spec.rb
CHANGED
@@ -3,10 +3,10 @@ describe Rubyvis::Wedge do
|
|
3
3
|
include Rubyvis::GeneralSpec
|
4
4
|
it "should have correct properties" do
|
5
5
|
props=[:angle, :antialias, :bottom, :cursor, :data, :end_angle, :events, :fill_style, :id, :inner_radius, :left, :line_width, :outer_radius, :reverse, :right, :start_angle, :stroke_style, :title, :top, :visible].inject({}) {|ac, v| ac[v]=true; ac}
|
6
|
-
Rubyvis::Wedge.properties.
|
6
|
+
expect(Rubyvis::Wedge.properties).to eq(props)
|
7
7
|
end
|
8
8
|
it "Rubyvis.Wedge be the same as Rubyvis::Wedge" do
|
9
|
-
Rubyvis.Wedge.
|
9
|
+
expect(Rubyvis.Wedge).to eql Rubyvis::Wedge
|
10
10
|
end
|
11
11
|
it "should render equal to protovis 'wedge-anchor.html' test" do
|
12
12
|
|
@@ -32,7 +32,7 @@ text(lambda {anchors[self.index]})
|
|
32
32
|
|
33
33
|
vis.render();
|
34
34
|
pv_out=fixture_svg_read("wedge_anchor.svg")
|
35
|
-
vis.to_svg.
|
35
|
+
expect(vis.to_svg).to have_same_svg_elements(pv_out)
|
36
36
|
|
37
37
|
end
|
38
38
|
it "should render equal to protovis 'wedge-donut.html' test" do
|
@@ -60,7 +60,7 @@ text(lambda {|d| "%0.2f" % d})
|
|
60
60
|
@vis.render();
|
61
61
|
|
62
62
|
@pv_out=fixture_svg_read("wedge_donut.svg")
|
63
|
-
@vis.to_svg.
|
63
|
+
expect(@vis.to_svg).to have_same_svg_elements(@pv_out)
|
64
64
|
end
|
65
65
|
|
66
66
|
end
|
data/web/build_site.rb
CHANGED
@@ -74,7 +74,7 @@ files.each do |f|
|
|
74
74
|
# Read svg size
|
75
75
|
width=350
|
76
76
|
height=200
|
77
|
-
if File.
|
77
|
+
if File.exist? "examples/#{page.svg_file}"
|
78
78
|
File.open("examples/#{page.svg_file}","r") {|fp|
|
79
79
|
header=fp.gets(">")
|
80
80
|
if header=~/\sheight=['"]([^']+)['"]/
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyvis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Bustos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- lib/rubyvis/sceneelement.rb
|
160
160
|
- lib/rubyvis/transform.rb
|
161
161
|
- lib/rubyvis/vector.rb
|
162
|
+
- lib/rubyvis/version.rb
|
162
163
|
- rubyvis.gemspec
|
163
164
|
- spec/anchor_spec.rb
|
164
165
|
- spec/area_spec.rb
|
@@ -272,8 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
273
|
- !ruby/object:Gem::Version
|
273
274
|
version: 1.3.6
|
274
275
|
requirements: []
|
275
|
-
|
276
|
-
rubygems_version: 2.2.2
|
276
|
+
rubygems_version: 3.0.1
|
277
277
|
signing_key:
|
278
278
|
specification_version: 4
|
279
279
|
summary: Rubyvis
|