rubyvis 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +6 -6
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +27 -21
  5. data/History.txt +10 -0
  6. data/lib/rubyvis.rb +1 -4
  7. data/lib/rubyvis/mark/panel.rb +1 -1
  8. data/lib/rubyvis/scene/svg_line.rb +0 -1
  9. data/lib/rubyvis/scene/svg_panel.rb +3 -0
  10. data/lib/rubyvis/scene/svg_rule.rb +0 -1
  11. data/lib/rubyvis/sceneelement.rb +1 -0
  12. data/lib/rubyvis/version.rb +6 -0
  13. data/rubyvis.gemspec +1 -2
  14. data/spec/anchor_spec.rb +11 -11
  15. data/spec/area_spec.rb +10 -10
  16. data/spec/bar_spec.rb +13 -13
  17. data/spec/color_spec.rb +24 -24
  18. data/spec/dom_spec.rb +77 -77
  19. data/spec/dot_spec.rb +3 -3
  20. data/spec/flatten_spec.rb +2 -2
  21. data/spec/histogram_spec.rb +5 -5
  22. data/spec/image_spec.rb +2 -2
  23. data/spec/internal_spec.rb +58 -58
  24. data/spec/javascript_behaviour_spec.rb +14 -14
  25. data/spec/label_spec.rb +9 -9
  26. data/spec/layout_arc_spec.rb +5 -5
  27. data/spec/layout_cluster_spec.rb +4 -4
  28. data/spec/layout_grid_spec.rb +5 -5
  29. data/spec/layout_horizon_spec.rb +5 -5
  30. data/spec/layout_indent_spec.rb +3 -3
  31. data/spec/layout_matrix_spec.rb +6 -6
  32. data/spec/layout_pack_spec.rb +2 -2
  33. data/spec/layout_partition_spec.rb +4 -4
  34. data/spec/layout_stack_spec.rb +11 -11
  35. data/spec/layout_tree_spec.rb +4 -4
  36. data/spec/layout_treemap_spec.rb +2 -2
  37. data/spec/line_spec.rb +14 -14
  38. data/spec/mark_spec.rb +7 -7
  39. data/spec/nest_spec.rb +3 -3
  40. data/spec/panel_spec.rb +10 -10
  41. data/spec/readme_spec.rb +6 -6
  42. data/spec/ruby_api_spec.rb +4 -4
  43. data/spec/rule_spec.rb +3 -3
  44. data/spec/scale_linear_datetime_spec.rb +23 -23
  45. data/spec/scale_linear_spec.rb +37 -37
  46. data/spec/scale_log_spec.rb +28 -28
  47. data/spec/scale_ordinal_spec.rb +21 -21
  48. data/spec/scale_spec.rb +2 -2
  49. data/spec/spec_helper.rb +6 -5
  50. data/spec/vector_spec.rb +8 -8
  51. data/spec/wedge_spec.rb +4 -4
  52. data/web/build_site.rb +1 -1
  53. metadata +4 -4
@@ -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.should==@rt.evaluate("y.domain()").to_a
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.should==@rt.evaluate("y.domain()").to_a
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).should==@rt.evaluate("y(v1+1)")
33
- @y.scale(@v2+1).should==@rt.evaluate("y(v2+1)")
34
- @y.scale(@v3+1).should==@rt.evaluate("y(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).should==@rt.evaluate("y.invert(v1+1)")
40
- @y.invert(@v2+1).should==@rt.evaluate("y.invert(v2+1)")
41
- @y.invert(@v3+1).should==@rt.evaluate("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.should==@rt.evaluate("y.ticks()").to_a
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.should==@rt.evaluate("y.domain()").to_a
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.should be_a(Rubyvis::Scale::Log)
69
+ expect(@y).to be_a(Rubyvis::Scale::Log)
70
70
  end
71
71
  it "should respond to domain" do
72
- @y.domain.should==[1, 1000]
72
+ expect(@y.domain).to eq([1, 1000])
73
73
  @y.domain(1)
74
- @y.domain.should==[1,1]
74
+ expect(@y.domain).to eq([1,1])
75
75
  @y.domain(1,100,300)
76
- @y.domain.should==[1,100,300]
76
+ expect(@y.domain).to eq([1,100,300])
77
77
  end
78
78
  it "should respond to range" do
79
- @y.range.should==[1, 280]
79
+ expect(@y.range).to eq([1, 280])
80
80
  @y.range(1)
81
- @y.range.should==[1,1]
81
+ expect(@y.range).to eq([1,1])
82
82
  @y.range(1,100,300)
83
- @y.range.should==[1,100,300]
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).should==280
87
- @y[@h_dom].should==280
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).should be_within( 0.001).of(121.995)
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).should be_within( 0.001).of(11.601)
93
- @y.invert(200).should be_within( 0.001).of(137.970)
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.should==t
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).should==t
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).should==t
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).should==t
111
+ expect(@y.ticks(5)).to eq(t)
112
112
  t=1,10,100,1000
