pos-printer 0.0.8 → 0.0.9
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 +4 -4
- data/lib/pos/printer.rb +22 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7718e3f4f1ce4a9a080ecee290af845cff7cdf0a5d92807539ef40eff5e53f01
|
4
|
+
data.tar.gz: aca4fe76e92c35a51efd75d91b799d0fe2e168361b3ace1c29d70ec10b8b988f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 025b8c473e444c9407e28bdef40759e49812530418fb06b8bf161c2b6f31db117b438c13d364a6cb3c20532101f761be89930913d94451b7ae745dafac83284f
|
7
|
+
data.tar.gz: c7b338cb1b53678c4311057a79eb4487878c6d2508261176a84016e5b42400ae54299246211d8916d5e5b673bbd6ced878e2210c56f11c184dd8955e0fc328ec
|
data/lib/pos/printer.rb
CHANGED
@@ -10,7 +10,7 @@ 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@".b # This is ESC/POS initialize command.
|
14
14
|
@lp_options = ['-d', name, '-o', 'raw', *lp_options]
|
15
15
|
end
|
16
16
|
|
@@ -67,11 +67,10 @@ module POS
|
|
67
67
|
msb = s / 256
|
68
68
|
|
69
69
|
add_command "\x1B\x61\x01"
|
70
|
-
add_command "\x1D\x28\x6B\x03\x00\x31\x43"
|
71
|
-
add_command qr_size.chr.force_encoding(Encoding::UTF_8)
|
70
|
+
add_command "\x1D\x28\x6B\x03\x00\x31\x43#{qr_size.chr}"
|
72
71
|
add_command "\x1D\x28\x6B\x03\x00\x31\x45\x33"
|
73
|
-
add_command "\x1D\x28\x6B#{lsb.chr
|
74
|
-
add_command "#{msb.chr
|
72
|
+
add_command "\x1D\x28\x6B#{lsb.chr}"
|
73
|
+
add_command "#{msb.chr}\x31\x50\x30"
|
75
74
|
add_command str
|
76
75
|
add_command "\x1D\x28\x6B\x03\x00\x31\x51\x30"
|
77
76
|
end
|
@@ -92,8 +91,25 @@ module POS
|
|
92
91
|
private
|
93
92
|
|
94
93
|
def add_command(command)
|
95
|
-
@commands << command
|
94
|
+
@commands << replace_spanish_characters(command)
|
96
95
|
return
|
97
96
|
end
|
97
|
+
|
98
|
+
def replace_spanish_characters(str)
|
99
|
+
str
|
100
|
+
.b
|
101
|
+
.gsub("Á".b, "\xB5".b)
|
102
|
+
.gsub("É".b, "\x90".b)
|
103
|
+
.gsub("Í".b, "\xD6".b)
|
104
|
+
.gsub("Ó".b, "\xE0".b)
|
105
|
+
.gsub("Ú".b, "\xE9".b)
|
106
|
+
.gsub("Ñ".b, "\xA5".b)
|
107
|
+
.gsub("á".b, "\xA0".b)
|
108
|
+
.gsub("é".b, "\x82".b)
|
109
|
+
.gsub("í".b, "\xA1".b)
|
110
|
+
.gsub("ó".b, "\xA2".b)
|
111
|
+
.gsub("ú".b, "\xA3".b)
|
112
|
+
.gsub("ñ".b, "\xA4".b)
|
113
|
+
end
|
98
114
|
end
|
99
115
|
end
|
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
|
+
version: 0.0.9
|
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-08-
|
11
|
+
date: 2019-08-06 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
|