Merge pull request #208 from spodlecki/removing-httpclient

Remove httpclient due to deprecation warning for #timeout
This commit is contained in:
John McAliley 2016-02-02 19:28:34 -05:00
commit 6e551927ec
6 changed files with 21 additions and 11 deletions

View File

@ -2,7 +2,7 @@ language: ruby
before_script: before_script:
- cd tests/test_app - cd tests/test_app
- bundle exec rails g impressionist -f - bundle exec rails g impressionist -f
- bundle exec rake db:migrate - bundle exec rake db:create db:migrate RAILS_ENV=test
- cd .. - cd ..
rvm: rvm:
- 1.9.3 - 1.9.3

View File

@ -22,6 +22,9 @@ group :test do
gem 'simplecov' gem 'simplecov'
gem 'systemu' gem 'systemu'
gem 'friendly_id', '~> 4.0.9' gem 'friendly_id', '~> 4.0.9'
# test/unit has been removed by default in Ruby 2.2.x+
gem 'test-unit'
end end
gemspec :path => '../' gemspec :path => '../'

View File

@ -22,6 +22,9 @@ group :test do
gem 'simplecov' gem 'simplecov'
gem 'systemu' gem 'systemu'
gem 'friendly_id', '~> 5.1.0' gem 'friendly_id', '~> 5.1.0'
# test/unit has been removed by default in Ruby 2.2.x+
gem 'test-unit'
end end
gemspec :path => '../' gemspec :path => '../'

View File

@ -18,8 +18,6 @@ Gem::Specification.new do |s|
s.require_path = 'lib' s.require_path = 'lib'
s.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if s.respond_to? :required_rubygems_version= 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_dependency 'nokogiri', '~> 1.6'
s.add_development_dependency 'bundler', '~> 1.0' s.add_development_dependency 'bundler', '~> 1.0'
end end

View File

@ -1,11 +1,13 @@
require 'httpclient' require 'timeout'
require 'net/http'
require 'nokogiri' require 'nokogiri'
module Impressionist module Impressionist
module Bots module Bots
LIST_URL = "http://www.user-agents.org/allagents.xml" LIST_URL = "http://www.user-agents.org/allagents.xml"
def self.consume def self.consume
response = HTTPClient.new.get_content(LIST_URL) Timeout.timeout(4) do
response = Net::HTTP.get(URI.parse(LIST_URL))
doc = Nokogiri::XML(response) doc = Nokogiri::XML(response)
list = [] list = []
doc.xpath('//user-agent').each do |agent| doc.xpath('//user-agent').each do |agent|
@ -15,4 +17,5 @@ module Impressionist
list list
end end
end end
end
end end

View File

@ -36,6 +36,9 @@ group :development, :test do
gem 'autotest-notification' gem 'autotest-notification'
gem 'rspec-rails', '~> 2.14.0' gem 'rspec-rails', '~> 2.14.0'
gem 'spork' gem 'spork'
# test/unit has been removed by default in Ruby 2.2.x+
gem 'test-unit'
end end
group :test do group :test do