sapos-print 1.0.0 → 1.0.5

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: 384234557dbd5bbb4d34a176bff5b7380aa504fdfc386bb85152a707877ed9e2
4
- data.tar.gz: 3032008fbab84616cc3cab20e99020f5fafdbadfec367903147fbb56067c042c
3
+ metadata.gz: 2203b37a5896bdfef0ef71bd913dfd1a461fd9c5ee4c7a87205d864043aa1a7b
4
+ data.tar.gz: 5b241d186803fa7d09814390fa8b941b2e943d22c6be18b2c057a1d6b739d298
5
5
  SHA512:
6
- metadata.gz: 24faed91618fc8dbeea8e2cb72397ef811e6edf43553e2670da63ec822df6e97c99ddda2c038fede60cbb1a849a2ad11494a49771c5b674bd90cd2c238cfce60
7
- data.tar.gz: 4bd1addf3406a81a578548ee0ac4f3c4a10be72a3235ce17bdb203829aa6e06f4b74dfa1e9afb22e90c86a8892fff1b5e6ce8b168c657f0341c67f38cd642cc8
6
+ metadata.gz: c8d56b32df32d081146bec0cf5195d2df5c19596c90e84677275f2c4c37d2b8950c359dc6474e4489dc8d89f0352a630f818fd5f608efbe196a492db2c59f184
7
+ data.tar.gz: 52b50bdcc53db8ea52df802e14ce6d86863d5ca073fa50da38860cc188495e6b8422c1ce07634e0a3387ccc69beb2d4ae2bad35e1ed8b194d1af6e527d7c83cc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sapos-print (1.0.0)
4
+ sapos-print (1.0.1)
5
5
  activesupport
6
6
  awesome_print
7
7
  json
@@ -32,6 +32,11 @@ module Sapos
32
32
  config = Sapos::Print.config
33
33
  puts ["Q=#{config.q.to_s}", "Printer=#{config.printer.to_s}", "Adapter=#{config.adapter.to_s}", "Interface=#{config.interface}"].join("\n")
34
34
 
35
+ print_dir = File.join(Sapos::Print.app_directory, 'print')
36
+ if File.exists?(print_dir)
37
+ FileUtils.rm_rf Dir.glob("#{print_dir}/*")
38
+ end
39
+
35
40
  Sapos::Print::QReader.printer_config = config
36
41
  Sapos::Print::QReader.verbose = options[:verbose]
37
42
  Sapos::Print::QReader.run!
@@ -42,7 +47,33 @@ module Sapos
42
47
  info
43
48
  config = Sapos::Print.config
44
49
  printer = Printer.new(config)
45
- printer.print("This is a test\nprint page\nwithno special commands")
50
+ printer.print(document: "This is a test\nprint page\nwithno special commands", document_number: "test", print_control: true)
51
+ end
52
+
53
+ def windows_test_print
54
+ info
55
+
56
+ filename = "test.print"
57
+
58
+ dir = File.join(Dir.home,".sapos-print")
59
+ FileUtils.mkdir_p dir unless File.exists?(dir)
60
+ dir
61
+
62
+ print_dir = File.join(dir, 'print')
63
+
64
+ FileUtils.mkdir_p print_dir unless File.exists?(print_dir)
65
+ filename = File.join(print_dir, filename)
66
+
67
+ puts "Test file Path: #{filename}"
68
+ File.open(filename, 'w'){|f| f.write("Test\nTest\nTest")}
69
+ puts "Execute COPY Command"
70
+ command = "COPY "+"'"+filename.gsub("/","\\")+"'"+'"\\\\%COMPUTERNAME%\\'+"TM"
71
+
72
+ if !system(command)
73
+ puts "ERROR"
74
+ else
75
+ puts "OK"
76
+ end
46
77
  end
47
78
 
48
79
  no_tasks do
@@ -2,26 +2,47 @@ module Sapos
2
2
  module Print
3
3
  class Printer
4
4
 
5
+
5
6
  def initialize(config)
6
7
  @config = config
7
8
  end
8
9
 
9
- def print(raw_message)
10
- puts "Print =>"
11
- filename = SecureRandom.hex
10
+ def print(args = {})
11
+ raw_message = args[:document]
12
+
13
+ log_text = "Print #{args[:document_number]},#{args[:print_control]}"
14
+ filename = "#{args[:document_number]}.print" if args[:document_number]
15
+ filename = SecureRandom.hex if filename.nil?
12
16
  result = false
13
17
  raw = raw_message.force_encoding("UTF-8")
14
18
  begin
15
- printable = data(raw_message)
16
- File.open(filename, 'w'){|f| f.write(printable)}
17
- result = send_to_printer({file: filename})
18
- puts "Result: #{result}"
19
+ if args[:print_control] && args[:document_number]
20
+ print_dir = File.join(Sapos::Print.app_directory, 'print')
21
+ FileUtils.mkdir_p print_dir unless File.exists?(print_dir)
22
+
23
+ filename = File.join(print_dir, filename)
24
+ if !File.exists?(filename)
25
+ printable = data(raw_message)
26
+ File.open(filename, 'w'){|f| f.write(printable)}
27
+ result = send_to_printer({file: filename})
28
+ #puts "Result: #{result}"
29
+ log_text += " => OK"
30
+ end
31
+ else
32
+ printable = data(raw_message)
33
+ File.open(filename, 'w'){|f| f.write(printable)}
34
+ result = send_to_printer({file: filename})
35
+ File.delete(filename) if File.exists?(filename)
36
+ #puts "Result: #{result}"
37
+ log_text += " => OK"
38
+ end
39
+ puts log_text
19
40
  rescue => e
20
41
  puts "#{e.message}"
21
42
  self.errors = e.message
22
43
  result = false
23
44
  ensure
24
- File.delete(filename) if File.exists?(filename)
45
+ #File.delete(filename) if File.exists?(filename)
25
46
  return result
26
47
  end
27
48
 
@@ -68,7 +89,10 @@ module Sapos
68
89
  return true
69
90
 
70
91
  when 'windows'
71
- command = "copy #{opts[:file]} "+'"\\\\%COMPUTERNAME%\\'+@config.printer
92
+ #command = "copy" + ' "' + filename + '" ' + '"\\\\%COMPUTERNAME%\\'+"TM"
93
+ filename = opts[:file].to_s.gsub("/","\\")
94
+ command = "COPY " + '"' + filename + '" ' + '"\\\\%COMPUTERNAME%\\' + @config.printer
95
+ #command = "copy #{opts[:file]} "+'"\\\\%COMPUTERNAME%\\'+@config.printer
72
96
  if !system(command)
73
97
  puts "Not executed"
74
98
  return false
@@ -14,7 +14,10 @@ module Sapos
14
14
  callback = Pubnub::SubscribeCallback.new(
15
15
  message: -> (envelope){
16
16
  document = Base64.decode64(envelope.result[:data][:message]['document'])
17
- if reader.printer.print(document)
17
+ print_control = envelope.result[:data][:message]['print_control']
18
+ document_number = envelope.result[:data][:message]['document_number']
19
+
20
+ if reader.printer.print(document: document, print_control: print_control, document_number: document_number)
18
21
  puts "OK"
19
22
  else
20
23
  puts "Printer Error".red
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sapos
4
4
  module Print
5
- VERSION = "1.0.0"
5
+ VERSION = "1.0.5"
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.0
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josef Sauter
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-08 00:00:00.000000000 Z
11
+ date: 2022-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -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.1.4
141
+ rubygems_version: 3.2.3
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: SAPOSCLOUD PRINT