pos-printer 0.0.4 → 0.0.5

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 +19 -23
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ec2088f850f7478a2bf6158fbbbc156bca15dbc5f5d44b06381de425831a58a
4
- data.tar.gz: 639f97d701f85b7837e937cf629ce023d7c53bfcaf1aa40f3c7619df4641ef0c
3
+ metadata.gz: 1c20a0f3e05ea7fb3023dbec21cd902f3150561e6cedccc3a31cbe40431cf075
4
+ data.tar.gz: 73d722d00114c024bc8140c58f6ec7929e3d5dd466f1446658fe7a6668814b98
5
5
  SHA512:
6
- metadata.gz: 516de03e1024b2f1e36679ba8467bb7de87df7d2e199715747ee924e3c052138b8ffc845c74057cf86f8e05808306eba8d9b9d4171fb3389cd33d88c7ba68d27
7
- data.tar.gz: e57bb630553ebe22b4df5894a8960e3e84fd8ac07efba19b0616aac5b8e7a87b66887454b28529733cf5705aec21d6748f2350c9aeb229891122d1bcae7b4e33
6
+ metadata.gz: 56061316f01a95fd862fe9c736cc63a6de0eaab554d41ff972877cef888b2227a8220c3272f906d04d5e98de9fefd094a810f67e7cd79ee464738aef99239f94
7
+ data.tar.gz: 27932b0a7cf813f61fc5bdcd93fd1fd8e354e1ea7edfccb8991a61d898a3062e96ea89c0a51a17b09da8720622316c33e3c004802ffdc50ebd5da2fe152730a6
@@ -10,58 +10,54 @@ module POS
10
10
 
11
11
  def initialize(name, lp_options = [])
12
12
  @name = name
13
- @commands = '\e@' # This is ESC/POS initialize command.
13
+ @commands = "\e@" # This is ESC/POS initialize command.
14
14
  @lp_options = ['-d', name, '-o', 'raw', *lp_options]
15
15
  end
16
16
 
17
- def commands
18
- @commands.gsub(/'/, "'\"'\"'")
19
- end
20
-
21
17
  def print
22
- Open3.capture3('lp', *@lp_options, stdin_data: commands)
18
+ Open3.capture3('lp', *@lp_options, stdin_data: @commands)
23
19
  end
24
20
 
25
21
  # ESC/POS commands
26
22
 
27
23
  def align_center
28
- add_command '\ea\1'
24
+ add_command "\ea\1"
29
25
  end
30
26
 
31
27
  def align_left
32
- add_command '\ea\0'
28
+ add_command "\ea\0"
33
29
  end
34
30
 
35
31
  def align_right
36
- add_command '\ea\2'
32
+ add_command "\ea\2"
37
33
  end
38
34
 
39
35
  def big_font
40
- add_command '\eM\0'
36
+ add_command "\eM\0"
41
37
  end
42
38
 
43
39
  def cut
44
- add_command '\em'
40
+ add_command "\em"
45
41
  end
46
42
 
47
43
  def double_size
48
- add_command '\x1d!\x11'
44
+ add_command "\x1d!\x11"
49
45
  end
50
46
 
51
47
  def line_feed
52
- add_command '\n'
48
+ add_command "\n"
53
49
  end
54
50
 
55
51
  def normal_size
56
- add_command '\x1d!\0'
52
+ add_command "\x1d!\0"
57
53
  end
58
54
 
59
55
  def open_drawer
60
- add_command '\x1bp\x00\x19\xff\x1bp\x01\x19\xff'
56
+ add_command "\x1bp\x00\x19\xff\x1bp\x01\x19\xff"
61
57
  end
62
58
 
63
59
  def print_logo
64
- add_command '\x1cp\1\0'
60
+ add_command "\x1cp\1\0"
65
61
  end
66
62
 
67
63
  def qr_code(str)
@@ -70,17 +66,17 @@ module POS
70
66
  lsb = s % 256
71
67
  msb = s / 256
72
68
 
73
- add_command '\x1B\x61\x01'
74
- add_command "\\x1D\\x28\\x6B\\x03\\x00\\x31\\x43\\x#{'%02x' % qr_size}"
75
- add_command '\x1D\x28\x6B\x03\x00\x31\x45\x33'
76
- add_command "\\x1D\\x28\\x6B\\x#{'%02x' % lsb}"
77
- add_command "\\x#{'%02x' % msb}\\x31\\x50\\x30"
69
+ add_command "\x1B\x61\x01"
70
+ add_command "\x1D\x28\x6B\x03\x00\x31\x43#{qr_size.chr}"
71
+ add_command "\x1D\x28\x6B\x03\x00\x31\x45\x33"
72
+ add_command "\x1D\x28\x6B#{lsb.chr}"
73
+ add_command "#{msb.chr}\x31\x50\x30"
78
74
  add_command str
79
- add_command '\x1D\x28\x6B\x03\x00\x31\x51\x30'
75
+ add_command "\x1D\x28\x6B\x03\x00\x31\x51\x30"
80
76
  end
81
77
 
82
78
  def small_font
83
- add_command '\eM\1'
79
+ add_command "\eM\1"
84
80
  end
85
81
 
86
82
  def text(str)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pos-printer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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-31 00:00:00.000000000 Z
11
+ date: 2019-08-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Library for printing using ESC/POS (thermal) printers using CUPS.
14
14
  email: yusent@protonmail.com