sapos-print 1.0.10 → 1.1.1

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: e1f30efb41b794e0457aba97ebd82d77a7c225d82768f86dfde2523e8cc1d77c
4
- data.tar.gz: 6895fb38bc99778737c7a126b6fd759505017c7362450c855d2a941e9589c218
3
+ metadata.gz: 9efee936fd5ce8384e2d893f19802b36fddf950dd3a7dc9a19f2c2aa075a2ea7
4
+ data.tar.gz: 1f7dc058f121b6711c98673c391560c4959042492b120bc3b37ca5e1a732e609
5
5
  SHA512:
6
- metadata.gz: 6efbd8f30e2c9446c76fdd7e2cd7547c80dd90b6b04fc680c1d4c3eb245a696c6372a25a19e350ac64e7b1b807ab8a8ca22a7b2f5310d2080fa2375d10bb24cc
7
- data.tar.gz: 78b637abab89f3745d43c9b1cea5628997076c52f9f0399d840461d8c7a70793faada466143d8d230f6ac92ff698d97012fb00992f6197ffa7657c21b3b24c10
6
+ metadata.gz: a94fbcb1e6fccdcc38579c1d1125e13b521bb87d5cdc0faa8e5d604e40cb300dae76fced7ae65e772f43476254b2bfaf1255849373a119073065ff9d13d2b180
7
+ data.tar.gz: 805d382cf37df0f32628784daab89238717ce85fa616b8ea4b34a7fa02118b4fd942769147009a22b84fd3fcc1e81bcee77b17ae51a765e910546d1b580846e1
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sapos-print (1.0.9)
5
- activesupport
4
+ sapos-print (1.1.0)
5
+ activesupport (~> 6.1)
6
6
  awesome_print
7
7
  json
8
8
  pubnub (~> 4.8.0)
@@ -12,12 +12,13 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activesupport (7.0.3)
15
+ activesupport (6.1.7.3)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 1.6, < 2)
18
18
  minitest (>= 5.1)
19
19
  tzinfo (~> 2.0)
20
- addressable (2.8.1)
20
+ zeitwerk (~> 2.3)
21
+ addressable (2.8.4)
21
22
  public_suffix (>= 2.0.2, < 6.0)
22
23
  awesome_print (1.9.2)
23
24
  concurrent-ruby (1.1.10)
@@ -25,49 +26,49 @@ GEM
25
26
  concurrent-ruby (~> 1.1.5)
26
27
  domain_name (0.5.20190701)
27
28
  unf (>= 0.0.5, < 1.0.0)
28
- dry-configurable (0.16.1)
29
- dry-core (~> 0.6)
29
+ dry-configurable (1.0.1)
30
+ dry-core (~> 1.0, < 2)
30
31
  zeitwerk (~> 2.6)
31
- dry-container (0.11.0)
32
- concurrent-ruby (~> 1.0)
33
- dry-core (0.9.1)
32
+ dry-core (1.0.0)
34
33
  concurrent-ruby (~> 1.0)
35
34
  zeitwerk (~> 2.6)
36
- dry-inflector (0.2.1)
35
+ dry-inflector (1.0.0)
37
36
  dry-initializer (3.1.1)
38
- dry-logic (1.2.0)
37
+ dry-logic (1.5.0)
39
38
  concurrent-ruby (~> 1.0)
40
- dry-core (~> 0.5, >= 0.5)
41
- dry-schema (1.8.0)
39
+ dry-core (~> 1.0, < 2)
40
+ zeitwerk (~> 2.6)
41
+ dry-schema (1.13.2)
42
42
  concurrent-ruby (~> 1.0)
43
- dry-configurable (~> 0.13, >= 0.13.0)
44
- dry-core (~> 0.5, >= 0.5)
43
+ dry-configurable (~> 1.0, >= 1.0.1)
44
+ dry-core (~> 1.0, < 2)
45
45
  dry-initializer (~> 3.0)
