rubyvis 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ === 0.6.0 / 2013-07-10
2
+ + Added support for dashed lines (ex.: stroke_dasharray('9,5,3'))
3
+ - Raises an exception on log scale when domain includes 0 or negative values
4
+
1
5
  === 0.5.2 / 2012-07-21
2
6
 
3
7
  - Fixed image bug (#13), and updated example for image. Web creation is updated, too
@@ -106,6 +106,8 @@ lib/rubyvis/scene/svg_wedge.rb
106
106
  lib/rubyvis/sceneelement.rb
107
107
  lib/rubyvis/transform.rb
108
108
  lib/rubyvis/vector.rb
109
+ lib/rspec/expectations/differ.rb
110
+ lib/rspec/expectations/differ_spec.rb
109
111
  spec/anchor_spec.rb
110
112
  spec/area_spec.rb
111
113
  spec/bar_spec.rb
data/README.txt CHANGED
@@ -37,7 +37,7 @@ Using protovis examples[http://vis.stanford.edu/protovis/ex/] as reference
37
37
  * Arc
38
38
  * Matrix
39
39
 
40
- I try to maintain, when posible, complete compatibility with Javascript API, including camel case naming of functions. Johnson [http://github.com/jbarnette/johnson] - the lovely Javascript wrapper inside Ruby embrace - is our friend to test implementation of basic object.
40
+ I try to maintain, when posible, complete compatibility with Javascript API, including camel case naming of functions.
41
41
 
42
42
  User could use +pv+ freely, cause is defined as a global method which call Rubyvis.
43
43
 
data/Rakefile CHANGED
@@ -7,16 +7,18 @@ require 'hoe'
7
7
  require 'rubyvis'
8
8
  require 'rspec'
9
9
  require 'rspec/core/rake_task'
10
+ require './lib/rspec/expectations/differ'
10
11
  require 'rubyforge'
11
12
 
12
13
  Hoe.plugin :git
14
+ Hoe.plugin :gemspec
13
15
 
14
16
  h=Hoe.spec 'rubyvis' do
15
17
  self.testlib=:rspec
16
18
  self.rspec_options << "-c" << "-b"
17
19
  self.developer('Claudio Bustos', 'clbustos_at_gmail.com')
18
20
  self.version=Rubyvis::VERSION
19
- self.extra_dev_deps << ["coderay",">=0"] << ["haml",">=0"] << ["nokogiri", ">=0"] << ["rspec",">=2.0"] << ["RedCloth",">=0"]
21
+ self.extra_dev_deps << ["coderay",">=0"] << ["haml",">=0"] << ["nokogiri", ">=0"] << ["rspec",">=2.7"] << ["RedCloth",">=0"]
20
22
  end
21
23
  desc "Publicar docs en rubyforge"
22
24
  task :publicar_docs => [:clean, :docs] do
@@ -0,0 +1,73 @@
1
+ # Borrowed from:
2
+ # https://github.com/pcreux/rspec-expectations/commit/b5f8d5ab7c9a3e8d470c6ec3241179be0b78f3ac#diff-1
3
+
4
+ require 'diff/lcs'
5
+ require 'diff/lcs/hunk'
6
+ require 'pp'
7
+
8
+ module RSpec
9
+ module Expectations
10
+ class Differ
11
+
12
+
13
+ # This is snagged from diff/lcs/ldiff.rb (which is a commandline tool)
14
+ def diff_as_string(data_new, data_old)
15
+ data_old = data_old.split(/\n/).map! { |e| e.chomp }
16
+ data_new = data_new.split(/\n/).map! { |e| e.chomp }
17
+ output = ""
18
+ diffs = Diff::LCS.diff(data_old, data_new)
19
+ return output if diffs.empty?
20
+ oldhunk = hunk = nil
21
+ file_length_difference = 0
22
+ diffs.each do |piece|
23
+ begin
24
+ hunk = Diff::LCS::Hunk.new(
25
+ data_old, data_new, piece, context_lines, file_length_difference
26
+ )
27
+ file_length_difference = hunk.file_length_difference
28
+ next unless oldhunk
29
+ # Hunks may overlap, which is why we need to be careful when our
30
+ # diff includes lines of context. Otherwise, we might print
31
+ # redundant lines.
32
+ if (context_lines > 0) and hunk.overlaps?(oldhunk)
33
+ hunk.unshift(oldhunk)
34
+ else
35
+ output << oldhunk.diff(format)
36
+ end
37
+ ensure
38
+ oldhunk = hunk
39
+ output << "\n"
40
+ end
41
+ end
42
+ #Handle the last remaining hunk
43
+ output << oldhunk.diff(format) << "\n"
44
+ end
45
+
46
+
47
+ def diff_as_object(actual,expected)
48
+ actual = object_to_string(actual)
49
+ expected = object_to_string(expected)
50
+ diff_as_string(actual, expected)
51
+ end
52
+
53
+ protected
54
+
55
+ def format; :unified; end
56
+ def context_lines; 3; end
57
+
58
+ def object_to_string(object)
59
+ case object
60
+ when Hash
61
+ object.keys.sort_by { |k| k.to_s }.map do |k|
62
+ %(#{PP.singleline_pp(k, "")} => #{PP.singleline_pp(object[k], "")})
63
+ end.join(",\n")
64
+ when String
65
+ object
66
+ else
67
+ PP.pp(object,"")
68
+ end
69
+ end
70
+
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,117 @@
1
+ require 'spec_helper'
2
+ require 'ostruct'
3
+
4
+ module RSpec
5
+ module Fixtures
6
+ class Animal
7
+ def initialize(name,species)
8
+ @name,@species = name,species
9
+ end
10
+
11
+ def inspect
12
+ <<-EOA
13
+ <Animal
14
+ name=#{@name},
15
+ species=#{@species}
16
+ >
17
+ EOA
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ describe "Diff" do
24
+ before(:each) do
25
+ @options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
26
+ @differ = RSpec::Expectations::Differ.new(@options)
27
+ end
28
+
29
+ it "outputs unified diff of two strings" do
30
+ expected="foo\nbar\nzap\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nline\n"
31
+ actual="foo\nzap\nbar\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nanother\nline\n"
32
+ expected_diff= <<'EOD'
33
+
34
+
35
+ @@ -1,6 +1,6 @@
36
+ foo
37
+ -zap
38
+ bar
39
+ +zap
40
+ this
41
+ is
42
+ soo
43
+ @@ -9,6 +9,5 @@
44
+ equal
45
+ insert
46
+ a
47
+ -another
48
+ line
49
+ EOD
50
+
51
+ diff = @differ.diff_as_string(expected, actual)
52
+ diff.should eql(expected_diff)
53
+ end
54
+
55
+ it "outputs unified diff message of two arrays" do
56
+ expected = [ :foo, 'bar', :baz, 'quux', :metasyntactic, 'variable', :delta, 'charlie', :width, 'quite wide' ]
57
+ actual = [ :foo, 'bar', :baz, 'quux', :metasyntactic, 'variable', :delta, 'tango' , :width, 'very wide' ]
58
+
59
+ expected_diff = <<'EOD'
60
+
61
+
62
+ @@ -5,7 +5,7 @@
63
+ :metasyntactic,
64
+ "variable",
65
+ :delta,
66
+ - "tango",
67
+ + "charlie",
68
+ :width,
69
+ - "very wide"]
70
+ + "quite wide"]
71
+ EOD
72
+
73
+
74
+ diff = @differ.diff_as_object(expected,actual)
75
+ diff.should == expected_diff
76
+ end
77
+
78
+ it "outputs unified diff message of two objects" do
79
+ expected = RSpec::Fixtures::Animal.new "bob", "giraffe"
80
+ actual = RSpec::Fixtures::Animal.new "bob", "tortoise"
81
+
82
+ expected_diff = <<'EOD'
83
+
84
+ @@ -1,5 +1,5 @@
85
+ <Animal
86
+ name=bob,
87
+ - species=tortoise
88
+ + species=giraffe
89
+ >
90
+ EOD
91
+
92
+ diff = @differ.diff_as_object(expected,actual)
93
+ diff.should == expected_diff
94
+ end
95
+
96
+ it "outputs unified diff message of two hashes" do
97
+ expected = { :foo => 'bar', :baz => 'quux', :metasyntactic => 'variable', :delta => 'charlie', :width =>'quite wide' }
98
+ actual = { :foo => 'bar', :metasyntactic => 'variable', :delta => 'charlotte', :width =>'quite wide' }
99
+
100
+ expected_diff = <<'EOD'
101
+
102
+ @@ -1,4 +1,5 @@
103
+ -:delta => "charlotte",
104
+ +:baz => "quux",
105
+ +:delta => "charlie",
106
+ :foo => "bar",
107
+ :metasyntactic => "variable",
108
+ :width => "quite wide"
109
+ EOD
110
+
111
+
112
+ diff = @differ.diff_as_object(expected,actual)
113
+ diff.should == expected_diff
114
+ end
115
+
116
+ end
117
+
@@ -34,7 +34,7 @@ require 'rubyvis/mark/shorcut_methods'
34
34
  module Rubyvis
35
35
  @@nokogiri=nil
36
36
  # Rubyvis version
37
- VERSION = '0.5.2'
37
+ VERSION = '0.6.0'
38
38
  # Protovis API on which current Rubyvis is based
39
39
  PROTOVIS_API_VERSION='3.3'
40
40
  # You actually can do it! http://snipplr.com/view/2137/uses-for-infinity-in-ruby/
@@ -12,6 +12,7 @@ module Rubyvis
12
12
  :stroke_style=> true,
13
13
  :fill_style=> true,
14
14
  :segmented=> true,
15
+ :stroke_dasharray => true, # SVG strokeDasharray (Jamie Love protovis mod)
15
16
  :interpolate=> true,
16
17
  :tension=> true
17
18
  }
@@ -201,7 +202,7 @@ module Rubyvis
201
202
 
202
203
 
203
204
 
204
- attr_accessor_dsl :width, :height, :line_width, [:stroke_style, lambda {|d| Rubyvis.color(d)}], [:fill_style, lambda {|d| Rubyvis.color(d)}], :segmented, :interpolate, :tension
205
+ attr_accessor_dsl :width, :height, :line_width, [:stroke_style, lambda {|d| Rubyvis.color(d)}], [:fill_style, lambda {|d| Rubyvis.color(d)}], :segmented, :stroke_dasharray, :interpolate, :tension
205
206
  def type
206
207
  'area'
207
208
  end
@@ -94,7 +94,7 @@ module Rubyvis
94
94
  # See {CSS3 text}[http://www.w3.org/TR/css3-text/#text-decoration]
95
95
 
96
96
 
97
- attr_accessor_dsl :text, :font, :text_angle, [:text_style, lambda {|d| Rubyvis.color(d)}], :text_align, :text_baseline, :text_margin, :text_decoration, :text_shadow
97
+ attr_accessor_dsl :text, :font, :text_angle, [:text_style, lambda {|d| Rubyvis.color(d)}], :text_align, :text_baseline, :text_margin, :text_decoration, :text_shadow, :font_family, :font_style, :font_variant, :font_weight, :font_size
98
98
  # Mark type
99
99
  def type
100
100
  'label'
@@ -73,7 +73,13 @@ module Rubyvis
73
73
  # Whether the line is segmented; whether variations in stroke style, line width and the other properties are treated as fixed. Rendering segmented lines is noticeably slower than non-segmented lines.
74
74
  # <p>This property is <i>fixed</i>. See Rubyvis.Mark
75
75
 
76
+
77
+ ##
78
+ # :attr: stroke_dasharray
79
+ # Whether the line is dashed using the strokeDasharray SVG property.
80
+ # <p>This property is <i>fixed</i>. See Rubyvis.Mark
76
81
 
82
+
77
83
  ##
78
84
  # :attr: interpolate
79
85
  # How to interpolate between values. Linear interpolation ("linear") is the
@@ -105,7 +111,7 @@ module Rubyvis
105
111
  #
106
112
  # <p>This property is <i>fixed</i>. See Rubyvis.Mark
107
113
 
108
- attr_accessor_dsl :line_width, :line_join, [:stroke_style, lambda {|d| Rubyvis.color(d)}], [:fill_style, lambda {|d| Rubyvis.color(d)}], :segmented, :interpolate, :eccentricity, :tension
114
+ attr_accessor_dsl :line_width, :line_join, [:stroke_style, lambda {|d| Rubyvis.color(d)}], [:fill_style, lambda {|d| Rubyvis.color(d)}], :stroke_dasharray, :segmented, :interpolate, :eccentricity, :tension
109
115
  # Type of line
110
116
  def type
111
117
  "line"
@@ -146,7 +152,14 @@ module Rubyvis
146
152
 
147
153
  def self.defaults
148
154
  a=Rubyvis::Colors.category10()
149
- Line.new.mark_extend(Mark.defaults).line_join('miter').line_width(1.5).stroke_style( lambda { a.scale(parent.index)}).interpolate('linear').eccentricity(0).tension(0.7)
155
+ Line.new.mark_extend(Mark.defaults).
156
+ line_join('miter').
157
+ line_width(1.5).
158
+ stroke_style( lambda { a.scale(parent.index)}).
159
+ stroke_dasharray('').
160
+ interpolate('linear').
161
+ eccentricity(0).
162
+ tension(0.7)
150
163
  end
151
164
  end
152
165
  end
@@ -6,7 +6,7 @@ module Rubyvis
6
6
  class Rule < Mark
7
7
  include LinePrototype
8
8
  @properties=Mark.properties.dup
9
- attr_accessor_dsl :width, :height, :line_width, [:stroke_style, lambda {|d| Rubyvis.color(d)}]
9
+ attr_accessor_dsl :width, :height, :line_width, [:stroke_style, lambda {|d| Rubyvis.color(d)}], :stroke_dasharray
10
10
  def self.defaults
11
11
  Rule.new.mark_extend(Mark.defaults).line_width(1).stroke_style('black').antialias(false)
12
12
  end
@@ -3,9 +3,9 @@ module Rubyvis
3
3
  class Scale::Log < Rubyvis::Scale::Quantitative
4
4
  def initialize(*args)
5
5
  super(*args)
6
+ raise(ArgumentError,"left side of domain should be >0") if(@d.first<=0)
6
7
  @b=nil
7
8
  @_p=nil
8
-
9
9
  base(10)
10
10
  end
11
11
  def log(x)
@@ -37,7 +37,7 @@ module Rubyvis
37
37
  d = domain
38
38
  n = d[0] < 0
39
39
  subdivisions||=@b
40
- span=@b.to_f/subdivisions
40
+ span=@b.to_f / subdivisions
41
41
  # puts "dom: #{d[0]} -> #{n}"
42
42
 
43
43
  i = (n ? -log(-d[0]) : log(d[0])).floor
@@ -41,7 +41,14 @@ module Rubyvis
41
41
  "fill-opacity"=> fill.opacity==0 ? nil : fill.opacity,
42
42
  "text-anchor"=> anchor
43
43
  }, {
44
- "font"=> s.font, "text-shadow"=> s.text_shadow, "text-decoration"=> s.text_decoration})
44
+ "font"=> s.font,
45
+ "font-family"=> s.font_family.nil? ? nil : s.font_family,
46
+ "font-style"=> s.font_style.nil? ? nil: s.font_style,
47
+ "font-variant"=> s.font_variant.nil? ? nil : s.font_variant,
48
+ "font-weight"=> s.font_weight.nil? ? nil: s.font_weight,
49
+ "font-size"=> s.font_size.nil? ? nil: s.font_size,
50
+ "text-shadow"=> s.text_shadow,
51
+ "text-decoration"=> s.text_decoration})
45
52
 
