sapos-print 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/lib/sapos/print/cli.rb +2 -1
- data/lib/sapos/print/configuration.rb +8 -2
- data/lib/sapos/print/printer.rb +14 -3
- data/lib/sapos/print/version.rb +1 -1
- 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: e1f30efb41b794e0457aba97ebd82d77a7c225d82768f86dfde2523e8cc1d77c
|
4
|
+
data.tar.gz: 6895fb38bc99778737c7a126b6fd759505017c7362450c855d2a941e9589c218
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6efbd8f30e2c9446c76fdd7e2cd7547c80dd90b6b04fc680c1d4c3eb245a696c6372a25a19e350ac64e7b1b807ab8a8ca22a7b2f5310d2080fa2375d10bb24cc
|
7
|
+
data.tar.gz: 78b637abab89f3745d43c9b1cea5628997076c52f9f0399d840461d8c7a70793faada466143d8d230f6ac92ff698d97012fb00992f6197ffa7657c21b3b24c10
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sapos-print (1.0.
|
4
|
+
sapos-print (1.0.9)
|
5
5
|
activesupport
|
6
6
|
awesome_print
|
7
7
|
json
|
@@ -12,7 +12,7 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activesupport (7.0.
|
15
|
+
activesupport (7.0.3)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
17
|
i18n (>= 1.6, < 2)
|
18
18
|
minitest (>= 5.1)
|
@@ -34,7 +34,7 @@ GEM
|
|
34
34
|
concurrent-ruby (~> 1.0)
|
35
35
|
zeitwerk (~> 2.6)
|
36
36
|
dry-inflector (0.2.1)
|
37
|
-
dry-initializer (3.
|
37
|
+
dry-initializer (3.1.1)
|
38
38
|
dry-logic (1.2.0)
|
39
39
|
concurrent-ruby (~> 1.0)
|
40
40
|
dry-core (~> 0.5, >= 0.5)
|
@@ -63,7 +63,7 @@ GEM
|
|
63
63
|
httpclient (2.8.3)
|
64
64
|
i18n (1.12.0)
|
65
65
|
concurrent-ruby (~> 1.0)
|
66
|
-
json (2.6.
|
66
|
+
json (2.6.3)
|
67
67
|
mime-types (3.4.1)
|
68
68
|
mime-types-data (~> 3.2015)
|
69
69
|
mime-types-data (3.2022.0105)
|
data/lib/sapos/print/cli.rb
CHANGED
@@ -35,6 +35,7 @@ module Sapos
|
|
35
35
|
config[:adapter] = ask("Printer Adapter: ", limited_to: ["console", "cups", "windows"])
|
36
36
|
config[:interface] = ask("Interface", limited_to: ["text", "escp"])
|
37
37
|
config[:user_id] = user_id
|
38
|
+
config[:duplicate_control] = ask("¿Control Duplicados por MSGID?", limited_to: ["si", "no"])
|
38
39
|
|
39
40
|
if yes?("Are you sure that you want to write the configuration file?")
|
40
41
|
Sapos::Print::Configuration.write(config)
|
@@ -48,7 +49,7 @@ module Sapos
|
|
48
49
|
def start
|
49
50
|
info
|
50
51
|
config = Sapos::Print.config
|
51
|
-
puts ["Q=#{config.q.to_s}", "Printer=#{config.printer.to_s}", "Adapter=#{config.adapter.to_s}", "Interface=#{config.interface}"].join(";")
|
52
|
+
puts ["Q=#{config.q.to_s}", "Printer=#{config.printer.to_s}", "Adapter=#{config.adapter.to_s}", "Interface=#{config.interface}", "DC=#{config.duplicate_control?}"].join(";")
|
52
53
|
|
53
54
|
print_dir = File.join(Sapos::Print.app_directory, 'print')
|
54
55
|
if File.exists?(print_dir)
|
@@ -6,7 +6,7 @@ module Sapos
|
|
6
6
|
module Print
|
7
7
|
class Configuration
|
8
8
|
|
9
|
-
attr_accessor :printer, :adapter, :interface, :q, :key, :emv_path, :emv_terminal, :user_id, :verbose
|
9
|
+
attr_accessor :printer, :adapter, :interface, :q, :key, :emv_path, :emv_terminal, :user_id, :verbose, :duplicate_control, :cache
|
10
10
|
|
11
11
|
def self.write(args = {})
|
12
12
|
config_file = "#{Sapos::Print.app_directory}/config.yml"
|
@@ -26,6 +26,8 @@ module Sapos
|
|
26
26
|
@emv_path = result[:emv_path]
|
27
27
|
@emv_terminal = result[:emv_terminal]
|
28
28
|
@user_id = result[:user_id]
|
29
|
+
@duplicate_control = result[:duplicate_control]
|
30
|
+
@cache = []
|
29
31
|
else
|
30
32
|
raise Sapos::Print::Error, "Configuration is missing. Make sure to create this file: #{config_file}"
|
31
33
|
end
|
@@ -42,9 +44,13 @@ module Sapos
|
|
42
44
|
def verify?
|
43
45
|
@verify == true
|
44
46
|
end
|
47
|
+
|
48
|
+
def duplicate_control?
|
49
|
+
@duplicate_control.to_s.downcase.eql?("si")
|
50
|
+
end
|
45
51
|
|
46
52
|
def to_h
|
47
|
-
{printer: @printer, adapter: @adapter, interface: @interface, q: @q, key: @key, emv_path: @emv_path, emv_terminal: @emv_terminal, user_id: @user_id }
|
53
|
+
{printer: @printer, adapter: @adapter, interface: @interface, q: @q, key: @key, emv_path: @emv_path, emv_terminal: @emv_terminal, user_id: @user_id, duplicate_control: @duplicate_control }
|
48
54
|
end
|
49
55
|
end
|
50
56
|
end
|
data/lib/sapos/print/printer.rb
CHANGED
@@ -10,11 +10,18 @@ module Sapos
|
|
10
10
|
def print(args = {})
|
11
11
|
raw_message = args[:document]
|
12
12
|
|
13
|
-
log_text = "id=#{args[:id]},doc=#{args[:document_number]},control=#{args[:print_control] ? "SI" : "NO"}\t"
|
13
|
+
log_text = "id=#{args[:id]},doc=#{args[:document_number]},control=#{args[:print_control] ? "SI" : "NO"},cache=0\t"
|
14
14
|
filename = "#{args[:document_number]}.print" if args[:document_number]
|
15
15
|
filename = SecureRandom.hex if filename.nil?
|
16
16
|
result = false
|
17
17
|
raw = raw_message.force_encoding("UTF-8")
|
18
|
+
msgid = args[:id]
|
19
|
+
if @config.duplicate_control? && @config.cache.include?(msgid)
|
20
|
+
log_text += " => DUPLICADO (DC)"
|
21
|
+
log_text.gsub!("cache=0", "cache=#{@config.cache.size}")
|
22
|
+
puts log_text
|
23
|
+
return true
|
24
|
+
end
|
18
25
|
begin
|
19
26
|
if args[:print_control] && args[:document_number]
|
20
27
|
print_dir = File.join(Sapos::Print.app_directory, 'print')
|
@@ -39,6 +46,11 @@ module Sapos
|
|
39
46
|
#puts "Result: #{result}"
|
40
47
|
log_text += " => OK"
|
41
48
|
end
|
49
|
+
if @config.duplicate_control?
|
50
|
+
@config.cache << msgid
|
51
|
+
@config.cache.shift if @config.cache.size > 30
|
52
|
+
log_text.gsub!("cache=0", "cache=#{@config.cache.size}")
|
53
|
+
end
|
42
54
|
puts log_text
|
43
55
|
rescue => e
|
44
56
|
puts "#{e.message}"
|
@@ -47,8 +59,7 @@ module Sapos
|
|
47
59
|
ensure
|
48
60
|
#File.delete(filename) if File.exists?(filename)
|
49
61
|
return result
|
50
|
-
end
|
51
|
-
|
62
|
+
end
|
52
63
|
end
|
53
64
|
|
54
65
|
def data(raw_message)
|
data/lib/sapos/print/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sapos-print
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josef Sauter
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|