Skip to content

Commit

Permalink
Fix deprecation warnings by switching to default ruby 1.9 String#encode
Browse files Browse the repository at this point in the history
calls instead of iconv.
  • Loading branch information
djcp committed Aug 17, 2012
1 parent 4ecdaa8 commit babf6f2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/feed-abstract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$LOAD_PATH.unshift(File.dirname(__FILE__)) unless $LOAD_PATH.include?(File.dirname(__FILE__))

require 'rss'
require 'iconv'
#require 'iconv'

require 'rss_atom_monkeypatches'

Expand Down
5 changes: 3 additions & 2 deletions lib/feed-abstract/feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,17 @@ def initialize(xml = nil, opts = {})
input = (xml.respond_to?(:read)) ? xml.read : xml

if options[:force_encoding]
ic = Iconv.new(options[:output_encoding].upcase + ((options[:transliterate_characters]) ? '//TRANSLIT' : '') + '//IGNORE',options[:input_encoding].upcase)
if input.respond_to?(:encoding)
# ruby 1.9
# Only transcode if the encoding isn't valid.
# See: http://po-ru.com/diary/fixing-invalid-utf-8-in-ruby-revisited/ for why we're appending the extra space.
unless (input.encoding.to_s.upcase == options[:output_encoding].upcase && input.valid_encoding?)
input = ic.iconv(input << ' ')[0..-2]
input.encode!(options[:output_encoding], options[:input_encoding])
end
else
# ruby 1.8
require 'iconv'
ic = Iconv.new(options[:output_encoding].upcase + ((options[:transliterate_characters]) ? '//TRANSLIT' : '') + '//IGNORE',options[:input_encoding].upcase)
input = ic.iconv(input << ' ')[0..-2]
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/feed-abstract/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# encoding: UTF-8

module FeedAbstract
VERSION = "0.0.12"
VERSION = "0.0.13"
end
2 changes: 1 addition & 1 deletion spec/feed_abstract_channel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ module FeedAbstract
@oa.channel.rights.should == 'Connotea 2011'
@delicious.channel.rights.should == ''
@zotero.channel.rights.should == ''
@feedburner.channel.rights.should == ' 2011 Cable News Network LP, LLLP.'
@feedburner.channel.rights.should == '© 2011 Cable News Network LP, LLLP.'
@pyblosxom.channel.rights.should == 'Creative Commons Attribution-ShareAlike'
@chill.channel.rights.should == ''
@twitter.channel.rights.should == ''
Expand Down

0 comments on commit babf6f2

Please sign in to comment.