escper 1.1.3 → 1.1.4
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.
- data/lib/escper/printer.rb +5 -3
- data/lib/escper/version.rb +1 -1
- metadata +1 -1
data/lib/escper/printer.rb
CHANGED
@@ -7,6 +7,7 @@ module Escper
|
|
7
7
|
@subdomain = subdomain
|
8
8
|
@open_printers = Hash.new
|
9
9
|
@codepages_lookup = YAML::load(File.read(Escper.codepage_file))
|
10
|
+
@file_mode = 'wb'
|
10
11
|
if vendor_printers.kind_of?(ActiveRecord::Relation) or vendor_printers.kind_of?(Array)
|
11
12
|
@vendor_printers = vendor_printers
|
12
13
|
elsif vendor_printers.kind_of? VendorPrinter
|
@@ -92,6 +93,7 @@ module Escper
|
|
92
93
|
if Escper.use_safe_device_path == true
|
93
94
|
sanitized_path = path.gsub(/[\/\s'"\&\^\$\#\!;\*]/,'_').gsub(/[^\w\/\.\-@]/,'')
|
94
95
|
path = File.join(Escper.safe_device_path, @subdomain, "#{sanitized_path}.bill")
|
96
|
+
@file_mode = 'ab'
|
95
97
|
end
|
96
98
|
|
97
99
|
ActiveRecord::Base.logger.info "[PRINTING] Trying to open #{ name } @ #{ path } ..."
|
@@ -106,7 +108,7 @@ module Escper
|
|
106
108
|
end
|
107
109
|
|
108
110
|
begin
|
109
|
-
printer = File.open path,
|
111
|
+
printer = File.open path, @file_mode
|
110
112
|
@open_printers.merge! pid => { :name => name, :path => path, :copies => p.copies, :device => printer, :codepage => codepage }
|
111
113
|
ActiveRecord::Base.logger.info "[PRINTING] Success for File: #{ printer.inspect }"
|
112
114
|
next
|
@@ -124,14 +126,14 @@ module Escper
|
|
124
126
|
end
|
125
127
|
unless @open_printers.has_key? p.id
|
126
128
|
path = File.join(Rails.root, 'tmp')
|
127
|
-
printer = File.open(File.join(path, "#{ p.id }-#{ name }-fallback-busy.salor"),
|
129
|
+
printer = File.open(File.join(path, "#{ p.id }-#{ name }-fallback-busy.salor"), @file_mode)
|
128
130
|
@open_printers.merge! pid => { :name => name, :path => path, :copies => p.copies, :device => printer, :codepage => codepage }
|
129
131
|
ActiveRecord::Base.logger.info "[PRINTING] Failed to open as either SerialPort or USB File and resource IS busy. This should not have happened. Created #{ printer.inspect } instead."
|
130
132
|
end
|
131
133
|
next
|
132
134
|
rescue Exception => e
|
133
135
|
path = File.join(Rails.root, 'tmp')
|
134
|
-
printer = File.open(File.join(path, "#{ p.id }-#{ name }-fallback-notbusy.salor"),
|
136
|
+
printer = File.open(File.join(path, "#{ p.id }-#{ name }-fallback-notbusy.salor"), @file_mode)
|
135
137
|
@open_printers.merge! pid => { :name => name, :path => path, :copies => p.copies, :device => printer, :codepage => codepage }
|
136
138
|
ActiveRecord::Base.logger.info "[PRINTING] Failed to open as either SerialPort or USB File and resource is NOT busy. Created #{ printer.inspect } instead."
|
137
139
|
end
|
data/lib/escper/version.rb
CHANGED