zebra-zpl 1.0.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +71 -0
  3. data/CONTRIBUTING.md +49 -0
  4. data/Gemfile +6 -0
  5. data/README.md +348 -89
  6. data/docs/example.rb +290 -0
  7. data/docs/images/barcode.png +0 -0
  8. data/docs/images/datamatrix.png +0 -0
  9. data/docs/images/earth.jpg +0 -0
  10. data/docs/images/graphics.png +0 -0
  11. data/docs/images/image.png +0 -0
  12. data/docs/images/image_inverted.png +0 -0
  13. data/docs/images/image_manipulation.png +0 -0
  14. data/docs/images/images.png +0 -0
  15. data/docs/images/justification.png +0 -0
  16. data/docs/images/qrcode.png +0 -0
  17. data/docs/images/rotation.png +0 -0
  18. data/docs/images/text.png +0 -0
  19. data/lib/zebra/print_job.rb +19 -17
  20. data/lib/zebra/zpl.rb +26 -18
  21. data/lib/zebra/zpl/barcode.rb +29 -12
  22. data/lib/zebra/zpl/barcode_type.rb +4 -1
  23. data/lib/zebra/zpl/box.rb +16 -4
  24. data/lib/zebra/zpl/comment.rb +15 -0
  25. data/lib/zebra/zpl/datamatrix.rb +76 -0
  26. data/lib/zebra/zpl/font.rb +1 -1
  27. data/lib/zebra/zpl/graphic.rb +91 -0
  28. data/lib/zebra/zpl/image.rb +97 -0
  29. data/lib/zebra/zpl/label.rb +3 -14
  30. data/lib/zebra/zpl/pdf417.rb +50 -0
  31. data/lib/zebra/zpl/qrcode.rb +6 -2
  32. data/lib/zebra/zpl/raw.rb +25 -0
  33. data/lib/zebra/zpl/text.rb +44 -20
  34. data/lib/zebra/zpl/version.rb +1 -1
  35. data/spec/fixtures/default.jpg +0 -0
  36. data/spec/spec_helper.rb +6 -2
  37. data/spec/zebra/print_job_spec.rb +13 -18
  38. data/spec/zebra/zpl/barcode_spec.rb +70 -63
  39. data/spec/zebra/zpl/box_spec.rb +27 -31
  40. data/spec/zebra/zpl/character_set_spec.rb +7 -7
  41. data/spec/zebra/zpl/comment_spec.rb +18 -0
  42. data/spec/zebra/zpl/datamatrix_spec.rb +124 -0
  43. data/spec/zebra/zpl/graphics_spec.rb +227 -0
  44. data/spec/zebra/zpl/image_spec.rb +146 -0
  45. data/spec/zebra/zpl/label_spec.rb +41 -53
  46. data/spec/zebra/zpl/pdf417_spec.rb +108 -0
  47. data/spec/zebra/zpl/qrcode_spec.rb +92 -92
  48. data/spec/zebra/zpl/text_spec.rb +60 -55
  49. data/zebra-zpl.gemspec +12 -12
  50. metadata +63 -27
@@ -3,46 +3,46 @@ require 'spec_helper'
3
3
 
4
4
  describe Zebra::Zpl::Text do
5
5
  it "can be initialized with the position of the text to be printed" do
6
- text = described_class.new :position => [20, 40]
7
- text.position.should == [20,40]
8
- text.x.should == 20
9
- text.y.should == 40
6
+ text = described_class.new position: [20, 40]
7
+ expect(text.position).to eq [20,40]
8
+ expect(text.x).to eq 20
9
+ expect(text.y).to eq 40
10
10
  end
11
11
 
12
12
  it "can be initialized with the text rotation" do
13
13
  rotation = Zebra::Zpl::Rotation::DEGREES_90
14
- text = described_class.new :rotation => rotation
15
- text.rotation.should == rotation
14
+ text = described_class.new rotation: rotation
15
+ expect(text.rotation).to eq rotation
16
16
  end
17
17
 
18
18
  it "can be initialized with the font_size to be used" do
19
19
  font_size = Zebra::Zpl::FontSize::SIZE_1
20
- text = described_class.new :font_size => font_size
21
- text.font_size.should == font_size
20
+ text = described_class.new font_size: font_size
21
+ expect(text.font_size).to eq font_size
22
22
  end
23
23
 
