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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pos/printer.rb +22 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8814a2ee3abe96a13570e49db9e156b4295a8fee944c752a7c0b85eacbc13781
4
- data.tar.gz: 071beec002d4986cecf05d1c3c9baa09c5675f2ce700bec9a10606ba95b5d39f
3
+ metadata.gz: 7718e3f4f1ce4a9a080ecee290af845cff7cdf0a5d92807539ef40eff5e53f01
4
+ data.tar.gz: aca4fe76e92c35a51efd75d91b799d0fe2e168361b3ace1c29d70ec10b8b988f
5
5
  SHA512:
6
- metadata.gz: 2c528a5fbd0a995c465854e9ed322825afe6bcc7f5b9919f42aeef24f2fb651de2b2975539e65c0e4b06da229e27d85fa2664efa2f6a474d00c0587024b2dbe4
7
- data.tar.gz: f8b88f459800ffd296a81c86bf9bf27a346d586adda749304257aa0027d90e5a7cc40a4d040d0100b932436f8a887fcfcbf30c95e3c91403dac0a7c0330d142c
6
+ metadata.gz: 025b8c473e444c9407e28bdef40759e49812530418fb06b8bf161c2b6f31db117b438c13d364a6cb3c20532101f761be89930913d94451b7ae745dafac83284f
7
+ data.tar.gz: c7b338cb1b53678c4311057a79eb4487878c6d2508261176a84016e5b42400ae54299246211d8916d5e5b673bbd6ced878e2210c56f11c184dd8955e0fc328ec
@@ -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.force_encoding(Encoding::UTF_8)}"
74
- add_command "#{msb.chr.force_encoding(Encoding::UTF_8)}\x31\x50\x30"
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.8
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-05 00:00:00.000000000 Z
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