46
- dry-logic (~> 1.0)
47
- dry-types (~> 1.5)
48
- dry-types (1.5.1)
46
+ dry-logic (>= 1.4, < 2)
47
+ dry-types (>= 1.7, < 2)
48
+ zeitwerk (~> 2.6)
49
+ dry-types (1.7.1)
49
50
  concurrent-ruby (~> 1.0)
50
- dry-container (~> 0.3)
51
- dry-core (~> 0.5, >= 0.5)
52
- dry-inflector (~> 0.1, >= 0.1.2)
53
- dry-logic (~> 1.0, >= 1.0.2)
54
- dry-validation (1.7.0)
51
+ dry-core (~> 1.0)
52
+ dry-inflector (~> 1.0)
53
+ dry-logic (~> 1.4)
54
+ zeitwerk (~> 2.6)
55
+ dry-validation (1.10.0)
55
56
  concurrent-ruby (~> 1.0)
56
- dry-container (~> 0.7, >= 0.7.1)
57
- dry-core (~> 0.5, >= 0.5)
57
+ dry-core (~> 1.0, < 2)
58
58
  dry-initializer (~> 3.0)
59
- dry-schema (~> 1.8, >= 1.8.0)
59
+ dry-schema (>= 1.12, < 2)
60
+ zeitwerk (~> 2.6)
60
61
  http-accept (1.7.0)
61
62
  http-cookie (1.0.5)
62
63
  domain_name (~> 0.5)
63
64
  httpclient (2.8.3)
64
- i18n (1.12.0)
65
+ i18n (1.14.1)
65
66
  concurrent-ruby (~> 1.0)
66
67
  json (2.6.3)
67
68
  mime-types (3.4.1)
68
69
  mime-types-data (~> 3.2015)
69
- mime-types-data (3.2022.0105)
70
- minitest (5.17.0)
70
+ mime-types-data (3.2023.0218.1)
71
+ minitest (5.18.1)
71
72
  netrc (0.11.0)
72
73
  public_suffix (5.0.1)
73
74
  pubnub (4.8.0)
@@ -83,14 +84,14 @@ GEM
83
84
  http-cookie (>= 1.0.2, < 2.0)
84
85
  mime-types (>= 1.16, < 4.0)
85
86
  netrc (~> 0.8)
86
- thor (1.2.1)
87
- timers (4.3.3)
88
- tzinfo (2.0.5)
87
+ thor (1.2.2)
88
+ timers (4.3.5)
89
+ tzinfo (2.0.6)
89
90
  concurrent-ruby (~> 1.0)
90
91
  unf (0.1.4)
91
92
  unf_ext
92
93
  unf_ext (0.0.8.2)
93
- zeitwerk (2.6.6)
94
+ zeitwerk (2.6.8)
94
95
 
95
96
  PLATFORMS
96
97
  arm64-darwin-21
@@ -3,17 +3,17 @@ module Sapos
3
3
  module Print
4
4
  include Thor::Actions
5
5
  class CLI < Thor
6
-
6
+
7
7
  desc "setup", "Setup Wizard"
8
8
  def setup
9
9
  info
10
10
  config = {}
11
11
 
12
- url = ask("Configuration URL")
12
+ url = ask("URL de Configuración: ")
13
13
  if url.eql?('manual')
14
14
  data = {}
15
- data["channel"] = ask("Channel:")
16
- data["key"] = ask("Queue Key")
15
+ data["channel"] = ask("Canal:")
16
+ data["key"] = ask("Llave de la Cola:")
17
17
  else
18
18
  response = RestClient.get(url)
19
19
  data = JSON.parse(response)
@@ -31,16 +31,21 @@ module Sapos
31
31
 
32
32
  config[:q] = data["channel"]
33
33
  config[:key] = data["key"]
34
- config[:printer] = ask("Printer Name: ")
35
- config[:adapter] = ask("Printer Adapter: ", limited_to: ["console", "cups", "windows"])
34
+ config[:printer] = ask("Nombre de la impresora default: ")
35
+ config[:adapter] = ask("Adaptador: ", limited_to: ["console", "cups", "windows"])
36
36
  config[:interface] = ask("Interface", limited_to: ["text", "escp"])
37
37
  config[:user_id] = user_id
38
38
  config[:duplicate_control] = ask("¿Control Duplicados por MSGID?", limited_to: ["si", "no"])
39
+ config[:printers] = [config[:printer]]
39
40
 
40
- if yes?("Are you sure that you want to write the configuration file?")
41
+ while yes?("¿Tiene impresoras adicionales?")
42
+ name = ask("Nombre de la impresora adicional: ")
43
+ config[:printers] << name
44
+ end
45
+ if yes?("¿Esta seguro que desea guardar la configuración?")
41
46
  Sapos::Print::Configuration.write(config)
42
47
  ap config
43
- say "Configuration Saved! Cheers"
48
+ say "La configuración ha sido guardada!"
44
49
  end
45
50
  end
46
51
 
@@ -64,9 +69,17 @@ module Sapos
64
69
  end
65
70
 
66
71
  desc "print", "demo print"
72
+ option :printer_name, type: :string
67
73
  def print
68
74
  info
69
75
  config = Sapos::Print.config
76
+ printer_name = options[:printer_name]
77
+ if printer_name.present?
78
+ if config.printers.any? && config.printers.include?(printer_name)
79
+ config.printer = printer_name
80
+ end
81
+ end
82
+ puts "Printing to: #{config.printer}"
70
83
  printer = Printer.new(config)
71
84
  printer.print(document: "This is a test\nprint page\nwithno special commands", document_number: "test", print_control: true)
72
85
  end
@@ -98,6 +111,27 @@ module Sapos
98
111
  end
99
112
  end
100
113
 
114
+ desc "test_q", "q reader test"
115
+ def test_q
116
+ config = Sapos::Print.config
117
+ puts ["Q=#{config.q.to_s}", "Printer=#{config.printer.to_s}", "Adapter=#{config.adapter.to_s}", "Interface=#{config.interface}", "DC=#{config.duplicate_control?}"].join(";")
118
+
119
+ Sapos::Print::QReader.printer_config = config
120
+ reader = QReader.new
121
+ puts reader.printer
122
+
123
+ message = {:document => "doc", :printer => "Daniel"}
124
+ ap reader.printers
125
+
126
+ Sapos::Print.config.printers.each do |p|
127
+ printer = reader.printers[p]
128
+ puts "Printing to: #{printer.config.printer}"
129
+ message[:document] = "Docu. #{p}"
130
+ printer.print(message)
131
+ end
132
+
133
+ end
134
+
101
135
  no_tasks do
102
136
  def info
103
137
  if @printed.nil?
@@ -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, :duplicate_control, :cache
9
+ attr_accessor :printer, :adapter, :interface, :q, :key, :emv_path, :emv_terminal, :user_id, :verbose, :duplicate_control, :cache, :printers, :verbose
10
10
 
11
11
  def self.write(args = {})
12
12
  config_file = "#{Sapos::Print.app_directory}/config.yml"
@@ -19,6 +19,7 @@ module Sapos
19
19
  template = ERB.new(File.read(config_file))
20
20
  result = YAML.load(template.result(binding))
21
21
  @printer = result[:printer]
22
+ @printers = result[:printers] || []
22
23
  @adapter = result[:adapter]
23
24
  @interface = result[:interface]
24
25
  @q = result[:q]
@@ -27,6 +28,7 @@ module Sapos
27
28
  @emv_terminal = result[:emv_terminal]
28
29
  @user_id = result[:user_id]
29
30
  @duplicate_control = result[:duplicate_control]
31
+ @verbose = result[:verbose]
30
32
  @cache = []
31
33
  else
