Skip to content

Commit

Permalink
don't use charlock_holmes
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 7, 2021
1 parent d63f1b1 commit 98dfdeb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
4 changes: 1 addition & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
PATH
remote: .
specs:
maremma (4.9)
maremma (4.9.1)
activesupport (>= 4.2.5)
addressable (>= 2.3.6)
builder (~> 3.2, >= 3.2.2)
charlock_holmes (~> 0.7.7)
excon (~> 0.71.0)
faraday (~> 0.17.3)
faraday-encoding (~> 0.0.4)
Expand All @@ -27,7 +26,6 @@ GEM
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2)
builder (3.2.4)
charlock_holmes (0.7.7)
concurrent-ruby (1.1.9)
crack (0.4.5)
rexml
Expand Down
14 changes: 4 additions & 10 deletions lib/maremma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
require "addressable/uri"
require "maremma/xml_converter"
require "maremma/version"
require "charlock_holmes"

module Maremma
DEFAULT_TIMEOUT = 60
Expand Down Expand Up @@ -230,15 +229,10 @@ def self.parse_error_response(string)
end

def self.parse_response(string, options = {})
detection = CharlockHolmes::EncodingDetector.detect(string)
utf8_encoded_content = CharlockHolmes::Converter.convert(string, detection[:encoding], "UTF-8")
return utf8_encoded_content if options[:raw]

from_json(utf8_encoded_content) || from_xml(utf8_encoded_content) || from_string(utf8_encoded_content)
rescue ArgumentError
# handle U_STRING_NOT_TERMINATED_WARNING
from_json(string.force_encoding("UTF-8")) || from_xml(string.force_encoding("UTF-8")) ||
from_string(string.force_encoding("UTF-8"))
string = string.dup.encode(Encoding.find("UTF-8"), invalid: :replace, undef: :replace, replace: "")
return string if options[:raw]

from_json(string) || from_xml(string) || from_string(string)
end

# currently supported by Twitter and Github
Expand Down
2 changes: 1 addition & 1 deletion lib/maremma/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Maremma
VERSION = "4.9".freeze
VERSION = "4.9.1".freeze
end
1 change: 0 additions & 1 deletion maremma.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Gem::Specification.new do |s|
s.add_dependency "activesupport", ">= 4.2.5"
s.add_dependency "addressable", ">= 2.3.6"
s.add_dependency "builder", "~> 3.2", ">= 3.2.2"
s.add_dependency "charlock_holmes", "~> 0.7.7"
s.add_dependency "excon", "~> 0.71.0"
s.add_dependency "faraday", "~> 0.17.3"
s.add_dependency "faraday-encoding", "~> 0.0.4"
Expand Down

0 comments on commit 98dfdeb

Please # to comment.