zebra-zpl 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f71f645c261f13d07c249d0aa2185d0457eb9cd82950bccc7cece4affd4e8ae
4
- data.tar.gz: 54584c33bbadbc85afdd1d3d6909ed2f97fb310a914fbb06937563c6382699a5
3
+ metadata.gz: fd34dee028d5f1722409a1976624d6b34412730dbeaae95cca39994416a562d5
4
+ data.tar.gz: 7d1f93a2ca77cd89d365b3b830eb27ed7efefa9bb12a06a42ab195c6d5088917
5
5
  SHA512:
6
- metadata.gz: fa31bbcf69048fb620115dfd1e7da60d7c01dc366486019cccefb0d70889c4028676a539375dffec5cface9693fb00f64bf21a97ada1394847710ec60b6cf129
7
- data.tar.gz: 0c07546694365b8549429e9690de5942f2c161703c3c5691336f44a109906fcabd8b207a123dacef94e93ecabb675011b84afdb23224e7e3497cd0e6b84cb029
6
+ metadata.gz: 3987b04350d612a3168247e181072d4f906ba0ed30e87f6b5acfd1be01907142bddac4aec4237cf1301b16c7d90f2ae4d2ba0ee29057f8dd6d4657ac2cb4d0d0
7
+ data.tar.gz: 47baa040cbad0068c9d7cf4ddad08fc25e48dcfb84ddf8b9f01eb01251a894e159c1214afc3d18bc7102df0c3170043b90ab3571262d0cc044dea71cc9ade798
data/.gitignore CHANGED
@@ -1,4 +1,4 @@
1
-
1
+ *.gem
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
@@ -1,7 +1,12 @@
1
- ### 1.1.1 (next)
1
+ ### 1.1.3 (next)
2
2
 
3
3
  * Your contribution here.
4
4
 
5
+ ### 1.1.2 (02/25/2019)
6
+
7
+ * [#63](https://github.com/bbulpett/zebra-zpl/pull/63): Un-restrict font size - [@mtking2](https://github.com/mtking2)
8
+ * [#62](https://github.com/bbulpett/zebra-zpl/pull/62): Add print service option for print jobs (`lp`/`rlpr`) - [@LagTag](https://github.com/LagTag)
9
+
5
10
  ### 1.1.1 (12/19/2019)
6
11
 
7
12
  * [#58](https://github.com/bbulpett/zebra-zpl/pull/58): Add access to source `Img2Zpl::Image` object - [@mtking2](https://github.com/mtking2)
data/README.md CHANGED
@@ -97,6 +97,18 @@ print_job.print label, ip
97
97
 
98
98
  This will persist the label contents to a tempfile (using Ruby's tempfile core library) and copy the file to the printer using either `rlpr -H <hostname/ip> -P <your-printer-name-on-windows> -o <path-to-the-temp-file>` (for Windows systems, see [section](#printing-directly-to-windows-lpd) below) or `lp -h <hostname/ip> -d <your-printer-name-on-cups> -o raw <path-to-the-tempfile>` (for Unix systems). All the tempfile creation/path resolution, as well as which command has to be used, are handled by the `PrintJob` class.
99
99
 
100
+ ##### Print Service
101
+
102
+ You can specify what print service command you want to be used when calling the `print` method by setting the `:print_service` option parameter. If left unspecified, it will attempt to send the print job first via `rlpr` - if the `rlpr` command fails in anyway then it will fall back to the `lp` command.
103
+
104
+ ```ruby
105
+ print_job.print label, ip, print_service: 'lp' # attempt only via the lp command
106
+
107
+ print_job.print label, ip, print_service: 'rlpr' # attempt only via the rlpr command
108
+
109
+ print_job.print label, ip # attempt via rlpr first, fallback to lp
110
+ ```
111
+
100
112
  #### Printing directly to Windows LPD
101
113
  This gem also supports printing directly to shared printer on Windows using LPD.
102
114
  In order to print directly to a LPD on a Windows machine you need two things:
@@ -7,7 +7,7 @@ module Zebra
7
7
  @printer = printer
8
8
  end
9
9
 
10
- def print(label, ip)
10
+ def print(label, ip, print_service: "")
11
11
  @remote_ip = ip
12
12
  if label.is_a? String
13
13
  tempfile = Tempfile.new "zebra_label"
@@ -16,15 +16,22 @@ module Zebra
16
16
  else
17
17
  tempfile = label.persist
18
18
  end
19
- send_to_printer tempfile.path
19
+ send_to_printer(tempfile.path, print_service)
20
20
  end
21
21
 
22
22
  private
23
23
 
24
- def send_to_printer(path)
24
+ def send_to_printer(path, print_service)
25
25
  puts "* * * * * * * * * * * * Sending file to printer #{@printer} at #{@remote_ip} * * * * * * * * * * "
26
- result = system("rlpr -H #{@remote_ip} -P #{@printer} -o #{path} 2>&1") # try printing to LPD on windows machine first
27
- system("lp -h #{@remote_ip} -d #{@printer} -o raw #{path}") if !result # print to unix (CUPS) if rlpr failed
26
+ case print_service
27
+ when "rlpr"
28
+ system("rlpr -H #{@remote_ip} -P #{@printer} -o #{path} 2>&1") # try printing to LPD on windows machine
29
+ when "lp"
30
+ system("lp -h #{@remote_ip} -d #{@printer} -o raw #{path}") # print to unix (CUPS) using lp
31
+ else
32
+ result = system("rlpr -H #{@remote_ip} -P #{@printer} -o #{path} 2>&1") # try printing to LPD on windows machine first
33
+ system("lp -h #{@remote_ip} -d #{@printer} -o raw #{path}") if !result # print to unix (CUPS) if rlpr failed
34
+ end
28
35
  end
29
36
  end
30
37
  end
@@ -15,7 +15,7 @@ module Zebra
15
15
  SIZE_9 = 133 # 48pt
16
16
 
17
17
  def self.valid_font_size?(font_size)
18
- [12, 17, 22, 28, 33, 44, 67, 100, 111, 133].include?(font_size.to_i)
18
+ (0..32000).include?(font_size.to_i)
19
19
  end
20
20
 
21
21
  def self.validate_font_size(font_size)
@@ -1,5 +1,5 @@
1
1
  module Zebra
2
2
  module Zpl
3
- VERSION = '1.1.1'.freeze
3
+ VERSION = '1.1.2'.freeze
4
4
  end
5
5
  end
@@ -56,7 +56,10 @@ 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
+ }.to raise_error(Zebra::Zpl::FontSize::InvalidFontSizeError)
61
+ expect {
62
+ described_class.new.font_size = 32001
60
63
  }.to raise_error(Zebra::Zpl::FontSize::InvalidFontSizeError)
61
64
  end
62
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zebra-zpl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barnabas Bulpett
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-12-19 00:00:00.000000000 Z
13
+ date: 2020-02-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: img2zpl