barby-pdf417 0.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,192 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: barby-pdf417
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: java
6
+ authors:
7
+ - Felix Bellanger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rdoc
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: '4.0'
25
+ prerelease: false
26
+ type: :development
27
+ - !ruby/object:Gem::Dependency
28
+ name: hoe-bundler
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '1.1'
39
+ prerelease: false
40
+ type: :development
41
+ - !ruby/object:Gem::Dependency
42
+ name: hoe-debugging
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.3
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: 1.0.3
53
+ prerelease: false
54
+ type: :development
55
+ - !ruby/object:Gem::Dependency
56
+ name: hoe-gemspec
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '1.0'
67
+ prerelease: false
68
+ type: :development
69
+ - !ruby/object:Gem::Dependency
70
+ name: hoe-git
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '1.4'
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '1.4'
81
+ prerelease: false
82
+ type: :development
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 2.2.2
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ version: 2.2.2
95
+ prerelease: false
96
+ type: :development
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0.9'
104
+ requirement: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0.9'
109
+ prerelease: false
110
+ type: :development
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake-compiler
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.8.0
118
+ requirement: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ~>
121
+ - !ruby/object:Gem::Version
122
+ version: 0.8.0
123
+ prerelease: false
124
+ type: :development
125
+ - !ruby/object:Gem::Dependency
126
+ name: hoe
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: '3.7'
132
+ requirement: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ~>
135
+ - !ruby/object:Gem::Version
136
+ version: '3.7'
137
+ prerelease: false
138
+ type: :development
139
+ description: Pdf417 support for Barby.
140
+ email:
141
+ - felix.bellanger@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files:
145
+ - CHANGELOG.rdoc
146
+ - README.rdoc
147
+ - ext/pdf417/pdf417.c
148
+ - ext/pdf417/pdf417lib.c
149
+ files:
150
+ - CHANGELOG.rdoc
151
+ - Gemfile
152
+ - Gemfile.lock
153
+ - README.rdoc
154
+ - Rakefile
155
+ - ext/java/pdf417/Pdf417lib.java
156
+ - ext/pdf417/Makefile
157
+ - ext/pdf417/extconf.rb
158
+ - ext/pdf417/pdf417.c
159
+ - ext/pdf417/pdf417.h
160
+ - ext/pdf417/pdf417lib.c
161
+ - ext/pdf417/pdf417lib.h
162
+ - ext/pdf417/pdf417libimp.h
163
+ - lib/barby/barcode/pdf_417.rb
164
+ - .gemtest
165
+ - lib/barby/barby-pdf417.jar
166
+ homepage: http://toretore.github.com/barby
167
+ licenses:
168
+ - MIT
169
+ metadata: {}
170
+ post_install_message:
171
+ rdoc_options:
172
+ - --main
173
+ - README.rdoc
174
+ require_paths:
175
+ - lib
176
+ required_ruby_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ required_rubygems_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - '>='
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ requirements: []
187
+ rubyforge_project: barby-pdf417
188
+ rubygems_version: 2.1.9
189
+ signing_key:
190
+ specification_version: 4
191
+ summary: Pdf417 support for Barby.
192
+ test_files: []