has_barcode 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +13 -0
- data/lib/has_barcode.rb +3 -3
- data/lib/has_barcode/configuration.rb +6 -2
- data/lib/has_barcode/version.rb +1 -1
- data/spec/has_barcode/configuration_spec.rb +18 -4
- metadata +115 -117
data/README.rdoc
CHANGED
@@ -20,6 +20,19 @@ A nice wrapper for Barcode generation using {barby}[https://github.com/toretore/
|
|
20
20
|
Product.new.barcode # => Barby::Code39 object
|
21
21
|
Product.new.barcode_data # => <Barby::Code39 object>.to_png
|
22
22
|
|
23
|
+
You can also pass the Barby barcode type directly like:
|
24
|
+
|
25
|
+
require 'barby/barcode/code_39'
|
26
|
+
class Product
|
27
|
+
include HasBarcode
|
28
|
+
|
29
|
+
has_barcode :barcode,
|
30
|
+
:outputter => :png,
|
31
|
+
:type => Barby::Code39,
|
32
|
+
:value => Proc.new { |p| p.number }
|
33
|
+
end
|
34
|
+
|
35
|
+
|
23
36
|
== Why has_barcode is a good choice for Heroku
|
24
37
|
Other libraries – such as {barcode_generator}[https://github.com/anujluthra/barcode-generator] – commonly rely on {gbarcode}[https://github.com/ahx/gbarcode], a GNU Barcode C library. This is problem since you need to install GNU barcode which {Heroku does not support}[https://github.com/perezd/barcoder/issues/1]. Luckily <tt>has_barcode</tt> doesn't have this dependency.
|
25
38
|
|
data/lib/has_barcode.rb
CHANGED
@@ -26,9 +26,9 @@ module HasBarcode
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
define_method "#{args.first}_data" do |
|
30
|
-
if
|
31
|
-
send(args.first).send("to_#{options[:outputter]}",
|
29
|
+
define_method "#{args.first}_data" do |*meth_args|
|
30
|
+
if meth_args
|
31
|
+
send(args.first).send("to_#{options[:outputter]}", *meth_args)
|
32
32
|
else
|
33
33
|
send(args.first).send("to_#{options[:outputter]}")
|
34
34
|
end
|
@@ -6,8 +6,12 @@ module HasBarcode
|
|
6
6
|
|
7
7
|
@name = args.first
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
if opts[:type].kind_of?(String) || opts[:type].kind_of?(Symbol)
|
10
|
+
require "barby/barcode/#{opts[:type]}"
|
11
|
+
@barcode_class = Barby.const_get(ActiveSupport::Inflector.classify("#{opts[:type].to_s}"))
|
12
|
+
else
|
13
|
+
@barcode_class = opts[:type]
|
14
|
+
end
|
11
15
|
|
12
16
|
require "barby/outputter/#{opts[:outputter]}_outputter"
|
13
17
|
@outputter = Barby.const_get(ActiveSupport::Inflector.classify("#{opts[:outputter]}_outputter"))
|
data/lib/has_barcode/version.rb
CHANGED
@@ -8,17 +8,31 @@ describe "a barcode configuration" do
|
|
8
8
|
)
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
11
|
+
it "has a name" do
|
12
12
|
@configuration.name.should_not be_nil
|
13
13
|
@configuration.name.should eql(:barcode)
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
16
|
+
it "has a barcode class derived from the symbol" do
|
17
17
|
@configuration.barcode_class.should eql(Barby::Code39)
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
20
|
+
it "has a barcode class that can be derived via string" do
|
21
|
+
@configuration = HasBarcode::Configuration.new(:barcode,
|
22
|
+
:outputter => :png,
|
23
|
+
:type => 'code_39'
|
24
|
+
)
|
25
|
+
@configuration.barcode_class.should eql(Barby::Code39)
|
26
|
+
end
|
21
27
|
|
22
|
-
|
28
|
+
it 'can take a barcode class directly' do
|
29
|
+
require 'barby/barcode/code_39'
|
30
|
+
@configuration = HasBarcode::Configuration.new(:barcode,
|
31
|
+
:outputter => :png,
|
32
|
+
:type => Barby::Code39
|
33
|
+
)
|
34
|
+
|
35
|
+
|
36
|
+
end
|
23
37
|
end
|
24
38
|
|
metadata
CHANGED
@@ -1,135 +1,130 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_barcode
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Dan Pickett
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2013-02-13 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
type: :runtime
|
15
22
|
name: activesupport
|
16
|
-
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
22
|
-
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 5
|
29
|
+
segments:
|
30
|
+
- 3
|
31
|
+
version: "3"
|
32
|
+
requirement: *id001
|
23
33
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '3'
|
30
|
-
- !ruby/object:Gem::Dependency
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
type: :runtime
|
31
36
|
name: i18n
|
32
|
-
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
33
38
|
none: false
|
34
|
-
requirements:
|
35
|
-
- -
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
|
38
|
-
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
requirement: *id002
|
39
47
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
type: :runtime
|
47
50
|
name: barby
|
48
|
-
|
51
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
49
52
|
none: false
|
50
|
-
requirements:
|
51
|
-
- -
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
|
54
|
-
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
requirement: *id003
|
55
61
|
prerelease: false
|
56
|
-
|
57
|
-
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
type: :runtime
|
63
64
|
name: rake
|
64
|
-
|
65
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
65
66
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
|
70
|
-
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
requirement: *id004
|
71
75
|
prerelease: false
|
72
|
-
|
73
|
-
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
type: :development
|
79
78
|
name: rspec
|
80
|
-
|
79
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
81
80
|
none: false
|
82
|
-
requirements:
|
83
|
-
- -
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
|
86
|
-
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
requirement: *id005
|
87
89
|
prerelease: false
|
88
|
-
|
89
|
-
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
94
|
-
- !ruby/object:Gem::Dependency
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
type: :development
|
95
92
|
name: chunky_png
|
96
|
-
|
93
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
97
94
|
none: false
|
98
|
-
requirements:
|
99
|
-
- -
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
|
102
|
-
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
requirement: *id006
|
103
103
|
prerelease: false
|
104
|
-
|
105
|
-
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
- !ruby/object:Gem::Dependency
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
type: :development
|
111
106
|
name: yard
|
112
|
-
|
107
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
113
108
|
none: false
|
114
|
-
requirements:
|
115
|
-
- -
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
|
118
|
-
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
hash: 3
|
113
|
+
segments:
|
114
|
+
- 0
|
115
|
+
version: "0"
|
116
|
+
requirement: *id007
|
119
117
|
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ! '>='
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '0'
|
126
118
|
description: Nice class method wrapper for Barby
|
127
|
-
email:
|
119
|
+
email:
|
128
120
|
- dpickett@enlightsolutions.com
|
129
121
|
executables: []
|
122
|
+
|
130
123
|
extensions: []
|
124
|
+
|
131
125
|
extra_rdoc_files: []
|
132
|
-
|
126
|
+
|
127
|
+
files:
|
133
128
|
- .document
|
134
129
|
- .gitignore
|
135
130
|
- .rspec
|
@@ -147,37 +142,40 @@ files:
|
|
147
142
|
- spec/has_barcode_spec.rb
|
148
143
|
- spec/models/has_png_barcode.rb
|
149
144
|
- spec/spec_helper.rb
|
150
|
-
homepage:
|
145
|
+
homepage: ""
|
151
146
|
licenses: []
|
147
|
+
|
152
148
|
post_install_message:
|
153
149
|
rdoc_options: []
|
154
|
-
|
150
|
+
|
151
|
+
require_paths:
|
155
152
|
- lib
|
156
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
154
|
none: false
|
158
|
-
requirements:
|
159
|
-
- -
|
160
|
-
- !ruby/object:Gem::Version
|
161
|
-
|
162
|
-
segments:
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
hash: 3
|
159
|
+
segments:
|
163
160
|
- 0
|
164
|
-
|
165
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
version: "0"
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
163
|
none: false
|
167
|
-
requirements:
|
168
|
-
- -
|
169
|
-
- !ruby/object:Gem::Version
|
170
|
-
|
171
|
-
segments:
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
hash: 3
|
168
|
+
segments:
|
172
169
|
- 0
|
173
|
-
|
170
|
+
version: "0"
|
174
171
|
requirements: []
|
172
|
+
|
175
173
|
rubyforge_project:
|
176
|
-
rubygems_version: 1.8.
|
174
|
+
rubygems_version: 1.8.25
|
177
175
|
signing_key:
|
178
176
|
specification_version: 3
|
179
177
|
summary: Nice class method wrapper for Barby
|
180
|
-
test_files:
|
178
|
+
test_files:
|
181
179
|
- spec/has_barcode/configuration_spec.rb
|
182
180
|
- spec/has_barcode_spec.rb
|
183
181
|
- spec/models/has_png_barcode.rb
|