google-qr 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/google-qr.rb +24 -5
- data/lib/string.rb +11 -0
- metadata +20 -40
data/lib/google-qr.rb
CHANGED
@@ -1,15 +1,29 @@
|
|
1
|
+
require 'string'
|
2
|
+
|
1
3
|
class GoogleQR
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
attr_accessor :data,
|
5
|
+
:size,
|
6
|
+
:use_https,
|
7
|
+
:encoding,
|
8
|
+
:error_correction
|
9
|
+
|
10
|
+
def initialize(opts={})
|
11
|
+
options = {
|
12
|
+
:data => "http://google.com",
|
13
|
+
:size => "100x100",
|
14
|
+
:use_https => true
|
15
|
+
}.merge!(opts)
|
16
|
+
|
17
|
+
options.each {|key,value| self.send("#{key}=", value) }
|
6
18
|
end
|
7
19
|
|
8
20
|
def to_s
|
9
21
|
if self.data
|
10
22
|
params = ["chl=#{self.data}"]
|
11
23
|
params << "chs=#{self.size}" if self.size
|
12
|
-
|
24
|
+
params << "choe=#{self.encoding}" if self.encoding
|
25
|
+
params << "chld=#{self.error_correction}" if self.error_correction
|
26
|
+
base_url + params.join("&")
|
13
27
|
else
|
14
28
|
raise "Attribute @data is required for GoogleQR code"
|
15
29
|
end
|
@@ -24,4 +38,9 @@ class GoogleQR
|
|
24
38
|
end
|
25
39
|
"<img src='#{self.to_s}'#{dimensions}/>"
|
26
40
|
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def base_url
|
44
|
+
"http#{self.use_https ? 's' : ''}://chart.googleapis.com/chart?cht=qr&"
|
45
|
+
end
|
27
46
|
end
|
data/lib/string.rb
ADDED
metadata
CHANGED
@@ -1,68 +1,48 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-qr
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
version: "0.1"
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.2'
|
5
|
+
prerelease:
|
9
6
|
platform: ruby
|
10
|
-
authors:
|
7
|
+
authors:
|
11
8
|
- Joseph Hsu
|
9
|
+
- Nick Hammond
|
12
10
|
autorequire:
|
13
11
|
bindir: bin
|
14
12
|
cert_chain: []
|
15
|
-
|
16
|
-
date: 2011-01-20 00:00:00 +00:00
|
17
|
-
default_executable:
|
13
|
+
date: 2011-07-27 00:00:00.000000000Z
|
18
14
|
dependencies: []
|
19
|
-
|
20
15
|
description: Generate URL string for Google QR code and render HTML img string
|
21
|
-
email:
|
16
|
+
email:
|
22
17
|
- jhsu@josephhsu.com
|
23
18
|
executables: []
|
24
|
-
|
25
19
|
extensions: []
|
26
|
-
|
27
20
|
extra_rdoc_files: []
|
28
|
-
|
29
|
-
files:
|
21
|
+
files:
|
30
22
|
- lib/google-qr.rb
|
31
|
-
|
23
|
+
- lib/string.rb
|
32
24
|
homepage: http://github.com/jhsu/google-qr
|
33
25
|
licenses: []
|
34
|
-
|
35
26
|
post_install_message:
|
36
27
|
rdoc_options: []
|
37
|
-
|
38
|
-
require_paths:
|
28
|
+
require_paths:
|
39
29
|
- lib
|
40
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
31
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
segments:
|
46
|
-
- 1
|
47
|
-
- 8
|
48
|
-
- 7
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
49
35
|
version: 1.8.7
|
50
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
37
|
none: false
|
52
|
-
requirements:
|
53
|
-
- -
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
segments:
|
56
|
-
- 1
|
57
|
-
- 3
|
58
|
-
- 6
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
59
41
|
version: 1.3.6
|
60
42
|
requirements: []
|
61
|
-
|
62
43
|
rubyforge_project:
|
63
|
-
rubygems_version: 1.
|
44
|
+
rubygems_version: 1.8.5
|
64
45
|
signing_key:
|
65
46
|
specification_version: 3
|
66
47
|
summary: Wrapper for Google Chart QR code
|
67
48
|
test_files: []
|
68
|
-
|