113
- @y.ticks(1).should==t
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().should==[0.1,1]
118
+ expect(@y.domain()).to eq([0.1,1])
119
119
  end
120
120
  end
@@ -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.should==@rt.evaluate("y.domain()").to_a
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.should==@rt.evaluate("y.domain()").to_a
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
- lambda {y = Rubyvis.Scale.ordinal(%w{a b c}).range(%w{red blue black})}.should_not raise_exception
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.should be_a(Rubyvis::Scale::Ordinal)
43
+ expect(@y).to be_a(Rubyvis::Scale::Ordinal)
44
44
  end
45
45
  it "should respond to domain" do
46
- @y.domain.should==%w{a b c}
46
+ expect(@y.domain).to eq(%w{a b c})
47
47
  @y.domain(%w{a})
48
- @y.domain.should==%w{a}
48
+ expect(@y.domain).to eq(%w{a})
49
49
  @y.domain(1,100,300)
50
- @y.domain.should==[1,100,300]
50
+ expect(@y.domain).to eq([1,100,300])
51
51
  end
52
52
  it "should respond to range" do
53
- @y.range.should==@range.map {|c| pv.color(c)}
53
+ expect(@y.range).to eq(@range.map {|c| pv.color(c)})
54
54
  @y.range('red')
55
- @y.range.should==[pv.color('red')]
55
+ expect(@y.range).to eq([pv.color('red')])
56
56
  @y.range('black','white')
57
- @y.range.should==[pv.color('black'), pv.color('white')]
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).should==pv.color('red')
61
- @y.scale('x').should==pv.color('white')
62
- @y.scale(9).should==pv.color('blue')
63
- @y.scale(1).should==pv.color('red')
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].should==@y.scale(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').should==pv.color('red')
71
- @y.scale('b').should==pv.color('white')
72
- @y.scale('c').should==pv.color('blue')
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).should==pv.color('blue')
80
- @y.call(b).should==pv.color('white')
81
- @y.call(c).should==pv.color('red')
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
@@ -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].should==200
6
- i[20].should==400
5
+ expect(i[10]).to eq(200)
6
+ expect(i[20]).to eq(400)
7
7
  end
8
8
  end
@@ -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].should be_truthy
99
- obs.attributes[k].value.should==v
99
+ expect(obs.attributes[k]).to be_truthy
100
+ expect(obs.attributes[k].value).to eq(v)
100
101
  }
101
102
  end
102
- failure_message_for_should do |obs|
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
- failure_message_for_should do |obs|
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
- failure_message_for_should do |obs|
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}"
@@ -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).should== @v1
9
+ expect(Rubyvis.vector(@x1,@y1)).to eq(@v1)
10
10
  end
11
11
  it "method perp" do
12
- @v1.perp.should==Rubyvis::Vector.new(-@y1,@x1)
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).should==Rubyvis::Vector.new(@x1*times,@y1*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.should eq l
20
+ expect(@v1.length).to eq l
21
21
  end
22
22
  it "method norm" do
23
23
  l=@v1.length
24
- @v1.norm.should==@v1.times(1/l.to_f)
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).should==Rubyvis::Vector.new(@x1+@x2,@y1+@y2)
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).should==Rubyvis::Vector.new(@x1-@x2,@y1-@y2)
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).should==@x1*@x2+@y1*@y2
33
+ expect(@v1.dot(@v2)).to eq(@x1*@x2+@y1*@y2)
34
34
  end
35
35
  end
36
36
 
@@ -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.should==props
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.should eql 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.should have_same_svg_elements(pv_out)
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.should have_same_svg_elements(@pv_out)
63
+ expect(@vis.to_svg).to have_same_svg_elements(@pv_out)
64
64
  end
65
65
 
66
66
  end
@@ -74,7 +74,7 @@ files.each do |f|
74
74
  # Read svg size
75
75
  width=350
76
76
  height=200
77
- if File.exists? "examples/#{page.svg_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.6.1
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: 2014-08-07 00:00:00.000000000 Z
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
- rubyforge_project:
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