barby-pdf417 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,88 @@
1
+ require 'barby/barcode'
2
+
3
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
4
+ require 'java'
5
+ require 'barby/barby-pdf417'
6
+ else
7
+ require 'pdf417_native'
8
+ end
9
+
10
+ module Barby
11
+ class Pdf417 < Barcode2D
12
+ DEFAULT_OPTIONS = {
13
+ :options => 0,
14
+ :y_height => 3,
15
+ :aspect_ratio => 0.5,
16
+ :error_level => 0,
17
+ :len_codewords => 0,
18
+ :code_rows => 0,
19
+ :code_columns => 0
20
+ }
21
+
22
+ # Creates a new Pdf417 barcode. The +options+ argument
23
+ # can use the same keys as DEFAULT_OPTIONS. Please consult
24
+ # the source code of Pdf417lib.java for details about values
25
+ # that can be used.
26
+ def initialize(data, options={})
27
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
28
+ @pdf417 = Java::Pdf417lib.new
29
+ else
30
+ @pdf417 = ::Pdf417::Lib.new
31
+ end
32
+
33
+ self.data = data
34
+ DEFAULT_OPTIONS.merge(options).each{|k,v| send("#{k}=", v) }
35
+ end
36
+
37
+ def options=(options)
38
+ @options = options
39
+ end
40
+
41
+ def y_height=(y_height)
42
+ @pdf417.setYHeight(y_height)
43
+ end
44
+
45
+ def aspect_ratio=(aspect_ratio)
46
+ @pdf417.setAspectRatio(aspect_ratio)
47
+ end
48
+
49
+ def error_level=(error_level)
50
+ @pdf417.setErrorLevel(error_level)
51
+ end
52
+
53
+ def len_codewords=(len_codewords)
54
+ @pdf417.setLenCodewords(len_codewords)
55
+ end
56
+
57
+ def code_rows=(code_rows)
58
+ @pdf417.setCodeRows(code_rows)
59
+ end
60
+
61
+ def code_columns=(code_columns)
62
+ @pdf417.setCodeColumns(code_columns)
63
+ end
64
+
65
+ def data=(data)
66
+ @pdf417.setText(data)
67
+ end
68
+
69
+ def encoding
70
+ @pdf417.paintCode()
71
+
72
+ cols = (@pdf417.getBitColumns() - 1) / 8 + 1
73
+ enc = nil
74
+
75
+ # Compute encoding
76
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
77
+ enc = String.from_java_bytes(@pdf417.getOutBits)
78
+ else
79
+ enc = @pdf417.getOutBits
80
+ end
81
+ enc = enc.bytes.to_a.each_slice(cols).to_a[0..(@pdf417.getCodeRows-1)]
82
+
83
+ return enc.collect do |row_of_bytes|
84
+ row_of_bytes.collect { |byte| sprintf("%08b", byte) }.join[0..@pdf417.getBitColumns-1]
85
+ end
86
+ end
87
+ end
88
+ end
metadata ADDED
@@ -0,0 +1,211 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: barby-pdf417
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Felix Bellanger
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-12-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rdoc
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '4.0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '4.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: hoe-bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '1.1'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '1.1'
46
+ - !ruby/object:Gem::Dependency
47
+ name: hoe-debugging
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.0.3
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.3
62
+ - !ruby/object:Gem::Dependency
63
+ name: hoe-gemspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '1.0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '1.0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: hoe-git
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '1.4'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '1.4'
94
+ - !ruby/object:Gem::Dependency
95
+ name: minitest
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 2.2.2
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 2.2.2
110
+ - !ruby/object:Gem::Dependency
111
+ name: rake
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0.9'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0.9'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rake-compiler
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 0.8.0
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 0.8.0
142
+ - !ruby/object:Gem::Dependency
143
+ name: hoe
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: '3.7'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: '3.7'
158
+ description: Pdf417 support for Barby.
159
+ email:
160
+ - felix.bellanger@gmail.com
161
+ executables: []
162
+ extensions:
163
+ - ext/pdf417/extconf.rb
164
+ extra_rdoc_files:
165
+ - CHANGELOG.rdoc
166
+ - README.rdoc
167
+ - ext/pdf417/pdf417.c
168
+ - ext/pdf417/pdf417lib.c
169
+ files:
170
+ - CHANGELOG.rdoc
171
+ - Gemfile
172
+ - Gemfile.lock
173
+ - README.rdoc
174
+ - Rakefile
175
+ - ext/pdf417/Makefile
176
+ - ext/pdf417/extconf.rb
177
+ - ext/pdf417/pdf417.c
178
+ - ext/pdf417/pdf417.h
179
+ - ext/pdf417/pdf417lib.c
180
+ - ext/pdf417/pdf417lib.h
181
+ - ext/pdf417/pdf417libimp.h
182
+ - lib/barby/barcode/pdf_417.rb
183
+ - .gemtest
184
+ homepage: http://toretore.github.com/barby
185
+ licenses:
186
+ - MIT
187
+ post_install_message:
188
+ rdoc_options:
189
+ - --main
190
+ - README.rdoc
191
+ require_paths:
192
+ - lib
193
+ required_ruby_version: !ruby/object:Gem::Requirement
194
+ none: false
195
+ requirements:
196
+ - - ! '>='
197
+ - !ruby/object:Gem::Version
198
+ version: 1.9.2
199
+ required_rubygems_version: !ruby/object:Gem::Requirement
200
+ none: false
201
+ requirements:
202
+ - - ! '>='
203
+ - !ruby/object:Gem::Version
204
+ version: '0'
205
+ requirements: []
206
+ rubyforge_project: barby-pdf417
207
+ rubygems_version: 1.8.25
208
+ signing_key:
209
+ specification_version: 3
210
+ summary: Pdf417 support for Barby.
211
+ test_files: []