google_visualr 2.1.5 → 2.1.6

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/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use ruby-1.9.3-p194@google_visualr --create
1
+ rvm use ruby-1.9.3-p327@google_visualr --create
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- google_visualr (2.1.4)
4
+ google_visualr (2.1.6)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.rdoc CHANGED
@@ -96,6 +96,10 @@ Please submit all feedback, bugs and feature-requests to {GitHub Issues Tracker}
96
96
 
97
97
  = Change Log
98
98
 
99
+ <em>Version 2.1.6</em>
100
+ * {Issue 54}[https://github.com/winston/google_visualr/issues/54] Allow apostrophes in labels.
101
+ * {Pull Request 55}[https://github.com/winston/google_visualr/pull/55] Added support to accept BigDecimal as number.
102
+
99
103
  <em>Version 2.1.5</em>
100
104
  * {Pull Request 48}[https://github.com/winston/google_visualr/pull/48] Fixed bug with Listener event registration.
101
105
 
@@ -205,17 +205,13 @@ module GoogleVisualr
205
205
 
206
206
  @cols.each do |column|
207
207
  js << "data_table.addColumn("
208
- if column[:role].nil?
209
- js << column.map{ |key, value| "'#{value}'" }.join(", ")
210
- else
211
- js << "{" + column.map{ |key, value| "#{key}: '#{value}'" }.join(", ") + "}"
212
- end
208
+ js << column.to_json
213
209
  js << ");"
214
210
  end
215
211
 
216
212
  @rows.each do |row|
217
213
  js << "data_table.addRow("
218
- js << "[#{row.collect { |cell| cell.to_js }.join(", ")}]" unless row.empty?
214
+ js << "[#{row.map(&:to_js).join(", ")}]" unless row.empty?
219
215
  js << ");"
220
216
  end
221
217
 
@@ -243,7 +239,7 @@ module GoogleVisualr
243
239
  when type == "string"
244
240
  raise ArgumentError, "cell value '#{v}' is not a String", caller unless v.is_a?(String)
245
241
  when type == "number"
246
- raise ArgumentError, "cell value '#{v}' is not an Integer or a Float", caller unless v.is_a?(Integer) || v.is_a?(Float)
242
+ raise ArgumentError, "cell value '#{v}' is not an Integer, Float or BigDecimal", caller unless v.is_a?(Integer) || v.is_a?(Float) || v.is_a?(BigDecimal)
247
243
  when type == "boolean"
248
244
  raise ArgumentError, "cell value '#{v}' is not a Boolean", caller unless v.is_a?(TrueClass) || v.is_a?(FalseClass)
249
245
  when type == 'datetime'
@@ -1,3 +1,3 @@
1
1
  module GoogleVisualr
2
- VERSION = "2.1.5"
2
+ VERSION = "2.1.6"
3
3
  end
@@ -205,6 +205,12 @@ describe GoogleVisualr::DataTable do
205
205
  it "raises an exception if value is not date" do
206
206
  assert_raises_exception(4, 'ABCD')
207
207
  end
208
+
209
+ it "accepts BigDecimal as number" do
210
+ expect {
211
+ dt.set_cell(0, 1, BigDecimal.new(42))
212
+ }.to_not raise_exception(ArgumentError)
213
+ end
208
214
  end
209
215
 
210
216
  it "accepts 'nil' for all column types" do
@@ -238,21 +244,28 @@ describe GoogleVisualr::DataTable do
238
244
  dt.new_column('number', 'Total', '1')
239
245
  dt.add_row([1])
240
246
 
241
- dt.to_js.should == "var data_table = new google.visualization.DataTable();data_table.addColumn('number', 'Total', '1');data_table.addRow([{v: 1}]);"
247
+ dt.to_js.should == "var data_table = new google.visualization.DataTable();data_table.addColumn({\"type\":\"number\",\"label\":\"Total\",\"id\":\"1\"});data_table.addRow([{v: 1}]);"
242
248
  end
243
249
 
244
250
  it "excludes :id and :label when these are not specified" do
245
251
  dt.new_column('number')
246
252
  dt.add_row([1])
247
253
 
248
- dt.to_js.should == "var data_table = new google.visualization.DataTable();data_table.addColumn('number');data_table.addRow([{v: 1}]);"
254
+ dt.to_js.should == "var data_table = new google.visualization.DataTable();data_table.addColumn({\"type\":\"number\"});data_table.addRow([{v: 1}]);"
249
255
  end
250
256
 
251
257
  it "includes :role and :pattern when these are specified" do
252
258
  dt.new_column('string', nil, nil, 'interval', 'pattern')
253
259
  dt.add_row(['interval'])
254
260
 
255
- dt.to_js.should == "var data_table = new google.visualization.DataTable();data_table.addColumn({type: 'string', role: 'interval', pattern: 'pattern'});data_table.addRow([{v: 'interval'}]);"
261
+ dt.to_js.should == "var data_table = new google.visualization.DataTable();data_table.addColumn({\"type\":\"string\",\"role\":\"interval\",\"pattern\":\"pattern\"});data_table.addRow([{v: 'interval'}]);"
262
+ end
263
+
264
+ it "escapes labels with apostrophes properly" do
265
+ dt.new_column('number', 'Winston\'s')
266
+ dt.add_row([1])
267
+
268
+ dt.to_js.should == "var data_table = new google.visualization.DataTable();data_table.addColumn({\"type\":\"number\",\"label\":\"Winston's\"});data_table.addRow([{v: 1}]);"
256
269
  end
257
270
  end
258
271
 
@@ -20,7 +20,7 @@ end
20
20
  def base_chart_js(div_class="div_class")
21
21
  js = "\n<script type='text/javascript'>"
22
22
  js << "\n google.load('visualization','1', {packages: ['basechart'], callback: function() {"
23
- js << "\n var data_table = new google.visualization.DataTable();data_table.addColumn('string', 'Year');data_table.addColumn('number', 'Sales');data_table.addColumn('number', 'Expenses');data_table.addRow([{v: '2004'}, {v: 1000}, {v: 400}]);data_table.addRow([{v: '2005'}, {v: 1200}, {v: 450}]);data_table.addRow([{v: '2006'}, {v: 1500}, {v: 600}]);data_table.addRow([{v: '2007'}, {v: 800}, {v: 500}]);\n var chart = new google.visualization.BaseChart(document.getElementById('#{div_class}'));"
23
+ js << "\n var data_table = new google.visualization.DataTable();data_table.addColumn({\"type\":\"string\",\"label\":\"Year\"});data_table.addColumn({\"type\":\"number\",\"label\":\"Sales\"});data_table.addColumn({\"type\":\"number\",\"label\":\"Expenses\"});data_table.addRow([{v: '2004'}, {v: 1000}, {v: 400}]);data_table.addRow([{v: '2005'}, {v: 1200}, {v: 450}]);data_table.addRow([{v: '2006'}, {v: 1500}, {v: 600}]);data_table.addRow([{v: '2007'}, {v: 800}, {v: 500}]);\n var chart = new google.visualization.BaseChart(document.getElementById('#{div_class}'));"
24
24
  js << "\n chart.draw(data_table, {legend: 'Test Chart', width: 800, is3D: true});"
25
25
  js << "\n }});"
26
26
  js << "\n</script>"
@@ -29,7 +29,7 @@ end
29
29
  def base_chart_with_listener_js(div_class="div_class")
30
30
  js = "\n<script type='text/javascript'>"
31
31
  js << "\n google.load('visualization','1', {packages: ['basechart'], callback: function() {"
32
- js << "\n var data_table = new google.visualization.DataTable();data_table.addColumn('string', 'Year');data_table.addColumn('number', 'Sales');data_table.addColumn('number', 'Expenses');data_table.addRow([{v: '2004'}, {v: 1000}, {v: 400}]);data_table.addRow([{v: '2005'}, {v: 1200}, {v: 450}]);data_table.addRow([{v: '2006'}, {v: 1500}, {v: 600}]);data_table.addRow([{v: '2007'}, {v: 800}, {v: 500}]);\n var chart = new google.visualization.BaseChart(document.getElementById('#{div_class}'));"
32
+ js << "\n var data_table = new google.visualization.DataTable();data_table.addColumn({\"type\":\"string\",\"label\":\"Year\"});data_table.addColumn({\"type\":\"number\",\"label\":\"Sales\"});data_table.addColumn({\"type\":\"number\",\"label\":\"Expenses\"});data_table.addRow([{v: '2004'}, {v: 1000}, {v: 400}]);data_table.addRow([{v: '2005'}, {v: 1200}, {v: 450}]);data_table.addRow([{v: '2006'}, {v: 1500}, {v: 600}]);data_table.addRow([{v: '2007'}, {v: 800}, {v: 500}]);\n var chart = new google.visualization.BaseChart(document.getElementById('#{div_class}'));"
33
33
  js << "\n google.visualization.events.addListener(chart, 'select', function() {test_event(chart);});"
34
34
  js << "\n chart.draw(data_table, {legend: 'Test Chart', width: 800, is3D: true});"
35
35
  js << "\n }});"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_visualr
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-30 00:00:00.000000000 Z
12
+ date: 2013-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &70104206018240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,15 +21,10 @@ dependencies:
21
21
  version: 1.1.5
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: 1.1.5
24
+ version_requirements: *70104206018240
30
25
  - !ruby/object:Gem::Dependency
31
26
  name: rspec
32
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &70104206017740 !ruby/object:Gem::Requirement
33
28
  none: false
34
29
  requirements:
35
30
  - - ! '>='
@@ -37,15 +32,10 @@ dependencies:
37
32
  version: 2.11.0
38
33
  type: :development
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: 2.11.0
35
+ version_requirements: *70104206017740
46
36
  - !ruby/object:Gem::Dependency
47
37
  name: rails
48
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &70104206017280 !ruby/object:Gem::Requirement
49
39
  none: false
50
40
  requirements:
51
41
  - - ! '>='
@@ -53,12 +43,7 @@ dependencies:
53
43
  version: 3.2.8
54
44
  type: :development
55
45
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: 3.2.8
46
+ version_requirements: *70104206017280
62
47
  description: This Ruby gem, GoogleVisualr, is a wrapper around the Google Chart Tools
63
48
  that allows anyone to create the same beautiful charts with just Ruby; you don't
64
49
  have to write any JavaScript at all.
@@ -187,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
172
  version: 1.3.6
188
173
  requirements: []
189
174
  rubyforge_project: google_visualr
190
- rubygems_version: 1.8.24
175
+ rubygems_version: 1.8.17
191
176
  signing_key:
192
177
  specification_version: 3
193
178
  summary: A Ruby wrapper around the Google Chart Tools that allows anyone to create