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.
@@ -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
 
@@ -26,9 +26,9 @@ module HasBarcode
26
26
  end
27
27
  end
28
28
 
29
- define_method "#{args.first}_data" do |opts = nil|
30
- if opts
31
- send(args.first).send("to_#{options[:outputter]}", opts)
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
- require "barby/barcode/#{opts[:type]}"
10
- @barcode_class = Barby.const_get(ActiveSupport::Inflector.classify("#{opts[:type].to_s}"))
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"))
@@ -1,3 +1,3 @@
1
1
  module HasBarcode
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -8,17 +8,31 @@ describe "a barcode configuration" do
8
8
  )
9
9
  end
10
10
 
11
- it "should have a name" do
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 "should have a barcode class" do
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 "should have an outputter" do
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
- end
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
- version: 0.2.2
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
- date: 2012-12-10 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
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
- requirement: !ruby/object:Gem::Requirement
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
17
24
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '3'
22
- type: :runtime
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
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
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
- requirement: !ruby/object:Gem::Requirement
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
33
38
  none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :runtime
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
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
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
- requirement: !ruby/object:Gem::Requirement
51
+ version_requirements: &id003 !ruby/object:Gem::Requirement
49
52
  none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :runtime
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
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
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
- requirement: !ruby/object:Gem::Requirement
65
+ version_requirements: &id004 !ruby/object:Gem::Requirement
65
66
  none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :runtime
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
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
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
- requirement: !ruby/object:Gem::Requirement
79
+ version_requirements: &id005 !ruby/object:Gem::Requirement
81
80
  none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :development
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
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
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
- requirement: !ruby/object:Gem::Requirement
93
+ version_requirements: &id006 !ruby/object:Gem::Requirement
97
94
  none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- type: :development
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
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
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
- requirement: !ruby/object:Gem::Requirement
107
+ version_requirements: &id007 !ruby/object:Gem::Requirement
113
108
  none: false
114
- requirements:
115
- - - ! '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
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
- files:
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
- require_paths:
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
- version: '0'
162
- segments:
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ hash: 3
159
+ segments:
163
160
  - 0
164
- hash: -3678793755858108082
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
- version: '0'
171
- segments:
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ hash: 3
168
+ segments:
172
169
  - 0
173
- hash: -3678793755858108082
170
+ version: "0"
174
171
  requirements: []
172
+
175
173
  rubyforge_project:
176
- rubygems_version: 1.8.23
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