zebra-zpl 1.0.5 → 1.1.0

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