sapos-print 1.0.8 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c6213f40144b180efcab3601be965bd4eb27538e24ce1061d5645294c7771d3
4
- data.tar.gz: b6ebb3d3b2faa32eaff6c7f65b488582a79c6ca7e3006dc574baa0eea9d3a80c
3
+ metadata.gz: e1f30efb41b794e0457aba97ebd82d77a7c225d82768f86dfde2523e8cc1d77c
4
+ data.tar.gz: 6895fb38bc99778737c7a126b6fd759505017c7362450c855d2a941e9589c218
5
5
  SHA512:
6
- metadata.gz: f5c29e07f820962d25be97d733a566397ce59de91f6b0f9ab14b2735bcc392b9da026f887612db38e8a7e3e9325266814f4b22f2789d2f07efdc7572083cf49e
7
- data.tar.gz: da79df111441d3512408add3a69fab610a07573ae7104a7ee16a84da4644684fcf5386971aa9a6367e47529a043cfe7316c72706f48723ad975a6470c8455ae5
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.7)
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.2.3)
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.0.4)
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.2)
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)
@@ -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
@@ -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)
@@ -51,7 +51,7 @@ module Sapos
51
51
  def initialize
52
52
  @config = QReader.printer_config
53
53
  @printer = Printer.new(@config)
54
- @pubnub = Pubnub.new(subscribe_key: @config.key, user_id: @config.user_id)
54
+ @pubnub = Pubnub.new(subscribe_key: @config.key, user_id: @config.user_id, ssl: true)
55
55
  end
56
56
  end
57
57
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sapos
4
4
  module Print
5
- VERSION = "1.0.8"
5
+ VERSION = "1.0.10"
6
6
  end
7
7
  end
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.8
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-21 00:00:00.000000000 Z
11
+ date: 2023-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor