jparker-ruby-googlechart 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,18 @@
1
+ == 0.0.1 2008-05-14
2
+
3
+ * Initial release
4
+
5
+ == 0.5.0 2008-11-08
6
+
7
+ * Code cleanup, improved tests
8
+ * First working gem release
9
+
10
+ == 0.6.0 2008-11-12
11
+
12
+ * Continued cleanup
13
+ * Changed data scaling behavior with negative values
14
+
15
+ == 0.6.1 2008-11-12
16
+
17
+ * Gem cleanup (switched from newgem + hoe to echoe)
18
+ * Fixed data scaling bug with all-zero data
@@ -1,8 +1,8 @@
1
- = ruby-googlechart
1
+ == ruby-googlechart
2
2
 
3
3
  * http://github.com/jparker/ruby-googlechart
4
4
 
5
- == DESCRIPTION:
5
+ == DESCRIPTION
6
6
 
7
7
  ruby-googlechart is a ruby library which provides object-oriented
8
8
  access to the Google Charts API.
@@ -13,33 +13,52 @@ libraries are more mature and may be better suited to your needs:
13
13
  * http://googlecharts.rubyforge.org/
14
14
  * http://code.google.com/p/gchartrb/
15
15
 
16
- == FEATURES/PROBLEMS:
16
+ == FEATURES
17
17
 
18
- * Limited support for Line and Bar charts
18
+ * Line charts (line, XY, sparkline)
19
+ * Bar charts (horizontal, vertical, grouped, stacked)
19
20
 
20
- == SYNOPSIS:
21
+ == SYNOPSIS
22
+
23
+ require 'google_chart'
21
24
 
22
25
  url = GoogleChart.Line(:data => [1, nil, 2, 8, 1])
26
+ url = GoogleChart.Bar(:data => [5, 23, 6, 14])
23
27
 
24
- url = GoogleChart.Line do |c|
25
- c.type = :line
26
- c.size = '800x375'
28
+ url = GoogleChart.Bar do |c|
29
+ c.axes = {:x => %w[Q1 Q2 Q3 Q4], :y => 0..400}
27
30
  c.data = [335, 285, 240, 220, 160, 175, 200, 205]
28
- c.scale = 0..400
29
31
  c.encoding = :extended
30
- c.title = 'Chart Title'
32
+ c.scale = 0..400
33
+ c.size = '800x375'
34
+ c.style = :dash
35
+ c.title = "Are You Pondering What I'm Pondering?"
36
+ c.type = :line
31
37
  end
38
+ url = GoogleChart.Bar do |c|
39
+ c.horizontal = true
40
+ c.grouped = true
41
+ c.data = [[5, 6, 7, 8], [23, 14, 17, 16]]
42
+ c.encoding = :text
43
+ c.title = 'Lorem Ipsum Dolor'
44
+ end
45
+
46
+ chart = GoogleChart::LineChart.new
47
+ chart.type = :sparkline
48
+ chart.size = '75x25'
49
+ chart.data = [1, 1, 2, 3, 5, 8, 13]
50
+ chart.color = 'ff0000'
51
+ url = chart.to_url
32
52
 
33
- == REQUIREMENTS:
53
+ == REQUIREMENTS
34
54
 
35
- * newgem >= 1.0.3
36
- * hoe >= 1.8.0
55
+ * Low standards
37
56
 
38
- == INSTALL:
57
+ == INSTALL
39
58
 
40
59
  * sudo gem install jparker-ruby-googlechart -s http://gems.github.com/
41
60
 
42
- == LICENSE:
61
+ == LICENSE
43
62
 
44
63
  (The MIT License)
45
64
 
@@ -62,4 +81,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
62
81
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
63
82
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
64
83
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
65
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
84
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,25 +1,14 @@
1
- %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
- require File.dirname(__FILE__) + '/lib/google_chart'
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
3
4
 
