Skip to content

Commit

Permalink
removing httpclient due to deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
spodlecki committed Dec 30, 2015
1 parent aae4292 commit b38845a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 0 additions & 2 deletions impressionist.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if s.respond_to? :required_rubygems_version=

s.add_dependency 'httpclient', '~> 2.2'
s.add_dependency 'nokogiri', '~> 1.6'

s.add_development_dependency 'bundler', '~> 1.0'
end
19 changes: 11 additions & 8 deletions lib/impressionist/bots.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
require 'httpclient'
require 'timeout'
require 'net/http'
require 'nokogiri'

module Impressionist
module Bots
LIST_URL = "http://www.user-agents.org/allagents.xml"
def self.consume
response = HTTPClient.new.get_content(LIST_URL)
doc = Nokogiri::XML(response)
list = []
doc.xpath('//user-agent').each do |agent|
type = agent.xpath("Type").text
list << agent.xpath("String").text.gsub("&lt;","<") if ["R","S"].include?(type) #gsub hack for badly formatted data
Timeout.timeout(4) do
response = Net::HTTP.get(URI.parse(LIST_URL))
doc = Nokogiri::XML(response)
list = []
doc.xpath('//user-agent').each do |agent|
type = agent.xpath("Type").text
list << agent.xpath("String").text.gsub("&lt;","<") if ["R","S"].include?(type) #gsub hack for badly formatted data
end
list
end
list
end
end
end
3 changes: 3 additions & 0 deletions tests/test_app/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ group :development, :test do
gem 'autotest-notification'
gem 'rspec-rails', '~> 2.14.0'
gem 'spork'

# test/unit has been removed by default in Ruby 2.2.x+
gem 'test-unit'
end

group :test do
Expand Down

0 comments on commit b38845a

Please sign in to comment.