Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing Rest Client w/HTTP #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/ogpr/fetcher/html_fetcher.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require 'uri'
require 'rest-client'
require 'http'
require 'kconv'

module Ogpr
Expand Down Expand Up @@ -32,11 +32,11 @@ def acceptable_content!(content_type)
end

def send_request(method, uri, headers)
RestClient::Request.execute(
request_options(method, uri, headers)
)
rescue RestClient::ExceptionWithResponse => e
raise "Got http status code(#{e.response.code}) by #{method} request from #{uri}"
HTTP.headers(headers).send(method, uri).tap do |res|
next if res.status.success?

raise "Got http status code(#{res.status.code}) by #{method} request from #{uri}"
end
rescue => e
raise e
end
Expand Down
16 changes: 7 additions & 9 deletions ogpr.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_development_dependency "bundler", "~> 1.17.3"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "bundler", ">= 1.17.3"
spec.add_development_dependency "rake", "~> 13.1.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "sinatra", "~> 2.0.1"
spec.add_development_dependency 'rubocop', '~> 0.52.1'
spec.add_development_dependency "webmock", "~> 3.3.0"
spec.add_development_dependency "simplecov", "~> 0.14.1"
spec.add_development_dependency "coveralls", "~> 0.8.21"
spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0"
spec.add_dependency 'rest-client', '~> 2.1.0'
spec.add_development_dependency "sinatra", "~> 4.0.0"
spec.add_development_dependency 'rubocop', "~> 1.60.2"
spec.add_development_dependency "webmock", "~> 3.20.0"
spec.add_development_dependency "simplecov", "~> 0.22.0"
spec.add_dependency 'http', '~> 5.2.0'
spec.add_dependency 'nokogiri', '~> 1.8'
end