4
- # Generate all the Rake tasks
5
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
- $hoe = Hoe.new('ruby-googlechart', GoogleChart::VERSION) do |p|
7
- p.developer('John Parker', 'jparker@urgetopunt.com')
8
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
- p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
10
- p.rubyforge_name = p.name # TODO this is default value
11
- # p.extra_deps = [
12
- # ['activesupport','>= 2.0.2'],
13
- # ]
14
- p.extra_dev_deps = [
15
- ['newgem', ">= #{::Newgem::VERSION}"]
16
- ]
17
-
18
- p.clean_globs |= %w[**/.DS_Store tmp *.log]
19
- path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
20
- p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
21
- p.rsync_args = '-av --delete --ignore-errors'
5
+ Echoe.new('ruby-googlechart', '0.6.1') do |p|
6
+ p.description = 'Ruby wrapper around the Google Charts API'
7
+ p.url = 'http://github.com/jparker/ruby-googlechart'
8
+ p.author = 'John Parker'
9
+ p.email = 'jparker@urgetopunt.com'
10
+ p.ignore_pattern = %w[tmp/* script/*]
11
+ # p.development_dependencies = []
22
12
  end
23
13
 
24
- require 'newgem/tasks' # load /tasks/*.rake
25
-
14
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each {|ext| load ext }
@@ -35,7 +35,11 @@ module GoogleChart
35
35
 
36
36
  def normalize(set, encoding_max)
37
37
  min, max = scale.min, scale.max
38
- set.map {|e| (e.to_f - min) / (max - min) * encoding_max if e }
38
+ if min != max
39
+ set.map {|e| (e.to_f - min) / (max - min) * encoding_max if e }
40
+ else
41
+ set
42
+ end
39
43
  end
40
44
 
41
45
  def simple_encode(data)
data/lib/google_chart.rb CHANGED
@@ -18,8 +18,6 @@ require 'google_chart/bar_chart'
18
18
  require 'google_chart/line_chart'
19
19
 
20
20
  module GoogleChart
21
- VERSION = '0.6.0'
22
-
23
21
  def self.Line(options = {}, &block)
24
22
  GoogleChart::LineChart.new(options, &block).to_url
25
23
  end
@@ -0,0 +1,35 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{ruby-googlechart}
5
+ s.version = "0.6.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["John Parker"]
9
+ s.date = %q{2008-11-12}
10
+ s.description = %q{Ruby wrapper around the Google Charts API}
11
+ s.email = %q{jparker@urgetopunt.com}
12
+ s.extra_rdoc_files = ["CHANGELOG", "lib/google_chart/abstract_chart.rb", "lib/google_chart/axis.rb", "lib/google_chart/bar_chart.rb", "lib/google_chart/bar_style.rb", "lib/google_chart/color.rb", "lib/google_chart/data.rb", "lib/google_chart/grid_line.rb", "lib/google_chart/legend.rb", "lib/google_chart/line_chart.rb", "lib/google_chart/line_style.rb", "lib/google_chart/range_marker.rb", "lib/google_chart/title.rb", "lib/google_chart.rb", "README.rdoc"]
13
+ s.files = ["CHANGELOG", "lib/google_chart/abstract_chart.rb", "lib/google_chart/axis.rb", "lib/google_chart/bar_chart.rb", "lib/google_chart/bar_style.rb", "lib/google_chart/color.rb", "lib/google_chart/data.rb", "lib/google_chart/grid_line.rb", "lib/google_chart/legend.rb", "lib/google_chart/line_chart.rb", "lib/google_chart/line_style.rb", "lib/google_chart/range_marker.rb", "lib/google_chart/title.rb", "lib/google_chart.rb", "Manifest", "Rakefile", "README.rdoc", "ruby-googlechart.gemspec", "test/google_chart/test_abstract_chart.rb", "test/google_chart/test_axis.rb", "test/google_chart/test_bar_chart.rb", "test/google_chart/test_bar_style.rb", "test/google_chart/test_color.rb", "test/google_chart/test_data.rb", "test/google_chart/test_grid_line.rb", "test/google_chart/test_legend.rb", "test/google_chart/test_line_chart.rb", "test/google_chart/test_line_style.rb", "test/google_chart/test_range_marker.rb", "test/google_chart/test_title.rb", "test/test_google_chart.rb", "test/test_helper.rb"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://github.com/jparker/ruby-googlechart}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ruby-googlechart", "--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{ruby-googlechart}
19
+ s.rubygems_version = %q{1.3.1}
20
+ s.summary = %q{Ruby wrapper around the Google Charts API}
21
+ s.test_files = ["test/google_chart/test_abstract_chart.rb", "test/google_chart/test_axis.rb", "test/google_chart/test_bar_chart.rb", "test/google_chart/test_bar_style.rb", "test/google_chart/test_color.rb", "test/google_chart/test_data.rb", "test/google_chart/test_grid_line.rb", "test/google_chart/test_legend.rb", "test/google_chart/test_line_chart.rb", "test/google_chart/test_line_style.rb", "test/google_chart/test_range_marker.rb", "test/google_chart/test_title.rb", "test/test_google_chart.rb", "test/test_helper.rb"]
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 2
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_development_dependency(%q<echoe>, [">= 0"])
29
+ else
30
+ s.add_dependency(%q<echoe>, [">= 0"])
31
+ end
32
+ else
33
+ s.add_dependency(%q<echoe>, [">= 0"])
34
+ end
35
+ end
@@ -29,10 +29,20 @@ class TestData < Test::Unit::TestCase
29
29
  assert_match(/\bchd=s:JP,YH\b/, @chart.to_url)
30
30
  end
31
31
 
32
- should 'encode missing data' do
33
- @chart.data = [50, nil, 33]
32
+ should 'encode floating point data' do
33
+ @chart.data = [49.5, 33.4]
34
34
  @chart.scale = 0..61
35
- assert_match(/\bchd=s:y_h\b/, @chart.to_url)
35
+ assert_match(/\bchd=s:yh\b/, @chart.to_url)
36
+ end
37
+
38
+ should 'encode all zeros with "A"' do
39
+ @chart.data = [0, 0, 0]
40
+ assert_match(/\bchd=s:AAA\b/, @chart.to_url)
41
+ end
42
+
43
+ should 'encode unchanging non-zero data with "9"' do
44
+ @chart.data = [1, 1, 1]
45
+ assert_match(/\bchd=s:999\b/, @chart.to_url)
36
46
  end
37
47
 
38
48
  should 'encode out-of-bounds data' do
@@ -41,10 +51,10 @@ class TestData < Test::Unit::TestCase
41
51
  assert_match(/\bchd=s:998BAA/, @chart.to_url)
42
52
  end
43
53
 
44
- should 'encode floating point data' do
45
- @chart.data = [49.5, 33.4]
54
+ should 'encode missing data' do
55
+ @chart.data = [50, nil, 33]
46
56
  @chart.scale = 0..61
47
- assert_match(/\bchd=s:yh\b/, @chart.to_url)
57
+ assert_match(/\bchd=s:y_h\b/, @chart.to_url)
48
58
  end
49
59
  end
50
60
 
@@ -68,10 +78,20 @@ class TestData < Test::Unit::TestCase
68
78
  assert_match(/\bchd=e:jpyh,JPYH\b/, @chart.to_url)
69
79
  end
70
80
 
71
- should 'encode missing data' do
72
- @chart.data = [2281, nil, 3233]
81
+ should 'encode floating point data' do
82
+ @chart.data = [2281.49, 3232.50]
73
83
  @chart.scale = 0..4095
74
- assert_match(/\bchd=e:jp__yh\b/, @chart.to_url)
84
+ assert_match(/\bchd=e:jpyh\b/, @chart.to_url)
85
+ end
86
+
87
+ should 'encode all zeros with "AA"' do
88
+ @chart.data = [0, 0, 0]
89
+ assert_match(/\bchd=e:AAAAAA\b/, @chart.to_url)
90
+ end
91
+
92
+ should 'encode unchanging non-zero data with ".."' do
93
+ @chart.data = [1, 1, 1]
94
+ assert_match(/\bchd=e:\.{6}/, @chart.to_url)
75
95
  end
76
96
 
77
97
  should 'encode out-of-bounds data' do
@@ -80,10 +100,10 @@ class TestData < Test::Unit::TestCase
80
100
  assert_match(/\bchd=e:\.\.\.\.\.-ABAAAA\b/, @chart.to_url)
81
101
  end
82
102
 
83
- should 'encode floating point data' do
84
- @chart.data = [2281.49, 3232.50]
103
+ should 'encode missing data' do
104
+ @chart.data = [2281, nil, 3233]
85
105
  @chart.scale = 0..4095
86
- assert_match(/\bchd=e:jpyh\b/, @chart.to_url)
106
+ assert_match(/\bchd=e:jp__yh\b/, @chart.to_url)
87
107
  end
88
108
  end
89
109
 
@@ -107,10 +127,20 @@ class TestData < Test::Unit::TestCase
107
127
  assert_match(/\bchd=t:6,14\|5,23\b/, @chart.to_url)
108
128
  end
109
129
 
110
- should 'encode missing data' do
111
- @chart.data = [6, nil, 14]
130
+ should 'rounds floating point data to the nearest tenth' do
131
+ @chart.data = [5.95, 14.01, 5.23]
112
132
  @chart.scale = 0..100
113
- assert_match(/\bchd=t:6,-1,14\b/, @chart.to_url)
133
+ assert_match(/\bchd=t:6,14,5.2\b/, @chart.to_url)
134
+ end
135
+
136
+ should 'encode all zeros with "0"' do
137
+ @chart.data = [0, 0, 0]
138
+ assert_match(/\bchd=t:0,0,0\b/, @chart.to_url)
139
+ end
140
+
141
+ should 'encode unchanging non-zero data with "100"' do
142
+ @chart.data = [1, 1, 1]
143
+ assert_match(/\bchd=t:100,100,100\b/, @chart.to_url)
114
144
  end
115
145
 
116
146
  should 'encode out-of-bounds data' do
@@ -119,10 +149,10 @@ class TestData < Test::Unit::TestCase
119
149
  assert_match(/\bchd=t:100,100,99,1,0,0\b/, @chart.to_url)
120
150
  end
121
151
 
122
- should 'rounds floating point data to the nearest tenth' do
123
- @chart.data = [5.95, 14.01, 5.23]
152
+ should 'encode missing data' do
153
+ @chart.data = [6, nil, 14]
124
154
  @chart.scale = 0..100
125
- assert_match(/\bchd=t:6,14,5.2\b/, @chart.to_url)
155
+ assert_match(/\bchd=t:6,-1,14\b/, @chart.to_url)
126
156
  end
127
157
  end
128
158
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jparker-ruby-googlechart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Parker
@@ -9,52 +9,42 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-11 00:00:00 -08:00
12
+ date: 2008-11-12 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: newgem
16
+ name: echoe
17
17
  version_requirement:
18
18
  version_requirements: !ruby/object:Gem::Requirement
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 1.0.3
22
+ version: "0"
23
23
  version:
24
- - !ruby/object:Gem::Dependency
25
- name: hoe
26
- version_requirement:
27
- version_requirements: !ruby/object:Gem::Requirement
28
- requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- version: 1.8.0
32
- version:
33
- - !ruby/object:Gem::Dependency
34
- name: thoughtbot-shoulda
35
- version_requirement:
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 2.0.0
41
- version:
42
- description: ruby-googlechart is a ruby library which provides object-oriented access to the Google Charts API
24
+ description: Ruby wrapper around the Google Charts API
43
25
  email: jparker@urgetopunt.com
44
26
  executables: []
45
27
 
46
28
  extensions: []
47
29
 
48
30
  extra_rdoc_files:
49
- - History.txt
50
- - Manifest.txt
51
- - README.txt
52
- files:
53
- - History.txt
54
- - Manifest.txt
55
- - Rakefile
56
- - README.txt
31
+ - CHANGELOG
32
+ - lib/google_chart/abstract_chart.rb
33
+ - lib/google_chart/axis.rb
34
+ - lib/google_chart/bar_chart.rb
35
+ - lib/google_chart/bar_style.rb
36
+ - lib/google_chart/color.rb
37
+ - lib/google_chart/data.rb
38
+ - lib/google_chart/grid_line.rb
39
+ - lib/google_chart/legend.rb
40
+ - lib/google_chart/line_chart.rb
41
+ - lib/google_chart/line_style.rb
42
+ - lib/google_chart/range_marker.rb
43
+ - lib/google_chart/title.rb
57
44
  - lib/google_chart.rb
45
+ - README.rdoc
46
+ files:
47
+ - CHANGELOG
58
48
  - lib/google_chart/abstract_chart.rb
59
49
  - lib/google_chart/axis.rb
60
50
  - lib/google_chart/bar_chart.rb
@@ -67,12 +57,35 @@ files:
67
57
  - lib/google_chart/line_style.rb
68
58
  - lib/google_chart/range_marker.rb
69
59
  - lib/google_chart/title.rb
70
- has_rdoc: false
60
+ - lib/google_chart.rb
61
+ - Manifest
62
+ - Rakefile
63
+ - README.rdoc
64
+ - ruby-googlechart.gemspec
65
+ - test/google_chart/test_abstract_chart.rb
66
+ - test/google_chart/test_axis.rb
67
+ - test/google_chart/test_bar_chart.rb
68
+ - test/google_chart/test_bar_style.rb
69
+ - test/google_chart/test_color.rb
70
+ - test/google_chart/test_data.rb
71
+ - test/google_chart/test_grid_line.rb
72
+ - test/google_chart/test_legend.rb
73
+ - test/google_chart/test_line_chart.rb
74
+ - test/google_chart/test_line_style.rb
75
+ - test/google_chart/test_range_marker.rb
76
+ - test/google_chart/test_title.rb
77
+ - test/test_google_chart.rb
78
+ - test/test_helper.rb
79
+ has_rdoc: true
71
80
  homepage: http://github.com/jparker/ruby-googlechart
72
81
  post_install_message:
73
82
  rdoc_options:
83
+ - --line-numbers
84
+ - --inline-source
85
+ - --title
86
+ - Ruby-googlechart
74
87
  - --main
75
- - README.txt
88
+ - README.rdoc
76
89
  require_paths:
77
90
  - lib
78
91
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -85,18 +98,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
98
  requirements:
86
99
  - - ">="
87
100
  - !ruby/object:Gem::Version
88
- version: "0"
101
+ version: "1.2"
89
102
  version:
90
103
  requirements: []
91
104
 
92
- rubyforge_project:
105
+ rubyforge_project: ruby-googlechart
93
106
  rubygems_version: 1.2.0
94
107
  signing_key:
95
108
  specification_version: 2
96
- summary: Ruby wrapper for the Google Charts API
109
+ summary: Ruby wrapper around the Google Charts API
97
110
  test_files:
98
- - test/test_helper.rb
99
- - test/test_google_chart.rb
100
111
  - test/google_chart/test_abstract_chart.rb
101
112
  - test/google_chart/test_axis.rb
102
113
  - test/google_chart/test_bar_chart.rb
@@ -109,3 +120,5 @@ test_files:
109
120
  - test/google_chart/test_line_style.rb
110
121
  - test/google_chart/test_range_marker.rb
111
122
  - test/google_chart/test_title.rb
123
+ - test/test_google_chart.rb
124
+ - test/test_helper.rb
data/History.txt DELETED
@@ -1,6 +0,0 @@
1
- == 0.0.1 2008-05-14
2
-
3
- * 1 major enhancement:
4
- * Initial release
5
- * Bar chart support
6
- * Line chart support
data/Manifest.txt DELETED
@@ -1,52 +0,0 @@
1
- History.txt
2
- License.txt
3
- Manifest.txt
4
- PostInstall.txt
5
- README.txt
6
- Rakefile
7
- TODO.txt
8
- config/hoe.rb
9
- config/requirements.rb
10
- lib/google_chart.rb
11
- lib/google_chart/axes.rb
12
- lib/google_chart/bar.rb
13
- lib/google_chart/bar_styles.rb
14
- lib/google_chart/base.rb
15
- lib/google_chart/colors.rb
16
- lib/google_chart/data.rb
17
- lib/google_chart/grid_lines.rb
18
- lib/google_chart/legends.rb
19
- lib/google_chart/line.rb
20
- lib/google_chart/line_styles.rb
21
- lib/google_chart/range_markers.rb
22
- lib/google_chart/sizes.rb
23
- lib/google_chart/titles.rb
24
- ruby-googlechart.gemspec
25
- script/console
26
- script/destroy
27
- script/generate
28
- script/txt2html
29
- setup.rb
30
- tasks/deployment.rake
31
- tasks/environment.rake
32
- tasks/website.rake
33
- test/google_chart/test_axes.rb
34
- test/google_chart/test_bar.rb
35
- test/google_chart/test_bar_styles.rb
36
- test/google_chart/test_base.rb
37
- test/google_chart/test_colors.rb
38
- test/google_chart/test_data.rb
39
- test/google_chart/test_grid_lines.rb
40
- test/google_chart/test_legends.rb
41
- test/google_chart/test_line.rb
42
- test/google_chart/test_line_styles.rb
43
- test/google_chart/test_range_markers.rb
44
- test/google_chart/test_sizes.rb
45
- test/google_chart/test_titles.rb
46
- test/test_google_chart.rb
47
- test/test_helper.rb
48
- website/index.html
49
- website/index.txt
50
- website/javascripts/rounded_corners_lite.inc.js
51
- website/stylesheets/screen.css
52
- website/template.html.erb