32
34
  raise Sapos::Print::Error, "Configuration is missing. Make sure to create this file: #{config_file}"
@@ -50,7 +52,7 @@ module Sapos
50
52
  end
51
53
 
52
54
  def to_h
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 }
55
+ {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, printers: @printers }
54
56
  end
55
57
  end
56
58
  end
@@ -2,6 +2,7 @@ module Sapos
2
2
  module Print
3
3
  class Printer
4
4
 
5
+ attr_accessor :config
5
6
 
6
7
  def initialize(config)
7
8
  @config = config
@@ -11,6 +12,7 @@ module Sapos
11
12
  raw_message = args[:document]
12
13
 
13
14
  log_text = "id=#{args[:id]},doc=#{args[:document_number]},control=#{args[:print_control] ? "SI" : "NO"},cache=0\t"
15
+ log_text += "printer=#{args[:printer]}\t" if args[:printer]
14
16
  filename = "#{args[:document_number]}.print" if args[:document_number]
15
17
  filename = SecureRandom.hex if filename.nil?
16
18
  result = false
@@ -85,6 +87,7 @@ module Sapos
85
87
  case @config.adapter
86
88
  when 'console'
87
89
  puts "=> CONSOLE: file: #{opts[:file]}<=\n\n"
90
+ puts "=> Printer: #{@config.printer}"
88
91
  puts File.read(opts[:file])
89
92
  puts "\n=> END CONSOLE =<"
90
93
  return true
@@ -7,7 +7,7 @@ module Sapos
7
7
  attr_accessor :printer_config, :verbose
8
8
  end
9
9
 
10
- attr_accessor :pubnub, :printer, :config
10
+ attr_accessor :pubnub, :printer, :config, :printers
11
11
 
12
12
  def self.run!
13
13
  reader = QReader.new
@@ -29,8 +29,15 @@ module Sapos
29
29
  end
30
30
 
31
31
  document = Base64.decode64(msg)
32
-
33
- if !reader.printer.print(document: document, print_control: print_control, document_number: document_number, id: msgid)
32
+
33
+ current_printer = reader.printer
34
+ printer_name = 'default'
35
+ if msg['printer'] && reader.printers[msg['printer']]
36
+ printer_name = msg['printer']
37
+ current_printer = reader.printers[msg['printer']]
38
+ end
39
+
40
+ if !current_printer.print(document: document, print_control: print_control, document_number: document_number, id: msgid, printer: printer_name)
34
41
  puts "Printer Error"
35
42
  end
36
43
  rescue => e
@@ -51,6 +58,12 @@ module Sapos
51
58
  def initialize
52
59
  @config = QReader.printer_config
53
60
  @printer = Printer.new(@config)
61
+ @printers = {}
62
+ @config.printers.each do |printer|
63
+ config = @config.dup
64
+ config.printer = printer
65
+ @printers[printer] = Printer.new(config)
66
+ end
54
67
  @pubnub = Pubnub.new(subscribe_key: @config.key, user_id: @config.user_id, ssl: true)
55
68
  end
56
69
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sapos
4
4
  module Print
5
- VERSION = "1.0.10"
5
+ VERSION = "1.1.1"
6
6
  end
7
7
  end
data/sapos-print.gemspec CHANGED
@@ -40,7 +40,7 @@ Gem::Specification.new do |spec|
40
40
  spec.add_dependency "pubnub", "~> 4.8.0"
41
41
  spec.add_dependency "rest-client"
42
42
  spec.add_dependency "awesome_print"
43
- spec.add_dependency "activesupport"
43
+ spec.add_dependency "activesupport", "~> 6.1"
44
44
  spec.add_dependency "json"
45
45
 
46
46
  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.10
4
+ version: 1.1.1
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-22 00:00:00.000000000 Z
11
+ date: 2023-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: activesupport
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '6.1'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '6.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: json
85
85
  requirement: !ruby/object:Gem::Requirement