46
53
  e.text=s.text.frozen? ? s.text.dup : s.text
47
54
 
@@ -43,6 +43,7 @@ module Rubyvis
43
43
  "fill-opacity"=> (fill.opacity==0.0) ? nil : fill.opacity,
44
44
  "stroke"=> stroke.color,
45
45
  "stroke-opacity"=> (stroke.opacity==0.0) ? nil : stroke.opacity,
46
+ "stroke-dasharray"=> s.stroke_dasharray, # strokeDasharray from Jamie Love (protovis mod)
46
47
  "stroke-width"=> (stroke.opacity>0) ? s.line_width / self.scale : nil,
47
48
  "stroke-linejoin"=> s.line_join
48
49
  });
@@ -17,6 +17,7 @@ module Rubyvis
17
17
  'y2'=>s.top+s.height,
18
18
  "stroke"=> stroke.color,
19
19
  "stroke-opacity"=> stroke.opacity,
20
+ "stroke-dasharray"=> s.stroke_dasharray,
20
21
  "stroke-width"=> s.line_width / self.scale
21
22
  })
22
23
 
@@ -8,7 +8,99 @@ module Rubyvis
8
8
  end
9
9
  include Enumerable
10
10
  attr_accessor :visible
11
- attr_accessor :mark, :type, :child_index, :parent, :parent_index, :target, :defs, :data, :antialias, :line_width, :fill_style, :overflow, :width, :height, :top, :bottom, :left, :right, :title, :reverse, :stroke_style, :transform, :canvas, :_g, :events, :cursor, :children, :id, :segmented, :interpolate, :tension, :name, :text_baseline, :text_align, :text, :font, :text_angle, :text_style, :text_margin, :text_decoration, :text_shadow, :line_join, :eccentricity, :shape_size, :shape, :shape_angle, :shape_radius, :start_angle, :end_angle, :angle, :inner_radius, :outer_radius, :layers, :orient, :offset, :order,:url, :image_width, :image_height, :image, :_id, :nodes, :round, :links, :padding_left, :padding_right, :padding_top, :padding_bottom, :mode, :group, :depth, :breadth, :spacing, :rows, :cols, :_grid,:bands, :background_style, :positive_style, :negative_style,:directed, :_matrix
11
+
12
+ ## ACCESSOR
13
+ ## If you implement new accessor on a scene element
14
+ ## you should add it here
15
+
16
+ attr_accessor :_g
17
+ attr_accessor :_grid
18
+ attr_accessor :_id
19
+ attr_accessor :_matrix
20
+ attr_accessor :angle
21
+ attr_accessor :antialias
22
+ attr_accessor :background_style
23
+ attr_accessor :bands
24
+ attr_accessor :bottom
25
+ attr_accessor :breadth
26
+ attr_accessor :canvas
27
+ attr_accessor :child_index
28
+ attr_accessor :children
29
+ attr_accessor :cols
30
+ attr_accessor :cursor
31
+ attr_accessor :data
32
+ attr_accessor :defs
33
+ attr_accessor :depth
34
+ attr_accessor :directed
35
+ attr_accessor :eccentricity
36
+ attr_accessor :end_angle
37
+ attr_accessor :events
38
+ attr_accessor :fill_style
39
+ attr_accessor :font
40
+ attr_accessor :font_family
41
+ attr_accessor :font_size
42
+ attr_accessor :font_style
43
+ attr_accessor :font_variant
44
+ attr_accessor :font_weight
45
+ attr_accessor :group
46
+ attr_accessor :height
47
+ attr_accessor :id
48
+ attr_accessor :image
49
+ attr_accessor :image_height
50
+ attr_accessor :image_width
51
+ attr_accessor :inner_radius
52
+ attr_accessor :interpolate
53
+ attr_accessor :layers
54
+ attr_accessor :left
55
+ attr_accessor :line_join
56
+ attr_accessor :line_width
57
+ attr_accessor :links
58
+ attr_accessor :mark
59
+ attr_accessor :mode
60
+ attr_accessor :name
61
+ attr_accessor :negative_style
62
+ attr_accessor :nodes
63
+ attr_accessor :offset
64
+ attr_accessor :order
65
+ attr_accessor :orient
66
+ attr_accessor :outer_radius
67
+ attr_accessor :overflow
68
+ attr_accessor :padding_bottom
69
+ attr_accessor :padding_left
70
+ attr_accessor :padding_right
71
+ attr_accessor :padding_top
72
+ attr_accessor :parent
73
+ attr_accessor :parent_index
74
+ attr_accessor :positive_style
75
+ attr_accessor :reverse
76
+ attr_accessor :right
77
+ attr_accessor :round
78
+ attr_accessor :rows
79
+ attr_accessor :segmented
80
+ attr_accessor :shape
81
+ attr_accessor :shape_angle
82
+ attr_accessor :shape_radius
83
+ attr_accessor :shape_size
84
+ attr_accessor :spacing
85
+ attr_accessor :start_angle
86
+ attr_accessor :stroke_dasharray
87
+ attr_accessor :stroke_style
88
+ attr_accessor :target
89
+ attr_accessor :tension
90
+ attr_accessor :text
91
+ attr_accessor :text_align
92
+ attr_accessor :text_angle
93
+ attr_accessor :text_baseline
94
+ attr_accessor :text_decoration
95
+ attr_accessor :text_margin
96
+ attr_accessor :text_shadow
97
+ attr_accessor :text_style
98
+ attr_accessor :title
99
+ attr_accessor :top
100
+ attr_accessor :transform
101
+ attr_accessor :type
102
+ attr_accessor :url
103
+ attr_accessor :width
12
104
 
