qrencoder 1.2.0 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,7 @@ UPS labels) in North America; ShotCode in the UK; and an additional format used
20
20
  in Korea. All vary in look and capacity, but QR code has one of the largest
21
21
  information densities and capacities among them with the following maximum data
22
22
 
23
- * Numeric 7,089
23
+ * Numeric 7,089
24
24
  * Alphanumeric 4,296
25
25
  * 8-Bit 2,953
26
26
  * Kanji 1,817
@@ -51,19 +51,25 @@ pass to <tt>QREncoder#encode</tt>.
51
51
  This gem requires you to build the C library lib <tt>libqrcode.a</tt> available
52
52
  from http://megaui.net/fukuchi/works/qrencode/index.en.html.
53
53
 
54
- Normally, the build process also expects you to install <tt>libpng</tt>, but
55
- this is only used for the <tt>qrenc</tt> command-line utility and can be avoided
56
- if you run the following build sequence:
54
+ Installation is usually as simple as:
55
+
56
+ curl http://fukuchi.org/works/qrencode/qrencode-3.1.1.tar.gz | tar xz
57
+ cd qrencode-3.1.1
58
+ ./configure
59
+ make
60
+ sudo make install
61
+
62
+ If if worked, you should be able to type <tt>qrencode</tt> and get a help
63
+ message.
64
+
65
+ Normally, the build process also expects you to have <tt>libpng</tt>, but
66
+ this is only used for the <tt>qrenc</tt> command-line utility and can be
67
+ avoided if you run the following build sequence:
57
68
 
58
69
  ./configure --without-tools
59
70
  make
60
71
  sudo make install
61
72
 
62
- This gem also requires the following gems to be installed:
63
-
64
- * ruby-inline
65
- * png
66
-
67
73
  == INSTALLATION:
68
74
 
69
75
  * First build the <tt>libqrencode</tt> library following the instructions above.
@@ -1,7 +1,7 @@
1
1
  require 'mkmf'
2
2
 
3
- dir_config("qrencode")
3
+ dir_config("qrencoder")
4
4
 
5
5
  if have_header("qrencode.h") && have_library("qrencode", "QRinput_new")
6
- create_makefile("qrencoder_ext")
6
+ create_makefile("qrencoder/qrencoder_ext")
7
7
  end
@@ -1,4 +1,4 @@
1
- require 'png'
1
+ require 'chunky_png'
2
2
 
3
3
  module QREncoder
4
4
  # Stores and represents data, points, and/or pixels for a QRCode
@@ -22,7 +22,7 @@ module QREncoder
22
22
  # [:transparent] Background transparency. Can be true or false. (default: +false+)
23
23
  #
24
24
  def png(options={})
25
- PNG.new(canvas(options))
25
+ canvas(options)
26
26
  end
27
27
 
28
28
  ##
@@ -31,14 +31,14 @@ module QREncoder
31
31
  # Takes an optional hash of options. See QRCode#png for details.
32
32
  def canvas(options={})
33
33
  @margin = options[:margin] || 4
34
- background = options[:transparent] ? PNG::Color::Background : PNG::Color::White
34
+ background = options[:transparent] ? ChunkyPNG::Color::TRANSPARENT : ChunkyPNG::Color::WHITE
35
35
  png_width = width + (2 * @margin)
36
36
 
37
- canvas = PNG::Canvas.new(png_width, png_width, background)
37
+ canvas = ChunkyPNG::Image.new(png_width, png_width, background)
38
38
 
39
39
  points.each do |p|
40
40
  x, y = png_coordinates_for_point(p)
41
- canvas[x,y] = PNG::Color::Black
41
+ canvas[x,y] = ChunkyPNG::Color::BLACK
42
42
  end
43
43
 
44
44
  canvas
@@ -47,7 +47,7 @@ module QREncoder
47
47
  private
48
48
  def png_coordinates_for_point(point)
49
49
  x = point[0] + @margin
50
- y = width - 1 - point[1] + @margin
50
+ y = point[1] + @margin
51
51
  [x,y]
52
52
  end
53
53
  end
@@ -1,3 +1,3 @@
1
1
  module QREncoder
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.3'
3
3
  end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+ require 'zxing'
3
+
4
+ describe QREncoder do
5
+ context "full integration" do
6
+ shared_examples_for "decodable" do
7
+ let(:message) { 'a message' }
8
+ let(:path) do
9
+ File.expand_path("../../tmp/integration.png", __FILE__)
10
+ end
11
+ before { File.unlink(path) if File.file?(path) }
12
+ it "creates decodable QRCode png files" do
13
+ QREncoder.encode(message).save_png(path)
14
+ ZXing.decode(path).should == message
15
+ end
16
+ end
17
+ it_should_behave_like "decodable" do
18
+ let(:message) {"Oh my! I'm amazed by technology."}
19
+ end
20
+ it_should_behave_like "decodable" do
21
+ let(:message) {"&*@ad!jlfj-=+"}
22
+ end
23
+ end
24
+ end
@@ -146,15 +146,15 @@ describe QREncoder::QRCode do
146
146
  describe "#canvas" do
147
147
  let(:qrcode) { QREncoder.encode("hi") }
148
148
 
149
- it "returns an instance of PNG::Canvas" do
150
- qrcode.canvas.should be_kind_of(PNG::Canvas)
149
+ it "returns an instance of ChunkyPNG::Canvas" do
150
+ qrcode.canvas.should be_kind_of(ChunkyPNG::Canvas)
151
151
  end
152
152
 
153
153
  context "with no options specified" do
154
154
  subject { qrcode.canvas }
155
155
  its(:width) { should == qrcode.width + (4 * 2) }
156
156
  specify "background should be white" do
157
- subject.data.first.first.should == PNG::Color::White
157
+ subject.get_pixel(1,1).should == ChunkyPNG::Color::WHITE
158
158
  end
159
159
  end
160
160
 
@@ -166,7 +166,7 @@ describe QREncoder::QRCode do
166
166
  context "with transparent set to true" do
167
167
  subject { qrcode.canvas(:transparent => true) }
168
168
  specify "background should be transparent" do
169
- subject.data.first.first.should == PNG::Color::Background
169
+ subject.get_pixel(1,1).should == ChunkyPNG::Color::TRANSPARENT
170
170
  end
171
171
  end
172
172
  end
@@ -174,12 +174,12 @@ describe QREncoder::QRCode do
174
174
  describe "#png" do
175
175
  let(:qrcode) { QREncoder.encode("hi") }
176
176
 
177
- it "returns an instance of PNG" do
178
- qrcode.png.should be_kind_of(PNG)
177
+ it "returns an instance of ChunkyPNG" do
178
+ qrcode.png.should be_kind_of(ChunkyPNG::Image)
179
179
  end
180
180
 
181
181
  it "sends options to #canvas" do
182
- canvas = PNG::Canvas.new(1,1)
182
+ canvas = ChunkyPNG::Canvas.new(1,1)
183
183
  options = { :margin => 5, :transparent => true }
184
184
  qrcode.should_receive(:canvas).with(options).and_return(canvas)
185
185
  qrcode.png(options)
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qrencoder
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 2
8
- - 0
9
- version: 1.2.0
4
+ prerelease:
5
+ version: 1.3.3
10
6
  platform: ruby
11
7
  authors:
12
8
  - Jacob Harris
@@ -16,7 +12,7 @@ autorequire:
16
12
  bindir: bin
17
13
  cert_chain: []
18
14
 
19
- date: 2010-11-23 00:00:00 -06:00
15
+ date: 2011-03-08 00:00:00 -06:00
20
16
  default_executable:
21
17
  dependencies:
22
18
  - !ruby/object:Gem::Dependency
@@ -27,10 +23,6 @@ dependencies:
27
23
  requirements:
28
24
  - - ~>
29
25
  - !ruby/object:Gem::Version
30
- segments:
31
- - 2
32
- - 4
33
- - 0
34
26
  version: 2.4.0
35
27
  type: :development
36
28
  version_requirements: *id001
@@ -42,10 +34,6 @@ dependencies:
42
34
  requirements:
43
35
  - - ~>
44
36
  - !ruby/object:Gem::Version
45
- segments:
46
- - 0
47
- - 7
48
- - 5
49
37
  version: 0.7.5
50
38
  type: :development
51
39
  version_requirements: *id002
@@ -57,41 +45,29 @@ dependencies:
57
45
  requirements:
58
46
  - - ~>
59
47
  - !ruby/object:Gem::Version
60
- segments:
61
- - 0
62
- - 2
63
- - 20
64
48
  version: 0.2.20
65
49
  type: :development
66
50
  version_requirements: *id003
67
51
  - !ruby/object:Gem::Dependency
68
- name: png
52
+ name: zxing
69
53
  prerelease: false
70
54
  requirement: &id004 !ruby/object:Gem::Requirement
71
55
  none: false
72
56
  requirements:
73
57
  - - ~>
74
58
  - !ruby/object:Gem::Version
75
- segments:
76
- - 1
77
- - 2
78
- - 0
79
- version: 1.2.0
80
- type: :runtime
59
+ version: "0.2"
60
+ type: :development
81
61
  version_requirements: *id004
82
62
  - !ruby/object:Gem::Dependency
83
- name: RubyInline
63
+ name: chunky_png
84
64
  prerelease: false
85
65
  requirement: &id005 !ruby/object:Gem::Requirement
86
66
  none: false
87
67
  requirements:
88
- - - ">="
68
+ - - ~>
89
69
  - !ruby/object:Gem::Version
90
- segments:
91
- - 3
92
- - 6
93
- - 2
94
- version: 3.6.2
70
+ version: 1.0.1
95
71
  type: :runtime
96
72
  version_requirements: *id005
97
73
  description: |-
@@ -102,20 +78,20 @@ email:
102
78
  - josh@joshuadavey.com
103
79
  executables: []
104
80
 
105
- extensions: []
106
-
81
+ extensions:
82
+ - ext/qrencoder_ext/extconf.rb
107
83
  extra_rdoc_files:
108
84
  - README.rdoc
109
85
  - ext/qrencoder_ext/qrencoder_ext.c
110
86
  files:
111
87
  - lib/qrencoder/qrcode.rb
112
- - lib/qrencoder/qrencoder_ext.bundle
113
88
  - lib/qrencoder/version.rb
114
89
  - lib/qrencoder.rb
115
90
  - ext/qrencoder_ext/extconf.rb
116
91
  - ext/qrencoder_ext/qrencoder_ext.c
117
92
  - History.txt
118
93
  - README.rdoc
94
+ - spec/integration_spec.rb
119
95
  - spec/qrcode_spec.rb
120
96
  - spec/qrencoder_spec.rb
121
97
  - spec/spec_helper.rb
@@ -133,27 +109,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
109
  requirements:
134
110
  - - ">="
135
111
  - !ruby/object:Gem::Version
136
- segments:
137
- - 0
138
112
  version: "0"
139
113
  required_rubygems_version: !ruby/object:Gem::Requirement
140
114
  none: false
141
115
  requirements:
142
116
  - - ">="
143
117
  - !ruby/object:Gem::Version
144
- segments:
145
- - 1
146
- - 3
147
- - 6
148
118
  version: 1.3.6
149
119
  requirements: []
150
120
 
151
121
  rubyforge_project:
152
- rubygems_version: 1.3.7
122
+ rubygems_version: 1.6.0
153
123
  signing_key:
154
124
  specification_version: 3
155
125
  summary: Wrapper around the C qrencode library for creating QR Codes
156
126
  test_files:
127
+ - spec/integration_spec.rb
157
128
  - spec/qrcode_spec.rb
158
129
  - spec/qrencoder_spec.rb
159
130
  - spec/spec_helper.rb