-
Notifications
You must be signed in to change notification settings - Fork 13
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
Upgrade to faraday 2 #50
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
source 'https://rubygems.org' | ||
|
||
# rack 2.x requires ruby 2.2.x | ||
if RUBY_VERSION < '2.2' | ||
gem 'rack', '~> 1.6.0', group: :test | ||
end | ||
|
||
gemspec |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
# coding: utf-8 | ||
lib = File.expand_path('../lib', __FILE__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
require 'cover_my_meds/version' | ||
require_relative 'lib/cover_my_meds/version' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quit messing with $LOAD_PATH. |
||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "cover_my_meds" | ||
|
@@ -12,26 +10,23 @@ Gem::Specification.new do |spec| | |
spec.summary = %q{CoverMyMeds Public API} | ||
spec.description = %q{The public version of CoverMyMeds API} | ||
spec.homepage = "https://github.com/covermymeds/cover_my_meds" | ||
|
||
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } | ||
spec.bindir = "exe" | ||
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } | ||
spec.require_paths = ["lib"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no executables, and lib is already the default require path. No idea why the default name was even changed. |
||
|
||
spec.add_development_dependency "bundler" | ||
spec.add_development_dependency "rspec", ">= 3.2" | ||
spec.add_development_dependency "rspec-junklet", ">= 2.0" | ||
spec.add_development_dependency "webmock", "~> 2.0" | ||
spec.add_development_dependency "rspec" | ||
spec.add_development_dependency "rspec-junklet" | ||
spec.add_development_dependency "webmock" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can forego versioning on dev dependencies unless we're really locked into a version. |
||
spec.add_development_dependency "rake" | ||
spec.add_development_dependency "pry" | ||
spec.add_development_dependency "dotenv" | ||
spec.add_development_dependency "simplecov" | ||
spec.add_development_dependency "railties" | ||
|
||
spec.add_runtime_dependency "faraday", ">= 1.0", "< 2.0" | ||
spec.add_runtime_dependency "faraday_middleware" | ||
spec.add_runtime_dependency "typhoeus" | ||
spec.add_runtime_dependency "mime-types" | ||
spec.add_runtime_dependency "hashie", ">= 3.4.0" | ||
spec.add_runtime_dependency "activesupport", ">= 4.2.2" | ||
spec.add_runtime_dependency "faraday", "~> 2.9.0" | ||
spec.add_runtime_dependency "faraday-follow_redirects", "~> 0.3.0" | ||
spec.add_runtime_dependency "faraday-multipart", "~> 1.0.4" | ||
spec.add_runtime_dependency "faraday-typhoeus", "~> 1.1.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The extra faraday-xxx dependencies here were required because of the updated faraday gem, i.e. multipart and redirect are no longer baked into it, but require separate gems. |
||
spec.add_runtime_dependency "mime-types", "~> 3.5.2" | ||
spec.add_runtime_dependency "hashie", "~> 5.0.0" | ||
spec.add_runtime_dependency "activesupport", "~> 7.0.8" | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
require 'faraday' | ||
require 'faraday_middleware' | ||
require 'typhoeus' | ||
require 'typhoeus/adapters/faraday' | ||
require 'faraday/typhoeus' | ||
require 'faraday/multipart' | ||
require 'faraday/follow_redirects' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||
require 'json' | ||
require 'hashie' | ||
require 'active_support/core_ext/object/to_param' | ||
require 'active_support/core_ext/object/to_query' | ||
require 'cover_my_meds/error' | ||
require 'mime-types' | ||
|
||
|
||
module CoverMyMeds | ||
module ApiRequest | ||
DEFAULT_TIMEOUT = 60 #seconds, matches Net::Http's default which rest-client used | ||
|
@@ -19,17 +18,18 @@ def request(http_method, host, path, params={}, auth_type = :basic, &block) | |
headers = params.delete(:headers) || {} | ||
timeout = params.delete(:timeout) || DEFAULT_TIMEOUT | ||
|
||
conn = Faraday.new host do |faraday| | ||
conn = Faraday.new(host) do |faraday| | ||
faraday.request :multipart | ||
faraday.request :url_encoded | ||
faraday.response :follow_redirects | ||
faraday.adapter :typhoeus | ||
end | ||
|
||
case auth_type | ||
when :basic | ||
conn.request :basic_auth, @username, @password | ||
when :bearer | ||
conn.authorization :Bearer, "#{@username}+#{params.delete(:token_id)}" | ||
when :basic | ||
conn.set_basic_auth(@username, @password) | ||
when :bearer | ||
headers['Authorization'] = "Bearer #{@username}+#{params.delete(:token_id)}" | ||
end | ||
|
||
response = conn.send http_method do |request| | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module CoverMyMeds | ||
VERSION = "3.4.1" | ||
VERSION = "3.5.0" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The minimum was already set to 2.6, this is pointless, removed.