escper 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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, 'wb'
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"), 'wb')
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"), 'wb')
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
@@ -1,3 +1,3 @@
1
1
  module Escper
2
- VERSION = "1.1.3"
2
+ VERSION = "1.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: escper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: