googlecharts 1.6.3 → 1.6.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.
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ log/*
3
+ .manifest
4
+ pkg
@@ -1,3 +1,10 @@
1
+ == 1.6.6
2
+ * added ssl support
3
+ * refactored code
4
+ * аdded ability to set the legend position
5
+ * fixed legend position value
6
+ * separated labels and legends for pies
7
+
1
8
  == 1.3.6
2
9
  * support nil values. The Google Charts API specifies that a single underscore (_) can be used to omit a value from a line chart with 'simple' data encoding, and a double underscore (__) can do the same for a chart with 'extended' data encoding. (Matt Moyer)
3
10
  * allow a label to appear on a google-o-meter via the :legend option. (hallettj)
@@ -296,30 +296,4 @@ try yourself
296
296
  "http://chart.apis.google.com/chart?chs=300x200&chdl=matt|patrick&chd=s:AAANUIv,JENCN9y&chtt=SDRuby+Fu+level&chf=bg,lg,0,76A4FB,0,ffffff,1&cht=bvs&chco=ff0000,00ff00"
297
297
 
298
298
  Gchart.pie(:data => [20,10,15,5,50], :title => 'SDRuby Fu level', :size => '400x200', :labels => ['matt', 'rob', 'patrick', 'ryan', 'jordan'])
299
- http://chart.apis.google.com/chart?cht=p&chs=400x200&chd=s:YMSG9&chtt=SDRuby+Fu+level&chl=matt|rob|patrick|ryan|jordan
300
-
301
-
302
- People reported using this gem:
303
- ---------------------
304
-
305
- ![github](http://img.skitch.com/20080627-r14subqdx2ye3w13qefbx974gc.png)
306
-
307
- * [http://github.com](http://github.com)
308
-
309
- ![stafftool.com](http://stafftool.com/images/masthead_screen.gif)
310
-
311
- * [http://stafftool.com/](http://stafftool.com/) Takeo (contributor)
312
-
313
- ![graffletopia.com](http://img.skitch.com/20080627-g2pp89h7gdbh15m1rr8hx48jep.jpg)
314
-
315
- * [graffleropia.com](http://graffletopia.com) Mokolabs (contributor)
316
-
317
- ![gumgum](http://img.skitch.com/20080627-kc1weqsbkmxeqhwiyriq3n6g8k.jpg)
318
-
319
- * [http://gumgum.com](http://gumgum.com) Mattetti (Author)
320
-
321
- ![http://img.skitch.com/20080627-n48j8pb2r7irsewfeh4yp3da12.jpg]
322
-
323
- * [http://feedflix.com/](http://feedflix.com/) [lifehacker article](http://lifehacker.com/395610/feedflix-creates-detailed-charts-from-your-netflix-use)
324
-
325
- * [California State University, Chico](http://www.csuchico.edu/)
299
+ http://chart.apis.google.com/chart?cht=p&chs=400x200&chd=s:YMSG9&chtt=SDRuby+Fu+level&chl=matt|rob|patrick|ryan|jordan
data/README.txt CHANGED
@@ -1,9 +1,3 @@
1
1
  CHECK README.markdown (open as a text file)
2
2
 
3
- Or check:
4
-
5
- http://googlecharts.rubyforge.org
6
-
7
- and/or
8
-
9
- http://github.com/mattetti/googlecharts
3
+ http://github.com/mattetti/googlecharts
data/Rakefile CHANGED
@@ -1,20 +1 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gemspec|
7
- gemspec.name = "googlecharts"
8
- gemspec.summary = "Generate charts using Google API & Ruby"
9
- gemspec.description = "Generate charts using Google API & Ruby"
10
- gemspec.email = "mattaimonetti@gmail.com"
11
- gemspec.homepage = "http://googlecharts.rubyforge.org/"
12
- gemspec.authors = ["Matt Aimonetti"]
13
- end
14
- Jeweler::GemcutterTasks.new
15
- rescue LoadError
16
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
17
- end
18
-
19
- Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
20
-
1
+ require 'rubygems'
@@ -1,71 +1,20 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "gchart/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
6
  s.name = %q{googlecharts}
8
- s.version = "1.6.3"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Matt Aimonetti"]
12
- s.date = %q{2011-05-05}
7
+ s.version = GchartInfo::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Matt Aimonetti", "Andrey Deryabin"]
10
+ s.date = %q{2011-05-21}
11
+ s.summary = %q{Generate charts using Google API & Ruby}
13
12
  s.description = %q{Generate charts using Google API & Ruby}
14
- s.email = %q{mattaimonetti@gmail.com}
15
- s.extra_rdoc_files = [
16
- "README",
17
- "README.markdown",
18
- "README.txt"
19
- ]
20
- s.files = [
21
- "History.txt",
22
- "License.txt",
23
- "Manifest.txt",
24
- "README",
25
- "README.markdown",
26
- "README.txt",
27
- "Rakefile",
28
- "VERSION",
29
- "config/hoe.rb",
30
- "config/requirements.rb",
31
- "googlecharts.gemspec",
32
- "lib/gchart.rb",
33
- "lib/gchart/aliases.rb",
34
- "lib/gchart/theme.rb",
35
- "lib/gchart/version.rb",
36
- "lib/googlecharts.rb",
37
- "lib/themes.yml",
38
- "script/destroy",
39
- "script/generate",
40
- "script/txt2html",
41
- "setup.rb",
42
- "spec/fixtures/another_test_theme.yml",
43
- "spec/fixtures/test_theme.yml",
44
- "spec/gchart_spec.rb",
45
- "spec/spec_helper.rb",
46
- "spec/theme_spec.rb",
47
- "tasks/deployment.rake",
48
- "tasks/environment.rake",
49
- "tasks/rspec.rake",
50
- "tasks/website.rake",
51
- "website/index.html",
52
- "website/index.txt",
53
- "website/javascripts/rounded_corners_lite.inc.js",
54
- "website/stylesheets/screen.css",
55
- "website/template.rhtml"
56
- ]
13
+ s.email = %q{mattaimonetti@gmail.com deriabin@gmail.com}
57
14
  s.homepage = %q{http://googlecharts.rubyforge.org/}
58
- s.require_paths = ["lib"]
59
- s.rubygems_version = %q{1.6.2}
60
- s.summary = %q{Generate charts using Google API & Ruby}
61
15
 
62
- if s.respond_to? :specification_version then
63
- s.specification_version = 3
64
-
65
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
66
- else
67
- end
68
- else
69
- end
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
70
20
  end
71
-
@@ -2,6 +2,7 @@ $:.unshift File.dirname(__FILE__)
2
2
  require 'gchart/version'
3
3
  require 'gchart/theme'
4
4
  require "net/http"
5
+ require "net/https"
5
6
  require "uri"
6
7
  require "cgi"
7
8
  require 'enumerator'
@@ -9,8 +10,12 @@ require 'enumerator'
9
10
  class Gchart
10
11
  include GchartInfo
11
12
 
12
- def self.url
13
- "http://chart.apis.google.com/chart?"
13
+ def self.url(use_ssl = false)
14
+ if use_ssl
15
+ 'https://www.google.com/chart?'
16
+ else
17
+ 'http://chart.apis.google.com/chart?'
18
+ end
14
19
  end
15
20
 
16
21
  def self.types
@@ -33,11 +38,11 @@ class Gchart
33
38
  'chart.png'
34
39
  end
35
40
 
36
- attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :legend, :labels, :data, :encoding, :bar_colors,
41
+ attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors,
37
42
  :title_color, :title_size, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass,
38
43
  :range_markers, :geographical_area, :map_colors, :country_codes, :axis_range, :filename, :min, :max, :colors, :usemap
39
44
 
40
- attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines
45
+ attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines, :use_ssl
41
46
 
42
47
  attr_accessor :min_value, :max_value
43
48
 
@@ -75,6 +80,7 @@ class Gchart
75
80
  @curved = false
76
81
  @horizontal = false
77
82
  @grouped = false
83
+ @use_ssl = false
78
84
  @encoding = 'simple'
79
85
  # @max_value = 'auto'
80
86
  # @min_value defaults to nil meaning zero
@@ -255,11 +261,13 @@ class Gchart
255
261
 
256
262
  # Returns the chart's generated PNG as a blob. (borrowed from John's gchart.rubyforge.org)
257
263
  def fetch
258
- url = URI.parse(self.class.url)
264
+ url = URI.parse(self.class.url(use_ssl))
259
265
  req = Net::HTTP::Post.new(url.path)
260
266
  req.body = query_builder
261
267
  req.content_type = 'application/x-www-form-urlencoded'
262
- Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }.body
268
+ http = Net::HTTP.new(url.host, url.port)
269
+ http.use_ssl = use_ssl
270
+ http.start {|resp| resp.request(req) }.body
263
271
  end
264
272
 
265
273
  # Writes the chart's generated PNG to a file. (borrowed from John's gchart.rubyforge.org)
@@ -409,18 +417,35 @@ class Gchart
409
417
 
410
418
  end
411
419
 
420
+ def set_legend_position
421
+ case @legend_position.to_s
422
+ when /(bottom|b)$/
423
+ "chdlp=b"
424
+ when /(bottom_vertical|bv)$/
425
+ "chdlp=bv"
426
+ when /(top|t)$/
427
+ "chdlp=t"
428
+ when /(top_vertical|tv)$/
429
+ "chdlp=tv"
430
+ when /(right|r)$/
431
+ "chdlp=r"
432
+ when /(left|l)$/
433
+ "chdlp=l"
434
+ end
435
+ end
436
+
412
437
  def set_line_thickness
413
- "chls=#{thickness}"
438
+ "chls=#{thickness}"
414
439
  end
415
-
440
+
416
441
  def set_line_markers
417
- "chm=#{new_markers}"
442
+ "chm=#{new_markers}"
418
443
  end
419
-
444
+
420
445
  def set_grid_lines
421
- "chg=#{grid_lines}"
446
+ "chg=#{grid_lines}"
422
447
  end
423
-
448
+
424
449
  def set_labels
425
450
  if labels.is_a?(Array)
426
451
  "chl=#{@labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}"
@@ -623,7 +648,7 @@ class Gchart
623
648
  end
624
649
 
625
650
  def url_builder(options="")
626
- self.class.url + query_builder(options)
651
+ self.class.url(use_ssl) + query_builder(options)
627
652
  end
628
653
 
629
654
  def query_builder(options="")
@@ -642,6 +667,8 @@ class Gchart
642
667
  set_legend unless legend.nil?
643
668
  when '@labels'
644
669
  set_labels unless labels.nil?
670
+ when '@legend_position'
671
+ set_legend_position unless legend_position.nil?
645
672
  when '@thickness'
646
673
  set_line_thickness
647
674
  when '@new_markers'
@@ -1,9 +1,3 @@
1
1
  module GchartInfo #:nodoc:
2
- module VERSION #:nodoc:
3
- MAJOR = 1
4
- MINOR = 6
5
- TINY = 2
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
- end
2
+ VERSION = "1.6.6"
9
3
  end
@@ -392,6 +392,18 @@ describe "a line chart" do
392
392
  chart = Gchart.line(:legend => 'legend label')
393
393
  chart.include?("chdl=legend+label").should be_true
394
394
  end
395
+
396
+ it "should be able to set the position of the legend" do
397
+ title = 'Chart & Title'
398
+ legend = ['first data & set label', 'n data set label']
399
+
400
+ chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical)
401
+ puts chart.inspect
402
+ chart.include?("chdlp=bv").should be_true
403
+
404
+ chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r')
405
+ chart.include?("chdlp=r").should be_true
406
+ end
395
407
 
396
408
  it "should be able to set the background fill" do
397
409
  Gchart.line(:bg => 'efefef').should include("chf=bg,s,efefef")
@@ -651,3 +663,16 @@ describe 'exporting a chart' do
651
663
  end
652
664
 
653
665
  end
666
+
667
+ describe 'SSL support' do
668
+ it 'should change url if is presented' do
669
+ Gchart.line(:use_ssl => true).should include('https://www.google.com/chart?')
670
+ end
671
+
672
+ it "should be available as a file" do
673
+ File.delete('chart.png') if File.exist?('chart.png')
674
+ Gchart.line(:data => [0, 26], :format => 'file', :use_ssl => true)
675
+ File.exist?('chart.png').should be_true
676
+ File.delete('chart.png') if File.exist?('chart.png')
677
+ end
678
+ end
metadata CHANGED
@@ -2,39 +2,35 @@
2
2
  name: googlecharts
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.6.3
5
+ version: 1.6.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matt Aimonetti
9
+ - Andrey Deryabin
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
13
 
13
- date: 2011-05-05 00:00:00 -07:00
14
+ date: 2011-05-21 00:00:00 +04:00
14
15
  default_executable:
15
16
  dependencies: []
16
17
 
17
18
  description: Generate charts using Google API & Ruby
18
- email: mattaimonetti@gmail.com
19
+ email: mattaimonetti@gmail.com deriabin@gmail.com
19
20
  executables: []
20
21
 
21
22
  extensions: []
22
23
 
23
- extra_rdoc_files:
24
- - README
25
- - README.markdown
26
- - README.txt
24
+ extra_rdoc_files: []
25
+
27
26
  files:
27
+ - .gitignore
28
28
  - History.txt
29
29
  - License.txt
30
- - Manifest.txt
31
30
  - README
32
31
  - README.markdown
33
32
  - README.txt
34
33
  - Rakefile
35
- - VERSION
36
- - config/hoe.rb
37
- - config/requirements.rb
38
34
  - googlecharts.gemspec
39
35
  - lib/gchart.rb
40
36
  - lib/gchart/aliases.rb
@@ -42,24 +38,11 @@ files:
42
38
  - lib/gchart/version.rb
43
39
  - lib/googlecharts.rb
44
40
  - lib/themes.yml
45
- - script/destroy
46
- - script/generate
47
- - script/txt2html
48
- - setup.rb
49
41
  - spec/fixtures/another_test_theme.yml
50
42
  - spec/fixtures/test_theme.yml
51
43
  - spec/gchart_spec.rb
52
44
  - spec/spec_helper.rb
53
45
  - spec/theme_spec.rb
54
- - tasks/deployment.rake
55
- - tasks/environment.rake
56
- - tasks/rspec.rake
57
- - tasks/website.rake
58
- - website/index.html
59
- - website/index.txt
60
- - website/javascripts/rounded_corners_lite.inc.js
61
- - website/stylesheets/screen.css
62
- - website/template.rhtml
63
46
  has_rdoc: true
64
47
  homepage: http://googlecharts.rubyforge.org/
65
48
  licenses: []
@@ -88,5 +71,9 @@ rubygems_version: 1.6.2
88
71
  signing_key:
89
72
  specification_version: 3
90
73
  summary: Generate charts using Google API & Ruby
91
- test_files: []
92
-
74
+ test_files:
75
+ - spec/fixtures/another_test_theme.yml
76
+ - spec/fixtures/test_theme.yml
77
+ - spec/gchart_spec.rb
78
+ - spec/spec_helper.rb
79
+ - spec/theme_spec.rb
@@ -1,18 +0,0 @@
1
- History.txt
2
- License.txt
3
- Manifest.txt
4
- README.txt
5
- Rakefile
6
- config/hoe.rb
7
- config/requirements.rb
8
- lib/gchart.rb
9
- lib/gchart/aliases.rb
10
- lib/gchart/theme.rb
11
- lib/gchart/version.rb
12
- setup.rb
13
- spec/gchart_spec.rb
14
- spec/theme_spec.rb
15
- spec/spec.opts
16
- spec/spec_helper.rb
17
- tasks/environment.rake
18
- tasks/rspec.rake
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.6.3
@@ -1,71 +0,0 @@
1
- require 'gchart/version'
2
-
3
- AUTHOR = 'Matt Aimonetti' # can also be an array of Authors
4
- EMAIL = "mattaimonetti@gmail.com"
5
- DESCRIPTION = "description of gem"
6
- GEM_NAME = 'googlecharts' # what ppl will type to install your gem
7
- RUBYFORGE_PROJECT = 'googlecharts' # The unix name for your project
8
- HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
- DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
-
11
- @config_file = "~/.rubyforge/user-config.yml"
12
- @config = nil
13
- RUBYFORGE_USERNAME = "matt_a"
14
- def rubyforge_username
15
- unless @config
16
- begin
17
- @config = YAML.load(File.read(File.expand_path(@config_file)))
18
- rescue
19
- puts <<-EOS
20
- ERROR: No rubyforge config file found: #{@config_file}
21
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
22
- - See http://newgem.rubyforge.org/rubyforge.html for more details
23
- EOS
24
- exit
25
- end
26
- end
27
- RUBYFORGE_USERNAME.replace @config["username"]
28
- end
29
-
30
-
31
- REV = nil
32
- # UNCOMMENT IF REQUIRED:
33
- # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
34
- VERS = GchartInfo::VERSION::STRING + (REV ? ".#{REV}" : "")
35
- RDOC_OPTS = ['--quiet', '--title', 'gchart documentation',
36
- "--opname", "index.html",
37
- "--line-numbers",
38
- "--main", "README",
39
- "--inline-source"]
40
-
41
- class Hoe
42
- def extra_deps
43
- @extra_deps.reject! { |x| Array(x).first == 'hoe' }
44
- @extra_deps
45
- end
46
- end
47
-
48
- # Generate all the Rake tasks
49
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
50
- hoe = Hoe.new(GEM_NAME, VERS) do |p|
51
- p.author = AUTHOR
52
- p.description = DESCRIPTION
53
- p.email = EMAIL
54
- p.summary = DESCRIPTION
55
- p.url = HOMEPATH
56
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
57
- p.test_globs = ["test/**/test_*.rb"]
58
- p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
59
-
60
- # == Optional
61
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
62
- #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
63
-
64
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
65
-
66
- end
67
-
68
- CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
69
- PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
70
- hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
71
- hoe.rsync_args = '-av --delete --ignore-errors'