pos-printer 0.0.1 → 0.0.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pos/printer.rb +7 -5
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c84647150038a2e3159fc0ff1a32765a37dc5cce29d51d4496bffbbdfa497b9
4
- data.tar.gz: fe59275b8c5fb1cf1ac845ad82c6db02d6882a727ae235b04398384031a97f66
3
+ metadata.gz: 6afeee00eef6bb42c4baa2855534d70e81a9a0c3cdac02eeb26937ecf64bca50
4
+ data.tar.gz: 2f310c8be8b5290ea7134472752676c1dc6bf8ee71a7b988617a4ead37e1cc88
5
5
  SHA512:
6
- metadata.gz: ce3a614f32f3796a323d22c696e7838d967d0aa3ef7079869bbf59921f3e1e23c23199f20613efe69c7a8d3f563808659de232b082e874aba7c6cb4bbcfd953a
7
- data.tar.gz: 70da9c12fca86e5859d5662dd10dfe2d0bd8238a1cb3072279b4e8472776f8fd9f75a8eb80fc62e4f2378b5294051e08dd2d1826c48c7e681188bd2db28f6c25
6
+ metadata.gz: e538880c88fb90c60e5ef6627afcdcc678fbb989e532353dfdac2d75a29d2e8aa04ac7e0ac8ff0d3e743711fbf6f34b994ecadffda298f8b117951315a0f2604
7
+ data.tar.gz: 1ffe8c2e2a11ee862a9c7766ac870ebfb386d2349730f099a53236c21da0387a3d09fa531b123832a5313eaa2f71ab98632714ed1b56ca59f503bdb6b1178390
data/lib/pos/printer.rb CHANGED
@@ -4,6 +4,12 @@ module POS
4
4
  class Printer
5
5
  attr_reader :name
6
6
 
7
+ def self.print(printer_name)
8
+ printer = self.new(printer_name)
9
+ yield printer
10
+ printer.print
11
+ end
12
+
7
13
  def initialize(name)
8
14
  @name = name
9
15
  @commands = '\e@' # This is ESC/POS initialize command.
@@ -14,7 +20,7 @@ module POS
14
20
  end
15
21
 
16
22
  def print
17
- send_to_printer
23
+ Open3.capture3('lp', '-d', @name, '-o', 'raw', stdin_data: commands)
18
24
  end
19
25
 
20
26
  # ESC/POS commands
@@ -73,9 +79,5 @@ module POS
73
79
  @commands << command
74
80
  return
75
81
  end
76
-
77
- def send_to_printer
78
- Open3.capture3('lp', '-d', @name, '-o', 'raw', stdin_data: commands)
79
- end
80
82
  end
81
83
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pos-printer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusent Chig
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-30 00:00:00.000000000 Z
11
+ date: 2019-07-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Library for printing using ESC/POS (thermal) printers.
13
+ description: Library for printing using ESC/POS (thermal) printers using CUPS.
14
14
  email: yusent@protonmail.com
15
15
  executables: []
16
16
  extensions: []
@@ -40,5 +40,5 @@ requirements: []
40
40
  rubygems_version: 3.0.4
41
41
  signing_key:
42
42
  specification_version: 4
43
- summary: Library for printing using ESC/POS (thermal) printers.
43
+ summary: Library for printing using ESC/POS (thermal) printers using CUPS.
44
44
  test_files: []