printr 0.5.1 → 0.5.2

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.
Files changed (3) hide show
  1. data/lib/printr.rb +7 -12
  2. data/printr.gemspec +1 -1
  3. metadata +2 -2
data/lib/printr.rb CHANGED
@@ -58,7 +58,7 @@ module Printr
58
58
  Printr.log "Getting Printers"
59
59
  if @@printr_source == :yaml then
60
60
  Printr.log "printr_source == :yaml"
61
- @@conf = YAML::load(File.open("#{RAILS_ROOT}/config/printrs.yml"))
61
+ @@conf = YAML::load(File.open("#{::Rails.root.to_s}/config/printrs.yml"))
62
62
  elsif @@printr_source.class == Hash then
63
63
  if @@printr_source[:active_record] then
64
64
  Printr.log "printr_source == :active_record"
@@ -155,12 +155,7 @@ module Printr
155
155
  # 3 the replacement etc. [needle,replace,needle,replace,needle,replace]
156
156
  Printr.log "sanitize(#{text[0..55]})"
157
157
  Printr.log "Forcing encoding to: " + Printr.encoding # Printr.encoding can be set in initializer with config.encoding = ISO-8859-15 etc
158
- begin
159
- text.encode! Printr.encoding;
160
- rescue
161
- Printr.log "Failed to encode with #{Printr.encoding}, trying UTF-8"
162
- begin text.encode! "UTF-8"; rescue; end
163
- end
158
+ text.encode! Printr.encoding
164
159
  char = ['ä', 'ü', 'ö', 'Ä', 'Ü', 'Ö', 'é', 'è', 'ú', 'ù', 'á', 'à', 'í', 'ì', 'ó', 'ò', 'â', 'ê', 'î', 'ô', 'û', 'ñ', 'ß']
165
160
  replacement = ["\x84", "\x81", "\x94", "\x8E", "\x9A", "\x99", "\x82", "\x8A", "\xA3", "\x97", "\xA0", "\x85", "\xA1", "\x8D", "\xA2", "\x95", "\x83", "\x88", "\x8C", "\x93", "\x96", "\xA4", "\xE1"]
166
161
  i = 0
@@ -177,16 +172,16 @@ module Printr
177
172
  rx = Printr.sanitize_tokens[i]
178
173
  rep = Printr.sanitize_tokens[i+1]
179
174
  Printr.log "Replacing: " + rx.to_s + " with " + rep.to_s
180
- begin text.gsub!(rx, rep); rescue; end
175
+ text.gsub!(rx, rep)
181
176
  i += 2
182
177
  end while i < Printr.sanitize_tokens.length
183
178
  return text
184
179
  end
185
180
 
186
181
  def sane_template(name,bndng)
187
- Printr.log "[Printr] attempting to print with template #{RAILS_ROOT}/app/views/#{Printr.scope}/#{name}.prnt.erb"
182
+ Printr.log "[Printr] attempting to print with template #{::Rails.root.to_s}/app/views/#{Printr.scope}/#{name}.prnt.erb"
188
183
  begin
189
- erb = ERB.new(File.new("#{RAILS_ROOT}/app/views/#{Printr.scope}/#{name}.prnt.erb",'r').read,0,'>')
184
+ erb = ERB.new(File.new("#{::Rails.root.to_s}/app/views/#{Printr.scope}/#{name}.prnt.erb",'r').read,0,'>')
190
185
  rescue Exception => e
191
186
  Printr.log "[Printr] Exception in view: " + $!.inspect
192
187
  end
@@ -198,9 +193,9 @@ module Printr
198
193
  return sanitize(text)
199
194
  end
200
195
  def template(name,bndng)
201
- Printr.log "[Printr] attempting to print with template #{RAILS_ROOT}/app/views/#{Printr.scope}/#{name}.prnt.erb"
196
+ Printr.log "[Printr] attempting to print with template #{::Rails.root.to_s}/app/views/#{Printr.scope}/#{name}.prnt.erb"
202
197
  begin
203
- erb = ERB.new(File.new("#{RAILS_ROOT}/app/views/#{Printr.scope}/#{name}.prnt.erb",'r').read,0,'>')
198
+ erb = ERB.new(File.new("#{::Rails.root.to_s}/app/views/#{Printr.scope}/#{name}.prnt.erb",'r').read,0,'>')
204
199
  rescue Exception => e
205
200
  Printr.log "[Printr] Exception in view: " + $!.inspect
206
201
  end
data/printr.gemspec CHANGED
@@ -4,7 +4,7 @@ require "printr/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "printr"
7
- s.version = '0.5.1'
7
+ s.version = '0.5.2'
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Michael Franzl","Jason Martin"]
10
10
  s.email = ["jason@jason-knight-martin.com"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: printr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-01-26 00:00:00.000000000Z
13
+ date: 2012-01-30 00:00:00.000000000Z
14
14
  dependencies: []
15
15
  description: This engine allows you to define printers and templates.
16
16
  email: