zint 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/Gemfile +4 -0
- data/README.rdoc +47 -0
- data/Rakefile +15 -0
- data/lib/zint.rb +11 -0
- data/lib/zint/barcode.rb +62 -0
- data/lib/zint/data_matrix.rb +8 -0
- data/lib/zint/ean.rb +7 -0
- data/lib/zint/exception.rb +4 -0
- data/lib/zint/qrcode.rb +14 -0
- data/lib/zint/upc.rb +7 -0
- data/lib/zint/version.rb +3 -0
- data/lib/zint/wrapper.rb +160 -0
- data/lib/zint/zint_symbol.rb +36 -0
- data/test/fixtures/code128.eps +128 -0
- data/test/fixtures/code128.png +0 -0
- data/test/fixtures/code128.svg +113 -0
- data/test/fixtures/qrcode.ecc_h.png +0 -0
- data/test/fixtures/qrcode.eps +235 -0
- data/test/fixtures/qrcode.png +0 -0
- data/test/fixtures/qrcode.rev.png +0 -0
- data/test/fixtures/qrcode.svg +179 -0
- data/test/qrcode_test.rb +59 -0
- data/test/test_helper.rb +5 -0
- data/test/zint_test.rb +43 -0
- data/zint.gemspec +26 -0
- metadata +152 -0
data/test/qrcode_test.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__) , 'test_helper')
|
2
|
+
|
3
|
+
class QRCodeTest < Test::Unit::TestCase
|
4
|
+
context "Canary" do
|
5
|
+
# canary test.
|
6
|
+
should "survive the canary test" do
|
7
|
+
assert true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "QRCodeTest" do
|
12
|
+
setup do
|
13
|
+
@bc = Zint::QRCode.new("http://rubygems.org/gems/zint")
|
14
|
+
end
|
15
|
+
|
16
|
+
should "create an object" do
|
17
|
+
assert @bc
|
18
|
+
end
|
19
|
+
|
20
|
+
should "set the proper symbology" do
|
21
|
+
assert_equal(Zint::BARCODE_QRCODE, @bc.bctype)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Actually the Zint library itself does not do this. Its a bug
|
25
|
+
# on their side.
|
26
|
+
# should "encode the proper value into the C zint_symbol struct" do
|
27
|
+
# @bc.encode!
|
28
|
+
# assert_equal(@bc.value, @bc.zint_symbol[:text].to_s)
|
29
|
+
# end
|
30
|
+
|
31
|
+
should "create a PNG file" do
|
32
|
+
@bc.print!
|
33
|
+
assert File.exists?(@bc.path)
|
34
|
+
end
|
35
|
+
|
36
|
+
should "create a PNG file that is the same as the test fixture" do
|
37
|
+
require 'md5'
|
38
|
+
@bc.print!
|
39
|
+
test_fixture = File.join(File.dirname(__FILE__) , 'fixtures', "qrcode.png")
|
40
|
+
assert_equal(MD5.file(test_fixture) , MD5.file(@bc.path))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
context "QRCode High ECC" do
|
44
|
+
setup do
|
45
|
+
@bc = Zint::QRCode.new("http://rubygems.org/gems/zint", Zint::QRCode::ECC_H)
|
46
|
+
end
|
47
|
+
|
48
|
+
should "create an object" do
|
49
|
+
assert @bc
|
50
|
+
end
|
51
|
+
|
52
|
+
should "create a PNG file that is the same as the test fixture" do
|
53
|
+
require 'md5'
|
54
|
+
@bc.print!
|
55
|
+
test_fixture = File.join(File.dirname(__FILE__) , 'fixtures', "qrcode.ecc_h.png")
|
56
|
+
assert_equal(MD5.file(test_fixture) , MD5.file(@bc.path))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/test/test_helper.rb
ADDED
data/test/zint_test.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__) , 'test_helper')
|
2
|
+
|
3
|
+
class ZintTest < Test::Unit::TestCase
|
4
|
+
context "Canary" do
|
5
|
+
# canary test.
|
6
|
+
should "survive the canary test" do
|
7
|
+
assert true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "ZintTest" do
|
12
|
+
setup do
|
13
|
+
@bc = Zint::Barcode.new("http://rubygems.org/gems/zint")
|
14
|
+
end
|
15
|
+
|
16
|
+
should "create a barcode object" do
|
17
|
+
assert @bc
|
18
|
+
end
|
19
|
+
|
20
|
+
should "assign the barcode's value on create" do
|
21
|
+
assert_equal("http://rubygems.org/gems/zint", @bc.value)
|
22
|
+
end
|
23
|
+
|
24
|
+
should "encode the proper value into the C zint_symbol struct" do
|
25
|
+
@bc.encode!
|
26
|
+
assert_equal(@bc.value, @bc.zint_symbol[:text].to_s, "ERRRR #{@bc.zint_symbol[:text]}")
|
27
|
+
end
|
28
|
+
|
29
|
+
# should probably define a new context for encoding tests against the fixtures
|
30
|
+
should "encode a barcode as PNG to filesystem" do
|
31
|
+
test_case = File.read(File.join(File.dirname(__FILE__), "fixtures", "code128.png"))
|
32
|
+
@bc.print!
|
33
|
+
assert_equal(test_case, File.read(@bc.path))
|
34
|
+
end
|
35
|
+
|
36
|
+
should "encode a barcode as PNG to raw byte string PNG" do
|
37
|
+
test_case = File.read(File.join(File.dirname(__FILE__), "fixtures", "code128.png"))
|
38
|
+
query_case = @bc.buffer!
|
39
|
+
assert_equal(test_case, query_case)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
data/zint.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/zint/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "zint"
|
6
|
+
s.version = Zint::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = "Angel Pizarro"
|
9
|
+
s.email = "angel@delagoya.com"
|
10
|
+
s.homepage = "http://rubygems.org/gems/zint"
|
11
|
+
s.summary = "Ruby FFI wrapper on Zint barcode library"
|
12
|
+
s.description = "Ruby FFI wrapper on Zint barcode library. See README for more details"
|
13
|
+
|
14
|
+
s.required_rubygems_version = ">= 1.3.7"
|
15
|
+
s.rubyforge_project = "zint"
|
16
|
+
|
17
|
+
s.add_dependency("ffi", "~> 0.6")
|
18
|
+
|
19
|
+
s.add_development_dependency "bundler", "~> 1.0"
|
20
|
+
s.add_development_dependency "shoulda", "~> 2.11"
|
21
|
+
s.add_development_dependency "yard"
|
22
|
+
|
23
|
+
s.files = `git ls-files`.split("\n")
|
24
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
25
|
+
s.require_path = 'lib'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zint
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Angel Pizarro
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-19 00:00:00 +00:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 7
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 6
|
31
|
+
version: "0.6"
|
32
|
+
requirement: *id001
|
33
|
+
type: :runtime
|
34
|
+
name: ffi
|
35
|
+
prerelease: false
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 15
|
43
|
+
segments:
|
44
|
+
- 1
|
45
|
+
- 0
|
46
|
+
version: "1.0"
|
47
|
+
requirement: *id002
|
48
|
+
type: :development
|
49
|
+
name: bundler
|
50
|
+
prerelease: false
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 21
|
58
|
+
segments:
|
59
|
+
- 2
|
60
|
+
- 11
|
61
|
+
version: "2.11"
|
62
|
+
requirement: *id003
|
63
|
+
type: :development
|
64
|
+
name: shoulda
|
65
|
+
prerelease: false
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
requirement: *id004
|
77
|
+
type: :development
|
78
|
+
name: yard
|
79
|
+
prerelease: false
|
80
|
+
description: Ruby FFI wrapper on Zint barcode library. See README for more details
|
81
|
+
email: angel@delagoya.com
|
82
|
+
executables: []
|
83
|
+
|
84
|
+
extensions: []
|
85
|
+
|
86
|
+
extra_rdoc_files: []
|
87
|
+
|
88
|
+
files:
|
89
|
+
- .gitignore
|
90
|
+
- Gemfile
|
91
|
+
- README.rdoc
|
92
|
+
- Rakefile
|
93
|
+
- lib/zint.rb
|
94
|
+
- lib/zint/barcode.rb
|
95
|
+
- lib/zint/data_matrix.rb
|
96
|
+
- lib/zint/ean.rb
|
97
|
+
- lib/zint/exception.rb
|
98
|
+
- lib/zint/qrcode.rb
|
99
|
+
- lib/zint/upc.rb
|
100
|
+
- lib/zint/version.rb
|
101
|
+
- lib/zint/wrapper.rb
|
102
|
+
- lib/zint/zint_symbol.rb
|
103
|
+
- test/fixtures/code128.eps
|
104
|
+
- test/fixtures/code128.png
|
105
|
+
- test/fixtures/code128.svg
|
106
|
+
- test/fixtures/qrcode.ecc_h.png
|
107
|
+
- test/fixtures/qrcode.eps
|
108
|
+
- test/fixtures/qrcode.png
|
109
|
+
- test/fixtures/qrcode.rev.png
|
110
|
+
- test/fixtures/qrcode.svg
|
111
|
+
- test/qrcode_test.rb
|
112
|
+
- test/test_helper.rb
|
113
|
+
- test/zint_test.rb
|
114
|
+
- zint.gemspec
|
115
|
+
has_rdoc: true
|
116
|
+
homepage: http://rubygems.org/gems/zint
|
117
|
+
licenses: []
|
118
|
+
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
hash: 3
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
version: "0"
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
none: false
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
hash: 21
|
139
|
+
segments:
|
140
|
+
- 1
|
141
|
+
- 3
|
142
|
+
- 7
|
143
|
+
version: 1.3.7
|
144
|
+
requirements: []
|
145
|
+
|
146
|
+
rubyforge_project: zint
|
147
|
+
rubygems_version: 1.3.7
|
148
|
+
signing_key:
|
149
|
+
specification_version: 3
|
150
|
+
summary: Ruby FFI wrapper on Zint barcode library
|
151
|
+
test_files: []
|
152
|
+
|