sapos-print 1.0.5 → 1.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2203b37a5896bdfef0ef71bd913dfd1a461fd9c5ee4c7a87205d864043aa1a7b
4
- data.tar.gz: 5b241d186803fa7d09814390fa8b941b2e943d22c6be18b2c057a1d6b739d298
3
+ metadata.gz: 6676d897cee608283071d8a13da6989e1db58cbbab4f4ba819be4b6fc9f80b30
4
+ data.tar.gz: 7c59412ee4b5d748389662823f5b9502d2aee835d1261c21c9673cee0d561da2
5
5
  SHA512:
6
- metadata.gz: c8d56b32df32d081146bec0cf5195d2df5c19596c90e84677275f2c4c37d2b8950c359dc6474e4489dc8d89f0352a630f818fd5f608efbe196a492db2c59f184
7
- data.tar.gz: 52b50bdcc53db8ea52df802e14ce6d86863d5ca073fa50da38860cc188495e6b8422c1ce07634e0a3387ccc69beb2d4ae2bad35e1ed8b194d1af6e527d7c83cc
6
+ metadata.gz: cc05e1cdecdca5672a07e874afe94dce4232af5ab3c159352897e61222a24a91a25cbf894fca48cd464fbbbe12d166815e6828fbebece534c12bf27b2b020937
7
+ data.tar.gz: c1300e4a85fb10fdcba5b1df562b3bcdbb73f612dccea867590ce0fd492fb32b9002c10483c451500a9c8861168f9e97838dc6511f15d76dbd88d5f201924805
data/Gemfile.lock CHANGED
@@ -1,23 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sapos-print (1.0.1)
4
+ sapos-print (1.0.6)
5
5
  activesupport
6
6
  awesome_print
7
7
  json
8
- pubnub
8
+ pubnub (~> 4.8.0)
9
9
  rest-client
10
10
  thor
11
11
 
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activesupport (6.1.4.1)
15
+ activesupport (7.0.2)
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
- zeitwerk (~> 2.3)
21
20
  addressable (2.8.0)
22
21
  public_suffix (>= 2.0.2, < 5.0)
23
22
  awesome_print (1.9.2)
@@ -26,7 +25,7 @@ GEM
26
25
  concurrent-ruby (~> 1.1.5)
27
26
  domain_name (0.5.20190701)
28
27
  unf (>= 0.0.5, < 1.0.0)
29
- dry-configurable (0.13.0)
28
+ dry-configurable (0.14.0)
30
29
  concurrent-ruby (~> 1.0)
31
30
  dry-core (~> 0.6)
32
31
  dry-container (0.9.0)
@@ -35,7 +34,7 @@ GEM
35
34
  dry-core (0.7.1)
36
35
  concurrent-ruby (~> 1.0)
37
36
  dry-inflector (0.2.1)
38
- dry-initializer (3.0.4)
37
+ dry-initializer (3.1.1)
39
38
  dry-logic (1.2.0)
40
39
  concurrent-ruby (~> 1.0)
41
40
  dry-core (~> 0.5, >= 0.5)
@@ -62,16 +61,16 @@ GEM
62
61
  http-cookie (1.0.4)
63
62
  domain_name (~> 0.5)
64
63
  httpclient (2.8.3)
65
- i18n (1.8.11)
64
+ i18n (1.9.1)
66
65
  concurrent-ruby (~> 1.0)
67
66
  json (2.6.1)
68
67
  mime-types (3.4.1)
69
68
  mime-types-data (~> 3.2015)
70
- mime-types-data (3.2021.1115)
71
- minitest (5.14.4)
69
+ mime-types-data (3.2022.0105)
70
+ minitest (5.15.0)
72
71
  netrc (0.11.0)
73
72
  public_suffix (4.0.6)
74
- pubnub (4.7.1)
73
+ pubnub (4.8.0)
75
74
  addressable (>= 2.0.0)
76
75
  concurrent-ruby (~> 1.1.5)
77
76
  concurrent-ruby-edge (~> 0.5.0)
@@ -84,14 +83,13 @@ GEM
84
83
  http-cookie (>= 1.0.2, < 2.0)
85
84
  mime-types (>= 1.16, < 4.0)
86
85
  netrc (~> 0.8)
87
- thor (1.1.0)
86
+ thor (1.2.1)
88
87
  timers (4.3.3)
89
88
  tzinfo (2.0.4)
90
89
  concurrent-ruby (~> 1.0)
91
90
  unf (0.1.4)
92
91
  unf_ext
93
92
  unf_ext (0.0.8)
