sapos-print 1.0.10 → 1.1.0

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: cc0f0e2c23bfce7306d2f9ad61b8c22133ea9a899bfbe7715ad412742e3dc0d1
4
+ data.tar.gz: 50c06d2cc61e089350ac62b05317d1ad894cf25debe67aba26baa6ddf0b14e35
5
5
  SHA512:
6
- metadata.gz: 6efbd8f30e2c9446c76fdd7e2cd7547c80dd90b6b04fc680c1d4c3eb245a696c6372a25a19e350ac64e7b1b807ab8a8ca22a7b2f5310d2080fa2375d10bb24cc
7
- data.tar.gz: 78b637abab89f3745d43c9b1cea5628997076c52f9f0399d840461d8c7a70793faada466143d8d230f6ac92ff698d97012fb00992f6197ffa7657c21b3b24c10
6
+ metadata.gz: bfe1ac23eb6b6696a3f97ee41d5574014e7979fc73735b3befec56c39c5e189d5175111da32e488cda1d9e7525d45a6950cbde53865fcfdfdfd7912714711ab5
7
+ data.tar.gz: 0fd6bd0aa7a28908221f6ed4a8f08666138542be8d6ae5d728840ede8a06da3f8c9d1e1a9a06a0696862a083a70b8503721ee0caf30c19940deff0e2f9eace03
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sapos-print (1.0.9)
4
+ sapos-print (1.0.10)
5
5
  activesupport
6
6
  awesome_print
7
7
  json
@@ -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
@@ -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
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]
@@ -50,7 +51,7 @@ module Sapos
50
51
  end
51
52
 
52
53
  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 }
54
+ {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
55
  end
55
56
  end
56
57
  end
@@ -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,14 @@ 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
+
35
+ if msg['printer'] && reader.printers[msg['printer']]
36
+ current_printer = reader.printers[msg['printer']]
37
+ end
38
+
39
+ if !current_printer.print(document: document, print_control: print_control, document_number: document_number, id: msgid)
34
40
  puts "Printer Error"
35
41
  end
36
42
  rescue => e
@@ -51,6 +57,12 @@ module Sapos
51
57
  def initialize
52
58
  @config = QReader.printer_config
53
59
  @printer = Printer.new(@config)
60
+ @printers = {}
61
+ @config.printers.each do |printer|
62
+ config = @config.dup
63
+ config.printer = printer
64
+ @printers[printer] = Printer.new(config)
65
+ end
54
66
  @pubnub = Pubnub.new(subscribe_key: @config.key, user_id: @config.user_id, ssl: true)
55
67
  end
56
68
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sapos
4
4
  module Print
5
- VERSION = "1.0.10"
5
+ VERSION = "1.1.0"
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.10
4
+ version: 1.1.0
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-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor