qr4r 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/Gemfile.lock +1 -1
- data/Rakefile +3 -1
- data/lib/qr4r/version.rb +1 -1
- data/lib/qr4r.rb +7 -1
- data/test/qr4r_test.rb +19 -4
- metadata +8 -10
data/.rvmrc
CHANGED
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
data/lib/qr4r/version.rb
CHANGED
data/lib/qr4r.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'rqrcode'
|
2
2
|
require 'mojo_magick'
|
3
3
|
module Qr4r
|
4
|
-
|
4
|
+
# size should indicate dot pixel size, size of 3 makes black pixels of 3x3
|
5
|
+
def self.encode(str, outfile, size = 3)
|
5
6
|
qr = RQRCode::QRCode.new(str)
|
6
7
|
data = []
|
7
8
|
qr.modules.each_index do |x|
|
@@ -18,6 +19,11 @@ module Qr4r
|
|
18
19
|
c.blob(d, :format => :rgb, :depth => 8, :size => ("%dx%d" % [qr.modules.size, qr.modules.size]))
|
19
20
|
c.file outfile
|
20
21
|
end
|
22
|
+
MojoMagick::convert do |c|
|
23
|
+
c.file outfile
|
24
|
+
c.scale "%dx%d" % [qr.modules.size, qr.modules.size].map{|s| s*size}
|
25
|
+
c.file outfile
|
26
|
+
end
|
21
27
|
end
|
22
28
|
|
23
29
|
end
|
data/test/qr4r_test.rb
CHANGED
@@ -1,13 +1,28 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require File::expand_path(File::join(File::dirname(__FILE__), '..', 'init'))
|
3
|
-
|
3
|
+
require 'tempfile'
|
4
4
|
class Qr4rTest < Test::Unit::TestCase
|
5
5
|
|
6
|
-
def
|
6
|
+
def test_encode
|
7
|
+
# do something
|
8
|
+
f = Tempfile.new(['qr4r','.png'])
|
9
|
+
Qr4r::encode('whatever yo', f.path)
|
10
|
+
# assert that it worked
|
11
|
+
assert File.exists?(f.path)
|
12
|
+
r = MojoMagick::get_image_size(f.path)
|
13
|
+
assert r[:height] == 99
|
14
|
+
assert r[:width] == 99
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_encode_with_size
|
7
18
|
# do something
|
8
|
-
|
19
|
+
f = Tempfile.new(['qr4r','.png'])
|
20
|
+
Qr4r::encode('whatever yo', f.path, 4)
|
9
21
|
# assert that it worked
|
10
|
-
assert File.exists?(
|
22
|
+
assert File.exists?(f)
|
23
|
+
r = MojoMagick::get_image_size(f.path)
|
24
|
+
assert r[:height] == 4 * 33
|
25
|
+
assert r[:width] == 4 * 33
|
11
26
|
end
|
12
27
|
|
13
28
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qr4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jon Rogers
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-03-18 00:00:00
|
19
|
-
default_executable:
|
18
|
+
date: 2012-03-18 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: rqrcode
|
@@ -82,7 +81,6 @@ files:
|
|
82
81
|
- lib/qr4r/version.rb~
|
83
82
|
- qr4r.gemspec
|
84
83
|
- test/qr4r_test.rb
|
85
|
-
has_rdoc: true
|
86
84
|
homepage: http://github.com/2rye/qr4r
|
87
85
|
licenses: []
|
88
86
|
|
@@ -112,9 +110,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
110
|
requirements: []
|
113
111
|
|
114
112
|
rubyforge_project: qr4r
|
115
|
-
rubygems_version: 1.
|
113
|
+
rubygems_version: 1.8.15
|
116
114
|
signing_key:
|
117
115
|
specification_version: 3
|
118
|
-
summary: qr4r-0.
|
116
|
+
summary: qr4r-0.2.0
|
119
117
|
test_files:
|
120
118
|
- test/qr4r_test.rb
|