24
- it "can be initialized with the horizontal multiplier" do
25
- multiplier = Zebra::Zpl::HorizontalMultiplier::VALUE_1
26
- text = described_class.new :h_multiplier => multiplier
27
- text.h_multiplier.should == multiplier
28
- end
29
-
30
- it "can be initialized with the vertical multiplier" do
31
- multiplier = Zebra::Zpl::VerticalMultiplier::VALUE_1
32
- text = described_class.new :v_multiplier => multiplier
33
- text.v_multiplier.should == multiplier
34
- end
24
+ # it "can be initialized with the horizontal multiplier" do
25
+ # multiplier = Zebra::Zpl::HorizontalMultiplier::VALUE_1
26
+ # text = described_class.new h_multiplier: multiplier
27
+ # expect(text.h_multiplier).to eq multiplier
28
+ # end
29
+ #
30
+ # it "can be initialized with the vertical multiplier" do
31
+ # multiplier = Zebra::Zpl::VerticalMultiplier::VALUE_1
32
+ # text = described_class.new v_multiplier: multiplier
33
+ # expect(text.v_multiplier).to eq multiplier
34
+ # end
35
35
 
36
36
  it "can be initialized with the data to be printed" do
37
37
  data = "foobar"
38
- text = described_class.new :data => data
39
- text.data.should == data
38
+ text = described_class.new data: data
39
+ expect(text.data).to eq data
40
40
  end
41
41
 
42
42
  it "can be initialized with the printing mode" do
43
43
  print_mode = Zebra::Zpl::PrintMode::REVERSE
44
- text = described_class.new :print_mode => print_mode
45
- text.print_mode.should == print_mode
44
+ text = described_class.new print_mode: print_mode
45
+ expect(text.print_mode).to eq print_mode
46
46
  end
47
47
 
48
48
  describe "#rotation=" do
@@ -56,26 +56,29 @@ describe Zebra::Zpl::Text do
56
56
  describe "#font_size=" do
57
57
  it "raises an error if the received font_size is invalid" do
58
58
  expect {
59
- described_class.new.font_size = 6
59
+ described_class.new.font_size = -1
60
60
  }.to raise_error(Zebra::Zpl::FontSize::InvalidFontSizeError)
61
- end
62
- end
63
-
64
- describe "#h_multiplier=" do
65
- it "raises an error if the received multiplier is invalid" do
66
61
  expect {
67
- described_class.new.h_multiplier = 9
68
- }.to raise_error(Zebra::Zpl::HorizontalMultiplier::InvalidMultiplierError)
62
+ described_class.new.font_size = 32001
63
+ }.to raise_error(Zebra::Zpl::FontSize::InvalidFontSizeError)
69
64
  end
70
65
  end
71
66
 
72
- describe "#v_multiplier=" do
73
- it "raises an error if the received multiplier is invalid" do
74
- expect {
75
- described_class.new.v_multiplier = 10
76
- }.to raise_error(Zebra::Zpl::VerticalMultiplier::InvalidMultiplierError)
77
- end
78
- end
67
+ # describe "#h_multiplier=" do
68
+ # it "raises an error if the received multiplier is invalid" do
69
+ # expect {
70
+ # described_class.new.h_multiplier = 9
71
+ # }.to raise_error(Zebra::Zpl::HorizontalMultiplier::InvalidMultiplierError)
72
+ # end
73
+ # end
74
+ #
75
+ # describe "#v_multiplier=" do
76
+ # it "raises an error if the received multiplier is invalid" do
77
+ # expect {
78
+ # described_class.new.v_multiplier = 10
79
+ # }.to raise_error(Zebra::Zpl::VerticalMultiplier::InvalidMultiplierError)
80
+ # end
81
+ # end
79
82
 
80
83
  describe "#print_mode=" do
81
84
  it "raises an error if the received print mode is invalid" do
@@ -86,24 +89,26 @@ describe Zebra::Zpl::Text do
86
89
  end
87
90
 
88
91
  describe "#to_zpl" do
89
- subject(:text) { described_class.new :position => [100, 150], :font_size => Zebra::Zpl::FontSize::SIZE_3, :data => "foobar" }
92
+ subject(:text) { described_class.new position: [100, 150], font_size: Zebra::Zpl::FontSize::SIZE_3, data: "foobar" }
93
+ subject(:text_bold) { described_class.new position: [100, 150], font_size: Zebra::Zpl::FontSize::SIZE_3, bold: true, data: "foobar" }
94
+ subject(:tokens) { text.to_zpl.split(/(\^[A-Z]+|\,)/).reject{ |e| ['', ',', nil].include?(e) } }
90
95
 
91
96
  it "raises an error if the X position was not informed" do
