google-qr 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/google-qr.rb +7 -6
  2. metadata +4 -3
@@ -1,4 +1,5 @@
1
1
  require 'string'
2
+ require 'uri'
2
3
 
3
4
  class GoogleQR
4
5
  attr_accessor :data,
@@ -6,11 +7,11 @@ class GoogleQR
6
7
  :use_https,
7
8
  :encoding,
8
9
  :error_correction
9
-
10
+
10
11
  def initialize(opts={})
11
12
  options = {
12
- :data => "http://google.com",
13
- :size => "100x100",
13
+ :data => "GoogleQR",
14
+ :size => "100x100",
14
15
  :use_https => true
15
16
  }.merge!(opts)
16
17
 
@@ -19,7 +20,7 @@ class GoogleQR
19
20
 
20
21
  def to_s
21
22
  if self.data
22
- params = ["chl=#{self.data}"]
23
+ params = ["chl=#{URI.encode(self.data, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}"]
23
24
  params << "chs=#{self.size}" if self.size
24
25
  params << "choe=#{self.encoding}" if self.encoding
25
26
  params << "chld=#{self.error_correction}" if self.error_correction
@@ -38,9 +39,9 @@ class GoogleQR
38
39
  end
39
40
  "<img src='#{self.to_s}'#{dimensions}/>"
40
41
  end
41
-
42
+
42
43
  private
43
44
  def base_url
44
45
  "http#{self.use_https ? 's' : ''}://chart.googleapis.com/chart?cht=qr&"
45
46
  end
46
- end
47
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-qr
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,12 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-07-27 00:00:00.000000000Z
13
+ date: 2011-12-14 00:00:00.000000000Z
14
14
  dependencies: []
15
15
  description: Generate URL string for Google QR code and render HTML img string
16
16
  email:
17
17
  - jhsu@josephhsu.com
18
+ - nrhammond@gmail.com
18
19
  executables: []
19
20
  extensions: []
20
21
  extra_rdoc_files: []
@@ -41,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
42
  version: 1.3.6
42
43
  requirements: []
43
44
  rubyforge_project:
44
- rubygems_version: 1.8.5
45
+ rubygems_version: 1.8.10
45
46
  signing_key:
46
47
  specification_version: 3
47
48
  summary: Wrapper for Google Chart QR code