94
- zeitwerk (2.5.1)
95
93
 
96
94
  PLATFORMS
97
95
  arm64-darwin-21
@@ -12,12 +12,23 @@ module Sapos
12
12
  url = ask("Configuration URL")
13
13
  response = RestClient.get(url)
14
14
  data = JSON.parse(response)
15
+
16
+ config_file = "#{Sapos::Print.app_directory}/config.yml"
17
+ user_id = nil
18
+ if File.exist?(config_file)
19
+ template = ERB.new(File.read(config_file))
20
+ result = YAML.load(template.result(binding))
21
+ user_id = result[:user_id]
22
+ end
23
+
24
+ user_id = SecureRandom.uuid if user_id.nil?
15
25
 
16
26
  config[:q] = data["channel"]
17
27
  config[:key] = data["key"]
18
28
  config[:printer] = ask("Printer Name: ")
19
29
  config[:adapter] = ask("Printer Adapter: ", limited_to: ["console", "cups", "windows"])
20
30
  config[:interface] = ask("Interface", limited_to: ["text", "escp"])
31
+ config[:user_id] = user_id
21
32
 
22
33
  if yes?("Are you sure that you want to write the configuration file?")
23
34
  Sapos::Print::Configuration.write(config)
@@ -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
9
+ attr_accessor :printer, :adapter, :interface, :q, :key, :emv_path, :emv_terminal, :user_id
10
10
 
11
11
  def self.write(args = {})
12
12
  config_file = "#{Sapos::Print.app_directory}/config.yml"
@@ -26,6 +26,7 @@ module Sapos
26
26
  @key = result[:key]
27
27
  @emv_path = result[:emv_path]
28
28
  @emv_terminal = result[:emv_terminal]
29
+ @user_id = result[:user_id]
29
30
  else
30
31
  raise Sapos::Print::Error, "Configuration is missing. Make sure to create this file: #{config_file}"
31
32
  end
@@ -44,7 +45,7 @@ module Sapos
44
45
  end
45
46
 
46
47
  def to_h
47
- {printer: @printer, adapter: @adapter, interface: @interface, q: @q, key: @key, emv_path: @emv_path, emv_terminal: @emv_terminal }
48
+ {printer: @printer, adapter: @adapter, interface: @interface, q: @q, key: @key, emv_path: @emv_path, emv_terminal: @emv_terminal, user_id: @user_id }
48
49
  end
49
50
  end
50
51
  end
@@ -13,9 +13,17 @@ module Sapos
13
13
  reader = QReader.new
14
14
  callback = Pubnub::SubscribeCallback.new(
15
15
  message: -> (envelope){
16
- document = Base64.decode64(envelope.result[:data][:message]['document'])
17
- print_control = envelope.result[:data][:message]['print_control']
18
- document_number = envelope.result[:data][:message]['document_number']
16
+ msg = envelope.result[:data][:message]
17
+ print_control = nil
18
+ document_number = nil
19
+
20
+ if msg.is_a?(Hash)
21
+ msg = msg['document']
22
+ print_control = msg['print_control']
23
+ document_number = msg['document_number']
24
+ end
25
+
26
+ document = Base64.decode64(msg)
19
27
 
20
28
  if reader.printer.print(document: document, print_control: print_control, document_number: document_number)
21
29
  puts "OK"
@@ -37,7 +45,7 @@ module Sapos
37
45
  def initialize
38
46
  @config = QReader.printer_config
39
47
  @printer = Printer.new(@config)
40
- @pubnub = Pubnub.new(subscribe_key: @config.key)
48
+ @pubnub = Pubnub.new(subscribe_key: @config.key, user_id: @config.user_id)
41
49
  end
42
50
  end
43
51
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sapos
4
4
  module Print
5
- VERSION = "1.0.5"
5
+ VERSION = "1.0.7"
6
6
  end
7
7
  end
data/sapos-print.gemspec CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
  # guide at: https://bundler.io/guides/creating_gem.html
38
38
 
39
39
  spec.add_dependency "thor"
40
- spec.add_dependency "pubnub"
40
+ spec.add_dependency "pubnub", "~> 4.8.0"
41
41
  spec.add_dependency "rest-client"
42
42
  spec.add_dependency "awesome_print"
43
43
  spec.add_dependency "activesupport"
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.5
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josef Sauter
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-05 00:00:00.000000000 Z
11
+ date: 2023-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: pubnub
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 4.8.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 4.8.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rest-client
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  requirements: []
141
- rubygems_version: 3.2.3
141
+ rubygems_version: 3.1.4
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: SAPOSCLOUD PRINT