92
- text = described_class.new :position => [nil, 100], :data => "foobar"
97
+ text = described_class.new position: [nil, 100], data: "foobar"
93
98
  expect {
94
99
  text.to_zpl
95
100
  }.to raise_error(Zebra::Zpl::Printable::MissingAttributeError, "Can't print if the X value is not given")
96
101
  end
97
102
 
98
103
  it "raises an error if the Y position was not informed" do
99
- text = described_class.new :position => [100, nil]
104
+ text = described_class.new position: [100, nil]
100
105
  expect {
101
106
  text.to_zpl
102
107
  }.to raise_error(Zebra::Zpl::Printable::MissingAttributeError, "Can't print if the Y value is not given")
103
108
  end
104
109
 
105
110
  it "raises an error if the font_size is not informed" do
106
- text = described_class.new :position => [100, 100], :data => "foobar"
111
+ text = described_class.new position: [100, 100], data: "foobar"
107
112
  expect {
108
113
  text.to_zpl
109
114
  }.to raise_error(Zebra::Zpl::Printable::MissingAttributeError, "Can't print if the font_size to be used is not given")
@@ -116,24 +121,24 @@ describe Zebra::Zpl::Text do
116
121
  }.to raise_error(Zebra::Zpl::Printable::MissingAttributeError, "Can't print if the data to be printed is not given")
117
122
  end
118
123
 
119
- it "begins width the 'A' command" do
120
- text.to_zpl.should =~ /\AA/
124
+ it "contains the '^FB' command" do
125
+ expect(text.to_zpl).to match /\^FB/
121
126
  end
122
127
 
123
- it "assumes 1 as the default horizontal multipler" do
124
- text.to_zpl.split(",")[4].to_i.should == Zebra::Zpl::HorizontalMultiplier::VALUE_1
128
+ it "contains the attributes in correct order" do
129
+ expect(text.to_zpl).to eq '^FWN^CF0,28^CI28^FO100,150^FB,4,,L,^FDfoobar^FS'
125
130
  end
126
131
 
127
- it "assumes 1 as the default vertical multiplier" do
128
- text.to_zpl.split(",")[5].to_i.should == Zebra::Zpl::VerticalMultiplier::VALUE_1
132
+ it "contains the properly duplicated attributes in correct order for bold text" do
133
+ expect(text_bold.to_zpl).to eq '^FWN^CF0,28^CI28^FO102,150^FB,4,,L,^FDfoobar^FS^FWN^CF0,28^CI28^FO100,152^FB,4,,L,^FDfoobar^FS'
129
134
  end
130
135
 
131
- it "assumes the normal print mode as the default" do
132
- text.to_zpl.split(",")[6].should == Zebra::Zpl::PrintMode::NORMAL
133
- end
134
-
135
- it "assumes no rotation by default" do
136
- text.to_zpl.split(",")[2].to_i.should == Zebra::Zpl::Rotation::NO_ROTATION
137
- end
136
+ # it "assumes 1 as the default horizontal multipler" do
137
+ # expect(text.to_zpl.split(",")[4].to_i).to eq Zebra::Zpl::HorizontalMultiplier::VALUE_1
138
+ # end
139
+ #
140
+ # it "assumes 1 as the default vertical multiplier" do
141
+ # expect(text.to_zpl.split(",")[5].to_i).to eq Zebra::Zpl::VerticalMultiplier::VALUE_1
142
+ # end
138
143
  end
139
144
  end
@@ -4,26 +4,26 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'zebra/zpl/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "zebra-zpl"
7
+ spec.name = 'zebra-zpl'
8
8
  spec.version = Zebra::Zpl::VERSION
9
- spec.authors = ["Barnabas Bulpett"]
10
- spec.email = ["barnabasbulpett@gmail.com"]
9
+ spec.authors = ['Barnabas Bulpett','Michael King','Logan Green']
10
+ spec.email = ['barnabasbulpett@gmail.com','mtking1123@gmail.com','loganagreen95@gmail.com']
11
11
  spec.description = %q{Print labels using ZPL2 and Ruby}
12
12
  spec.summary = %q{Simple DSL to create labels and send them to a Zebra printer using Ruby, ZPL2 and CUPS}
13
13
 
14
- spec.homepage = "https://github.com/bbulpett/zebra-zpl"
15
- spec.license = "MIT"
14
+ spec.homepage = 'https://github.com/bbulpett/zebra-zpl'
15
+ spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files`.split($/)
18
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ['lib']
21
21
 
22
- spec.add_dependency "cups"
22
+ spec.add_dependency 'img2zpl', '~> 1.0.0'
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.3"
25
- spec.add_development_dependency "rake"
26
- spec.add_development_dependency "rspec"
27
- spec.add_development_dependency "guard"
28
- spec.add_development_dependency "guard-rspec"
24
+ spec.add_development_dependency 'bundler', '~> 2.0'
25
+ spec.add_development_dependency 'rake', '~> 13'
26
+ spec.add_development_dependency 'rspec', '~> 3.9'
27
+ spec.add_development_dependency 'guard', '~> 2.15'
28
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
29
29
  end
metadata CHANGED
@@ -1,138 +1,169 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zebra-zpl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barnabas Bulpett
8
+ - Michael King
9
+ - Logan Green
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2017-04-27 00:00:00.000000000 Z
13
+ date: 2020-10-05 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
- name: cups
16
+ name: img2zpl
15
17
  requirement: !ruby/object:Gem::Requirement
16
18
  requirements:
17
- - - ">="
19
+ - - "~>"
18
20
  - !ruby/object:Gem::Version
19
- version: '0'
21
+ version: 1.0.0
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
23
25
  requirements:
24
- - - ">="
26
+ - - "~>"
25
27
  - !ruby/object:Gem::Version
26
- version: '0'
28
+ version: 1.0.0
27
29
  - !ruby/object:Gem::Dependency
28
30
  name: bundler
29
31
  requirement: !ruby/object:Gem::Requirement
30
32
  requirements:
31
33
  - - "~>"
32
34
  - !ruby/object:Gem::Version
33
- version: '1.3'
35
+ version: '2.0'
34
36
  type: :development
35
37
  prerelease: false
36
38
  version_requirements: !ruby/object:Gem::Requirement
37
39
  requirements:
38
40
  - - "~>"
39
41
  - !ruby/object:Gem::Version
40
- version: '1.3'
42
+ version: '2.0'
41
43
  - !ruby/object:Gem::Dependency
42
44
  name: rake
43
45
  requirement: !ruby/object:Gem::Requirement
44
46
  requirements:
45
- - - ">="
47
+ - - "~>"
46
48
  - !ruby/object:Gem::Version
47
- version: '0'
49
+ version: '13'
48
50
  type: :development
49
51
  prerelease: false
50
52
  version_requirements: !ruby/object:Gem::Requirement
51
53
  requirements:
52
- - - ">="
54
+ - - "~>"
53
55
  - !ruby/object:Gem::Version
54
- version: '0'
56
+ version: '13'
55
57
  - !ruby/object:Gem::Dependency
56
58
  name: rspec
57
59
  requirement: !ruby/object:Gem::Requirement
58
60
  requirements:
59
- - - ">="
61
+ - - "~>"
60
62
  - !ruby/object:Gem::Version
61
- version: '0'
63
+ version: '3.9'
62
64
  type: :development
63
65
  prerelease: false
64
66
  version_requirements: !ruby/object:Gem::Requirement
65
67
  requirements:
66
- - - ">="
68
+ - - "~>"
67
69
  - !ruby/object:Gem::Version
68
- version: '0'
70
+ version: '3.9'
69
71
  - !ruby/object:Gem::Dependency
70
72
  name: guard
71
73
  requirement: !ruby/object:Gem::Requirement
72
74
  requirements:
73
- - - ">="
75
+ - - "~>"
74
76
  - !ruby/object:Gem::Version
75
- version: '0'
77
+ version: '2.15'
76
78
  type: :development
77
79
  prerelease: false
78
80
  version_requirements: !ruby/object:Gem::Requirement
79
81
  requirements:
80
- - - ">="
82
+ - - "~>"
81
83
  - !ruby/object:Gem::Version
82
- version: '0'
84
+ version: '2.15'
83
85
  - !ruby/object:Gem::Dependency
84
86
  name: guard-rspec
85
87
  requirement: !ruby/object:Gem::Requirement
86
88
  requirements:
87
- - - ">="
89
+ - - "~>"
88
90
  - !ruby/object:Gem::Version
89
- version: '0'
91
+ version: '4.7'
90
92
  type: :development
91
93
  prerelease: false
92
94
  version_requirements: !ruby/object:Gem::Requirement
93
95
  requirements:
94
- - - ">="
96
+ - - "~>"
95
97
  - !ruby/object:Gem::Version
96
- version: '0'
98
+ version: '4.7'
97
99
  description: Print labels using ZPL2 and Ruby
98
100
  email:
99
101
  - barnabasbulpett@gmail.com
102
+ - mtking1123@gmail.com
103
+ - loganagreen95@gmail.com
100
104
  executables: []
101
105
  extensions: []
102
106
  extra_rdoc_files: []
103
107
  files:
104
108
  - ".gitignore"
105
109
  - ".rspec"
110
+ - CHANGELOG.md
111
+ - CONTRIBUTING.md
106
112
  - Gemfile
107
113
  - Guardfile
108
114
  - LICENSE
109
115
  - LICENSE_ORIGINAL.txt
110
116
  - README.md
111
117
  - Rakefile
118
+ - docs/example.rb
119
+ - docs/images/barcode.png
120
+ - docs/images/datamatrix.png
121
+ - docs/images/earth.jpg
122
+ - docs/images/graphics.png
123
+ - docs/images/image.png
124
+ - docs/images/image_inverted.png
125
+ - docs/images/image_manipulation.png
126
+ - docs/images/images.png
127
+ - docs/images/justification.png
128
+ - docs/images/qrcode.png
129
+ - docs/images/rotation.png
130
+ - docs/images/text.png
112
131
  - lib/zebra/print_job.rb
113
132
  - lib/zebra/zpl.rb
114
133
  - lib/zebra/zpl/barcode.rb
115
134
  - lib/zebra/zpl/barcode_type.rb
116
135
  - lib/zebra/zpl/box.rb
117
136
  - lib/zebra/zpl/character_set.rb
137
+ - lib/zebra/zpl/comment.rb
118
138
  - lib/zebra/zpl/country_code.rb
139
+ - lib/zebra/zpl/datamatrix.rb
119
140
  - lib/zebra/zpl/font.rb
141
+ - lib/zebra/zpl/graphic.rb
142
+ - lib/zebra/zpl/image.rb
120
143
  - lib/zebra/zpl/justification.rb
121
144
  - lib/zebra/zpl/label.rb
122
145
  - lib/zebra/zpl/language.rb
123
146
  - lib/zebra/zpl/multipliers.rb
147
+ - lib/zebra/zpl/pdf417.rb
124
148
  - lib/zebra/zpl/print_mode.rb
125
149
  - lib/zebra/zpl/printable.rb
126
150
  - lib/zebra/zpl/qrcode.rb
151
+ - lib/zebra/zpl/raw.rb
127
152
  - lib/zebra/zpl/rotation.rb
128
153
  - lib/zebra/zpl/text.rb
129
154
  - lib/zebra/zpl/version.rb
155
+ - spec/fixtures/default.jpg
130
156
  - spec/spec_helper.rb
131
157
  - spec/zebra/print_job_spec.rb
132
158
  - spec/zebra/zpl/barcode_spec.rb
133
159
  - spec/zebra/zpl/box_spec.rb
134
160
  - spec/zebra/zpl/character_set_spec.rb
161
+ - spec/zebra/zpl/comment_spec.rb
162
+ - spec/zebra/zpl/datamatrix_spec.rb
163
+ - spec/zebra/zpl/graphics_spec.rb
164
+ - spec/zebra/zpl/image_spec.rb
135
165
  - spec/zebra/zpl/label_spec.rb
166
+ - spec/zebra/zpl/pdf417_spec.rb
136
167
  - spec/zebra/zpl/qrcode_spec.rb
137
168
  - spec/zebra/zpl/text_spec.rb
138
169
  - spec/zebra/zpl/zpl_spec.rb
@@ -156,19 +187,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
187
  - !ruby/object:Gem::Version
157
188
  version: '0'
158
189
  requirements: []
159
- rubyforge_project:
160
- rubygems_version: 2.6.10
190
+ rubygems_version: 3.1.2
161
191
  signing_key:
162
192
  specification_version: 4
163
193
  summary: Simple DSL to create labels and send them to a Zebra printer using Ruby,
164
194
  ZPL2 and CUPS
165
195
  test_files:
196
+ - spec/fixtures/default.jpg
166
197
  - spec/spec_helper.rb
167
198
  - spec/zebra/print_job_spec.rb
168
199
  - spec/zebra/zpl/barcode_spec.rb
169
200
  - spec/zebra/zpl/box_spec.rb
170
201
  - spec/zebra/zpl/character_set_spec.rb
202
+ - spec/zebra/zpl/comment_spec.rb
203
+ - spec/zebra/zpl/datamatrix_spec.rb
204
+ - spec/zebra/zpl/graphics_spec.rb
205
+ - spec/zebra/zpl/image_spec.rb
171
206
  - spec/zebra/zpl/label_spec.rb
207
+ - spec/zebra/zpl/pdf417_spec.rb
172
208
  - spec/zebra/zpl/qrcode_spec.rb
173
209
  - spec/zebra/zpl/text_spec.rb
174
210
  - spec/zebra/zpl/zpl_spec.rb