13
105
  def []=(v,i)
14
106
  if v.is_a? Numeric
@@ -1,8 +1,9 @@
1
+ require File.expand_path(File.dirname(__FILE__)+"/../lib/rspec/expectations/differ.rb")
1
2
  require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
2
3
  describe Rubyvis::Area do
3
4
  include Rubyvis::GeneralSpec
4
5
  it "should have correct properties" do
5
- props=[:antialias, :bottom, :cursor, :data, :events, :fill_style, :height, :id, :interpolate, :left, :line_width, :reverse, :right, :segmented, :stroke_style, :tension, :title, :top, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
6
+ props=[:antialias, :bottom, :cursor, :data, :events, :fill_style, :height, :id, :interpolate, :left, :line_width, :reverse, :right, :segmented, :stroke_dasharray, :stroke_style, :tension, :title, :top, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
6
7
  Rubyvis::Area.properties.should==props
7
8
  end
8
9
  it "Rubyvis.Area be the same as Rubyvis::Area" do
@@ -140,4 +141,4 @@ top(5)
140
141
  doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0 180Q16 160 20 160C26 160 34 186 40 180S54 120 60 120S74 183 80 180Q84 178 100 100L100 200Q84 200 80 200C74 200 66 200 60 200S46 200 40 200S26 200 20 200Q16 200 0 200Z"
141
142
  end
142
143
  end
143
- end
144
+ end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
2
2
  describe Rubyvis::Label do
3
3
  it "should have correct properties" do
4
- props=[:antialias, :bottom, :cursor, :data, :events, :font, :id, :left, :reverse, :right, :text, :text_align, :text_angle, :text_baseline, :text_decoration, :text_margin, :text_shadow, :text_style, :title, :top, :visible].inject({}) {|ac, v| ac[v]=true; ac}
4
+ props=[:antialias, :bottom, :cursor, :data, :events, :font, :font_family, :font_style, :font_variant, :font_weight, :font_size, :id, :left, :reverse, :right, :text, :text_align, :text_angle, :text_baseline, :text_decoration, :text_margin, :text_shadow, :text_style, :title, :top, :visible].inject({}) {|ac, v| ac[v]=true; ac}
5
5
 
6
6
  Rubyvis::Label.properties.should==props
7
7
  end
@@ -18,24 +18,36 @@ require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
18
18
  context "on a Panel" do
19
19
  before do
20
20
  #Rubyvis.clear_document
21
- @h=100
22
- @w=200
23
- @vis = Rubyvis.Panel.new.width(@w).height(@h)
24
- @vis.add(pv.Bar).data([1,2]).width(20).height(lambda {|d| d * 80}).bottom(0).left(lambda {self.index * 25}).add(pv.Label)
21
+ @h=100
22
+ @w=200
23
+ @vis = Rubyvis.Panel.new.width(@w).height(@h)
24
+ @bar=@vis.add(pv.Bar).data([1,2]).width(20).height(lambda {|d| d * 80}).bottom(0).left(lambda {self.index * 25})
25
+ @label=@bar.add(pv.Label)
25
26
  end
26
- it "should bould propertly" do
27
+ it "should bould properly with font_size" do
28
+ @label.font_size('20px')
29
+ @vis.render
30
+ s=@vis.to_svg
31
+ doc=Nokogiri::XML(s)
32
+ #p doc.at_xpath("//xmlns:text")
33
+ doc.at_xpath("//xmlns:text").attributes['style'].value.should=='font-size:20px'
34
+ end
35
+
36
+ it "should bould basic stuff properly " do
27
37
  @vis.render
28
38
  s=@vis.to_svg
29
39
  #p s
30
40
  #File.open("test.svg","w") {|f| f.puts s}
31
41
 
32
42
  doc=Nokogiri::XML(s)
43
+ #p doc.at_xpath("//xmlns:text")
33
44
 
34
45
  attribs=doc.xpath("//xmlns:text").map {|v|
35
46
  [v.attributes['y'].value, v.attributes['transform'].value, v.text] }
36
47
  attribs.should==[["-3","translate(0,100)","1"],["-3","translate(25,100)","2"]]
37
- end
48
+ end
49
+
38
50
  end
39
51
 
40
52
 
41
- end
53
+ end
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
2
2
  describe Rubyvis::Line do
3
3
  include Rubyvis::GeneralSpec
4
4
  it "should have correct properties" do
5
- props=[:antialias, :bottom, :cursor, :data, :eccentricity, :events, :fill_style, :id, :interpolate, :left, :line_join, :line_width, :reverse, :right, :segmented, :stroke_style, :tension, :title, :top, :visible].inject({}) {|ac, v| ac[v]=true; ac}
5
+ props=[:antialias, :bottom, :cursor, :data, :eccentricity, :events, :fill_style, :id, :interpolate, :left, :line_join, :line_width, :reverse, :right, :segmented, :stroke_dasharray, :stroke_style, :tension, :title, :top, :visible].inject({}) {|ac, v| ac[v]=true; ac}
6
6
  Rubyvis::Line.properties.should==props
7
7
  end
8
8
  it "should render correctly 'line_interpolation.html' example" do
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
2
2
  describe Rubyvis::Rule do
3
3
  include Rubyvis::GeneralSpec
4
4
  it "should have correct properties" do
5
- props=[:antialias, :bottom, :cursor, :data, :events, :height, :id, :left, :line_width, :reverse, :right, :stroke_style, :title, :top, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
5
+ props=[:antialias, :bottom, :cursor, :data, :events, :height, :id, :left, :line_width, :reverse, :right, :stroke_style, :stroke_dasharray, :title, :top, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
6
6
  Rubyvis::Rule.properties.should==props
7
7
  end
8
8
  it "Rubyvis.Rule be the same as Rubyvis::Rule" do
@@ -30,4 +30,4 @@ describe Rubyvis::Rule do
30
30
  vis.to_svg.should have_same_svg_elements(pv_out)
31
31
  end
32
32
 
33
- end
33
+ end
@@ -96,6 +96,12 @@ describe Rubyvis::Scale::Log 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
97
  @y.ticks.should==t
98
98
  end
99
+ it "should return :ArgumentError on domain that includes 0 or less" do
100
+ h=280
101
+ h_dom=1000
102
+ expect {Rubyvis.Scale.log(-1, @h_dom)}.to raise_error(ArgumentError)
103
+
104
+ end
99
105
  it "should returns correct ticks with subdivisions" do
100
106
  t=1,5,10,50,100,500,1000
101
107
  @y.ticks(2).should==t
@@ -111,4 +117,4 @@ describe Rubyvis::Scale::Log do
111
117
  @y.nice
112
118
  @y.domain().should==[0.1,1]
113
119
  end
114
- end
120
+ end
File without changes
File without changes
@@ -1,6 +1,7 @@
1
1
  !!!
2
2
  %html
3
3
  %head
4
+ %meta{"http-equiv"=>"Content-Type", :content=>"text/html", :charset=>"UTF-8"}
4
5
  %link{:type=>"text/css", :rel=>"stylesheet", :href=>"../style.css"}
5
6
  %title="Rubyvis - Example: #{title}"
6
7
  %body
@@ -1,6 +1,7 @@
1
1
  !!!
2
2
  %html
3
3
  %head
4
+ %meta{"http-equiv"=>"Content-Type", :content=>"text/html", :charset=>"UTF-8"}
4
5
  %link{:type=>"text/css", :rel=>"stylesheet", :href=>"style.css"}
5
6
  %title Rubyvis: Ruby version of Protovis
6
7
  %body
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyvis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
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-07-21 00:00:00.000000000 Z
12
+ date: 2013-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - ! '>='
84
84
  - !ruby/object:Gem::Version
85
- version: '2.0'
85
+ version: '2.7'
86
86
  type: :development
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  requirements:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
- version: '2.0'
93
+ version: '2.7'
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: RedCloth
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +114,7 @@ dependencies:
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: '3.0'
117
+ version: '3.3'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: '3.0'
125
+ version: '3.3'
126
126
  description: Ruby port of Protovis[http://vis.stanford.edu/protovis/], a Javascript
127
127
  visualization toolkit.
128
128
  email:
@@ -242,6 +242,8 @@ files:
242
242
  - lib/rubyvis/sceneelement.rb
243
243
  - lib/rubyvis/transform.rb
244
244
  - lib/rubyvis/vector.rb
245
+ - lib/rspec/expectations/differ.rb
246
+ - lib/rspec/expectations/differ_spec.rb
245
247
  - spec/anchor_spec.rb
246
248
  - spec/area_spec.rb
247
249
  - spec/bar_spec.rb