Skip to content

Commit

Permalink
Merge pull request #26 from mhfs/master
Browse files Browse the repository at this point in the history
Avoid iconv warnings on ruby 1.9.3 (fixes 23)
  • Loading branch information
shairontoledo committed Apr 19, 2012
2 parents 59305d9 + 1e0c596 commit 1d8cb17
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/rghost/ruby_ghost_config.rb
@@ -1,5 +1,4 @@
require "rghost/ps_object"
require 'iconv'
require 'rghost/font_map'

#Rghost setup with Ghostscript.
Expand Down Expand Up @@ -70,19 +69,20 @@ module RGhost::Config
:default_params=> %w(gs -dNOPAUSE -dBATCH -dQUIET -dNOPAGEPROMPT),
:stack_elements => 5000,
:font_encoding => :IsoLatin,
:charset_convert => lambda {|text| Iconv::iconv('latin1','utf-8', text).join },
#:charset_convert => nil,
:charset_convert => begin
if RUBY_VERSION =~ /^1.9/
lambda { |text| text.encode('ISO-8859-1', 'UTF-8') }
else
require 'iconv'
lambda { |text| Iconv::iconv('latin1','utf-8', text).join }
end
end,
:external_encoding => nil,
:fontsize => 8,
:unit => RGhost::Units::Cm
}





def self.config_platform #:nodoc:

const= 'PLATFORM'
const = "RUBY_"+const if RUBY_VERSION =~ /^1.9/
GS[:path]=case Object.const_get(const)
Expand All @@ -94,6 +94,7 @@ def self.config_platform #:nodoc:
not_found_msg="\nGhostscript not found in your environment.\nInstall it and set the variable RGhost::Config::GS[:path] with the executable.\nExample: RGhost::Config::GS[:path]='/path/to/my/gs' #unix-style\n RGhost::Config::GS[:path]=\"C:\\\\gs\\\\bin\\\\gswin32c.exe\" #windows-style\n"
raise not_found_msg unless (File.exists? GS[:path])
end

#Test if your environment is ready to works. If yes the page below will show.
#
#link:images/is_ok.png
Expand Down

0 comments on commit 1d8cb17

Please sign in to comment.