net-hippie 0.2.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d1f9e15a11440c2c2468f74058b5149f192e4ad06ae6294611fb5338e647773
4
- data.tar.gz: a4d57905ab58bff0f00749087204dfd310e68a3b5089c29a0848e496a1c21bd8
3
+ metadata.gz: ca969a22c79466a3c517f262f6a7c72137a62304b358b2f1caeec7849e222357
4
+ data.tar.gz: e9faffeec00a494e39f795d5ab3d32c7f58e9027e3ec79106256ae2b7b70d6f0
5
5
  SHA512:
6
- metadata.gz: 6f097e0155295f4b1a8db79f355660a00f85567e01fea8b12b31ea054da73122428f79b1be4f43e7b112814251ffc1be897c143cc205f98c92bb5a8cec422922
7
- data.tar.gz: b93b6026fc81629f532f64b52e4fbb694a553e275affb4514e336e087fee71a429325012e4bcba258a8d73f16063011a6dfcc9453b3e47dda9ab35ea96895eeb
6
+ metadata.gz: 035f5e34f31997473705d0556ee16e3e038c004fff44065c7ac86c1ffa2abd659cf0eb7ef1ff44baf51f31c7113e623621d627fd5fbccc478616585a10b59aa0
7
+ data.tar.gz: f86f16b3fa730239cf81683a1087a275633b88cee991358e7ad282db965b18f9293fc4bf8de6c991dee7ad2921de5413bcbcd6abdb178a42d2f77c2da523fcc1
@@ -0,0 +1,17 @@
1
+ name: Test
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby: [ '2.5', '2.6', '2.7' ]
11
+ steps:
12
+ - uses: actions/checkout@v1
13
+ - uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: ${{ matrix.ruby }}
16
+ - name: cibuild
17
+ run: bin/cibuild
@@ -5,9 +5,10 @@ AllCops:
5
5
  - 'test/**/*'
6
6
  - 'tmp/**/*'
7
7
  - 'vendor/**/*'
8
- TargetRubyVersion: 2.6
8
+ NewCops: enable
9
+ TargetRubyVersion: 2.5
9
10
 
10
- Layout/AlignParameters:
11
+ Layout/ParameterAlignment:
11
12
  EnforcedStyle: with_fixed_indentation
12
13
 
13
14
  Naming/RescuedExceptionsVariableName:
@@ -1,4 +1,5 @@
1
- Version 0.2.6
1
+ Version 1.0.0
2
+
2
3
  # Changelog
3
4
  All notable changes to this project will be documented in this file.
4
5
 
@@ -7,6 +8,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
8
 
8
9
  ## [Unreleased]
9
10
 
11
+ ## [1.0.0] - 2020-07-31
12
+ ### Added
13
+ - Add simpler API to remove the need to instantiate a `Client` directly.
14
+ - Default to 3 retries using simple API.
15
+ - Re-use client connection for connections to the same scheme, host, and port.
16
+
17
+ ### Removed
18
+ - Remove support for Ruby 2.4
19
+ - Remove legacy `Api` class.
20
+
21
+ ### Changed
22
+ - Limit mutable options on Client.
23
+ - Change default `read_timeout` to 10 seconds.
24
+ - Change default `open_timeout` to 10 seconds.
25
+ - Log to `STDERR` by default instead of `STDOUT`.
26
+
27
+ ## [0.3.2] - 2020-01-28
28
+ ### Fixed
29
+ - Follow relative path redirects
30
+
31
+ ## [0.3.1] - 2020-01-14
32
+ ### Fixed
33
+ - Parse location header in response then follow redirect.
34
+ - Follow redirect using GET regardless of the original request method.
35
+
36
+ ## [0.3.0] - 2020-01-13
37
+ ### Added
38
+ - Allow following HTTP redirects.
39
+
40
+ ## [0.2.7] - 2019-10-04
41
+ ### Added
42
+ - add additional connection errors
43
+
44
+ ### Changed
45
+ - specify ruby 2.4 and minimum required.
46
+
10
47
  ## [0.2.6] - 2019-04-30
11
48
  ### Added
12
49
  - add support for PATCH verb.
@@ -32,7 +69,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
32
69
  - with\_retry.https://www.mokhan.ca/%F0%9F%92%8E/2018/11/10/net-hippie-0-2-0.html
33
70
  - authorization header helpers
34
71
 
35
- [Unreleased]: https://github.com/mokhan/net-hippie/compare/v0.2.6...HEAD
72
+ [Unreleased]: https://github.com/mokhan/net-hippie/compare/v1.0.0...HEAD
73
+ [1.0.0]: https://github.com/mokhan/net-hippie/compare/v0.3.2...v1.0.0
74
+ [0.3.2]: https://github.com/mokhan/net-hippie/compare/v0.3.1...v0.3.2
75
+ [0.3.1]: https://github.com/mokhan/net-hippie/compare/v0.3.0...v0.3.1
76
+ [0.3.0]: https://github.com/mokhan/net-hippie/compare/v0.2.7...v0.3.0
77
+ [0.2.7]: https://github.com/mokhan/net-hippie/compare/v0.2.6...v0.2.7
36
78
  [0.2.6]: https://github.com/mokhan/net-hippie/compare/v0.2.5...v0.2.6
37
79
  [0.2.5]: https://github.com/mokhan/net-hippie/compare/v0.2.4...v0.2.5
38
80
  [0.2.4]: https://github.com/mokhan/net-hippie/compare/v0.2.3...v0.2.4
data/Gemfile CHANGED
@@ -2,7 +2,5 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
-
7
5
  # Specify your gem's dependencies in net-hippie.gemspec
8
6
  gemspec
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Net::Hippie
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/net-hippie.svg)](https://rubygems.org/gems/net-hippie)
4
- [![Build Status](https://travis-ci.org/mokhan/net-hippie.svg?branch=master)](https://travis-ci.org/mokhan/net-hippie)
4
+ [![Build Status](https://github.com/mokhan/net-hippie/workflows/Test/badge.svg)](https://github.com/mokhan/net-hippie/actions)
5
5
 
6
- Net::Hippie is a light weight wrapper around `net/http` that defaults to
7
- sending JSON messages.
6
+ `Net::Hippie` is a light weight wrapper around `net/http` that defaults to
7
+ sending `JSON` messages.
8
8
 
9
9
  ## Installation
10
10
 
@@ -27,23 +27,22 @@ Or install it yourself as:
27
27
  ```ruby
28
28
  require 'net/hippie'
29
29
 
30
- Net::Hippie.logger = Rails.logger
31
-
32
- client = Net::Hippie::Client.new
30
+ Net::Hippie.logger = Logger.new(STDERR)
33
31
 
34
32
  headers = {
35
33
  'Accept' => 'application/vnd.haveibeenpwned.v2+json'
36
34
  }
37
35
 
38
- uri = URI.parse('https://haveibeenpwned.com/api/breaches')
39
- response = client.get(uri, headers: headers)
36
+ uri = 'https://haveibeenpwned.com/api/breaches'
37
+ response = Net::Hippie.get(uri, headers: headers)
40
38
  puts JSON.parse(response.body)
41
39
  ```
42
40
 
43
41
  ```ruby
44
- client = Net::Hippie::Client.new
45
- body = { user: { name: 'hippie' } }
46
- response = client.post(URI.parse('https://example.org'), body: body)
42
+ response = Net::Hippie.post(
43
+ 'https://example.org',
44
+ body: { name: 'hippie' }
45
+ )
47
46
  puts JSON.parse(response.body)
48
47
  ```
49
48
 
@@ -69,24 +68,30 @@ client = Net::Hippie::Client.new(
69
68
  ### Basic Auth
70
69
 
71
70
  ```ruby
72
- client = Net::Hippie::Client.new
73
- headers = { 'Authorization' => Net::Hippie.basic_auth('username', 'password') }
74
- client.get('https://www.example.org', headers: headers)
71
+ Net::Hippie.get(
72
+ 'https://www.example.org',
73
+ headers: {
74
+ 'Authorization' => Net::Hippie.basic_auth('username', 'password')
75
+ }
76
+ )
75
77
  ```
76
78
 
77
79
  ### Bearer Auth
78
80
 
79
81
  ```ruby
80
- client = Net::Hippie::Client.new
81
82
  headers = { 'Authorization' => Net::Hippie.bearer_auth('token') }
82
- client.get('https://www.example.org', headers: headers)
83
+ Net::Hippie.get('https://www.example.org', headers: headers)
83
84
  ```
84
85
 
85
86
  ## Development
86
87
 
87
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
88
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` to run the tests.
89
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
88
90
 
89
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
91
+ To install this gem onto your local machine, run `bundle exec rake install`.
92
+ To release a new version, update the version number in `version.rb`,
93
+ and then run `bin/shipit`, which will create a git tag for the version,
94
+ push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
90
95
 
91
96
  ## Contributing
92
97
 
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'rubocop/rake_task'
6
6
 
7
7
  Rake::TestTask.new(:test) do |t|
8
8
  t.libs << 'test'
9
- t.libs << 'lib'
9
+ t.verbose = true
10
10
  t.test_files = FileList['test/**/*_test.rb']
11
11
  end
12
12
  RuboCop::RakeTask.new(:rubocop)
@@ -1,15 +1,10 @@
1
1
  #!/bin/sh
2
2
 
3
- # script/cibuild: Setup environment for CI to run tests. This is primarily
4
- # designed to run on the continuous integration server.
5
-
6
3
  set -e
4
+ [ -z "$DEBUG" ] || set -x
7
5
 
8
6
  cd "$(dirname "$0")/.."
9
7
 
10
- echo [$(date "+%H:%M:%S")] "==> Started at…"
11
-
12
- # GC customizations
13
8
  export RUBY_GC_MALLOC_LIMIT=79000000
14
9
  export RUBY_GC_HEAP_INIT_SLOTS=800000
15
10
  export RUBY_HEAP_FREE_MIN=100000
@@ -17,7 +12,11 @@ export RUBY_HEAP_SLOTS_INCREMENT=400000
17
12
  export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
18
13
  export CIBUILD=1
19
14
 
20
- ruby -v
21
- gem install bundler:2.0.1 --conservative
15
+ echo "[$(date "+%H:%M:%S")] ==> Running setup…"
16
+ bin/setup
17
+
18
+ echo "[$(date "+%H:%M:%S")] ==> Running tests…"
22
19
  bin/test
20
+
21
+ echo "[$(date "+%H:%M:%S")] ==> Running linters…"
23
22
  bin/lint
data/bin/lint CHANGED
@@ -2,7 +2,4 @@
2
2
 
3
3
  set -e
4
4
 
5
- [ -z "$DEBUG" ] || set -x
6
-
7
- echo [$(date "+%H:%M:%S")] "==> Running linters…"
8
5
  bundle exec rake lint
data/bin/setup CHANGED
@@ -1,8 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
  IFS=$'\n\t'
4
- set -vx
5
4
 
5
+ ruby -v
6
+ gem install bundler -v '~> 2.0'
6
7
  bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/bin/test CHANGED
@@ -1,17 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
- # script/test: Run test suite for application. Optionally pass in a path to an
4
- # individual test file to run a single test.
5
-
6
-
7
3
  set -e
8
4
 
9
5
  cd "$(dirname "$0")/.."
10
6
 
11
- [ -z "$DEBUG" ] || set -x
12
-
13
- echo [$(date "+%H:%M:%S")] "==> Running setup…"
14
- bin/setup
15
-
16
- echo [$(date "+%H:%M:%S")] "==> Running tests…"
17
7
  bundle exec rake test
@@ -6,24 +6,32 @@ require 'logger'
6
6
  require 'net/http'
7
7
  require 'openssl'
8
8
 
9
- require 'net/hippie/version'
10
- require 'net/hippie/content_type_mapper'
11
9
  require 'net/hippie/client'
12
- require 'net/hippie/api'
10
+ require 'net/hippie/connection'
11
+ require 'net/hippie/content_type_mapper'
12
+ require 'net/hippie/version'
13
13
 
14
14
  module Net
15
15
  # net/http for hippies.
16
16
  module Hippie
17
17
  CONNECTION_ERRORS = [
18
18
  EOFError,
19
+ Errno::ECONNREFUSED,
20
+ Errno::ECONNRESET,
19
21
  Errno::ECONNRESET,
22
+ Errno::EHOSTUNREACH,
20
23
  Errno::EINVAL,
24
+ Net::OpenTimeout,
21
25
  Net::ProtocolError,
26
+ Net::ReadTimeout,
27
+ OpenSSL::OpenSSLError,
28
+ OpenSSL::SSL::SSLError,
29
+ SocketError,
22
30
  Timeout::Error
23
31
  ].freeze
24
32
 
25
33
  def self.logger
26
- @logger ||= Logger.new(STDOUT)
34
+ @logger ||= Logger.new(STDERR)
27
35
  end
28
36
 
29
37
  def self.logger=(logger)
@@ -45,5 +53,19 @@ module Net
45
53
  def self.bearer_auth(token)
46
54
  "Bearer #{token}"
47
55
  end
56
+
57
+ def self.method_missing(symbol, *args)
58
+ default_client.with_retry(retries: 3) do |client|
59
+ client.public_send(symbol, *args)
60
+ end || super
61
+ end
62
+
63
+ def self.respond_to_missing?(name, _include_private = false)
64
+ Client.public_instance_methods.include?(name.to_sym)
65
+ end
66
+
67
+ def self.default_client
68
+ @default_client ||= Client.new(follow_redirects: 3, logger: logger)
69
+ end
48
70
  end
49
71
  end
@@ -10,55 +10,50 @@ module Net
10
10
  'User-Agent' => "net/hippie #{Net::Hippie::VERSION}"
11
11
  }.freeze
12
12
 
13
- attr_accessor :mapper, :read_timeout, :open_timeout, :logger
14
-
15
- def initialize(certificate: nil, headers: DEFAULT_HEADERS,
16
- key: nil, passphrase: nil, verify_mode: Net::Hippie.verify_mode)
17
- @certificate = certificate
18
- @default_headers = headers
19
- @key = key
20
- @mapper = ContentTypeMapper.new
21
- @passphrase = passphrase
22
- @read_timeout = 30
23
- @verify_mode = verify_mode
24
- @logger = Net::Hippie.logger
13
+ attr_reader :mapper, :logger, :follow_redirects
14
+
15
+ def initialize(options = {})
16
+ @options = options
17
+ @mapper = options.fetch(:mapper, ContentTypeMapper.new)
18
+ @logger = options.fetch(:logger, Net::Hippie.logger)
19
+ @follow_redirects = options.fetch(:follow_redirects, 0)
20
+ @default_headers = options.fetch(:headers, DEFAULT_HEADERS)
21
+ @connections = Hash.new do |hash, key|
22
+ scheme, host, port = key
23
+ hash[key] = Connection.new(scheme, host, port, options)
24
+ end
25
25
  end
26
26
 
27
- def execute(uri, request)
28
- response = http_for(normalize_uri(uri)).request(request)
29
- if block_given?
30
- yield request, response
27
+ def execute(uri, request, limit: follow_redirects, &block)
28
+ connection = connection_for(uri)
29
+ response = connection.run(request)
30
+ if limit.positive? && response.is_a?(Net::HTTPRedirection)
31
+ url = connection.build_url_for(response['location'])
32
+ request = request_for(Net::HTTP::Get, url)
33
+ execute(url, request, limit: limit - 1, &block)
31
34
  else
32
- response
35
+ block_given? ? yield(request, response) : response
33
36
  end
34
37
  end
35
38
 
36
39
  def get(uri, headers: {}, body: {}, &block)
37
- request = request_for(Net::HTTP::Get, uri, headers: headers, body: body)
38
- execute(uri, request, &block)
40
+ run(uri, Net::HTTP::Get, headers, body, &block)
39
41
  end
40
42
 
41
43
  def patch(uri, headers: {}, body: {}, &block)
42
- type = Net::HTTP::Patch
43
- request = request_for(type, uri, headers: headers, body: body)
44
- execute(uri, request, &block)
44
+ run(uri, Net::HTTP::Patch, headers, body, &block)
45
45
  end
46
46
 
47
47
  def post(uri, headers: {}, body: {}, &block)
48
- type = Net::HTTP::Post
49
- request = request_for(type, uri, headers: headers, body: body)
50
- execute(uri, request, &block)
48
+ run(uri, Net::HTTP::Post, headers, body, &block)
51
49
  end
52
50
 
53
51
  def put(uri, headers: {}, body: {}, &block)
54
- request = request_for(Net::HTTP::Put, uri, headers: headers, body: body)
55
- execute(uri, request, &block)
52
+ run(uri, Net::HTTP::Put, headers, body, &block)
56
53
  end
57
54
 
58
55
  def delete(uri, headers: {}, body: {}, &block)
59
- type = Net::HTTP::Delete
60
- request = request_for(type, uri, headers: headers, body: body)
61
- execute(uri, request, &block)
56
+ run(uri, Net::HTTP::Delete, headers, body, &block)
62
57
  end
63
58
 
64
59
  # attempt 1 -> delay 0.1 second
@@ -82,8 +77,6 @@ module Net
82
77
  private
83
78
 
84
79
  attr_reader :default_headers
85
- attr_reader :verify_mode
86
- attr_reader :certificate, :key, :passphrase
87
80
 
88
81
  def attempt(attempt, max)
89
82
  yield
@@ -91,45 +84,25 @@ module Net
91
84
  raise error if attempt == max
92
85
 
93
86
  delay = ((2**attempt) * 0.1) + Random.rand(0.05) # delay + jitter
94
- warn("`#{error.message}` Retry: #{attempt + 1}/#{max} Delay: #{delay}s")
87
+ logger.warn("`#{error.message}` #{attempt + 1}/#{max} Delay: #{delay}s")
95
88
  sleep delay
96
89
  end
97
90
 
98
- def http_for(uri)
99
- http = Net::HTTP.new(uri.host, uri.port)
100
- http.read_timeout = read_timeout
101
- http.open_timeout = open_timeout if open_timeout
102
- http.use_ssl = uri.scheme == 'https'
103
- http.verify_mode = verify_mode
104
- http.set_debug_output(logger)
105
- apply_client_tls_to(http)
106
- http
107
- end
108
-
109
91
  def request_for(type, uri, headers: {}, body: {})
110
92
  final_headers = default_headers.merge(headers)
111
- type.new(uri.to_s, final_headers).tap do |x|
93
+ type.new(URI.parse(uri.to_s), final_headers).tap do |x|
112
94
  x.body = mapper.map_from(final_headers, body) unless body.empty?
113
95
  end
114
96
  end
115
97
 
116
- def normalize_uri(uri)
117
- uri.is_a?(URI) ? uri : URI.parse(uri)
118
- end
119
-
120
- def private_key(type = OpenSSL::PKey::RSA)
121
- passphrase ? type.new(key, passphrase) : type.new(key)
122
- end
123
-
124
- def apply_client_tls_to(http)
125
- return if certificate.nil? || key.nil?
126
-
127
- http.cert = OpenSSL::X509::Certificate.new(certificate)
128
- http.key = private_key
98
+ def run(uri, http_method, headers, body, &block)
99
+ request = request_for(http_method, uri, headers: headers, body: body)
100
+ execute(uri, request, &block)
129
101
  end
130
102
 
131
- def warn(message)
132
- logger.warn(message)
103
+ def connection_for(uri)
104
+ uri = URI.parse(uri.to_s)
105
+ @connections[[uri.scheme, uri.host, uri.port]]
133
106
  end
134
107
  end
135
108
  end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Net
4
+ module Hippie
5
+ # A connection to a specific host
6
+ class Connection
7
+ def initialize(scheme, host, port, options = {})
8
+ http = Net::HTTP.new(host, port)
9
+ http.read_timeout = options.fetch(:read_timeout, 10)
10
+ http.open_timeout = options.fetch(:open_timeout, 10)
11
+ http.use_ssl = scheme == 'https'
12
+ http.verify_mode = options.fetch(:verify_mode, Net::Hippie.verify_mode)
13
+ http.set_debug_output(options.fetch(:logger, Net::Hippie.logger))
14
+ apply_client_tls_to(http, options)
15
+ @http = http
16
+ end
17
+
18
+ def run(request)
19
+ @http.request(request)
20
+ end
21
+
22
+ def build_url_for(path)
23
+ return path if path.start_with?('http')
24
+
25
+ "#{@http.use_ssl? ? 'https' : 'http'}://#{@http.address}#{path}"
26
+ end
27
+
28
+ private
29
+
30
+ def apply_client_tls_to(http, options)
31
+ return if options[:certificate].nil? || options[:key].nil?
32
+
33
+ http.cert = OpenSSL::X509::Certificate.new(options[:certificate])
34
+ http.key = private_key(options[:key], options[:passphrase])
35
+ end
36
+
37
+ def private_key(key, passphrase, type = OpenSSL::PKey::RSA)
38
+ passphrase ? type.new(key, passphrase) : type.new(key)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -5,6 +5,8 @@ module Net
5
5
  # Converts a ruby hash into a JSON string
6
6
  class ContentTypeMapper
7
7
  def map_from(headers, body)
8
+ return body if body.is_a?(String)
9
+
8
10
  content_type = headers['Content-Type'] || ''
9
11
  return JSON.generate(body) if content_type.include?('json')
10
12
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Net
4
4
  module Hippie
5
- VERSION = '0.2.6'
5
+ VERSION = '1.0.0'
6
6
  end
7
7
  end
@@ -21,10 +21,11 @@ Gem::Specification.new do |spec|
21
21
  spec.bindir = 'exe'
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
+ spec.required_ruby_version = '~> 2.5'
24
25
 
25
26
  spec.add_development_dependency 'minitest', '~> 5.0'
26
- spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rake', '~> 13.0'
27
28
  spec.add_development_dependency 'rubocop', '~> 0.55'
28
- spec.add_development_dependency 'vcr', '~> 4.0'
29
+ spec.add_development_dependency 'vcr', '~> 6.0'
29
30
  spec.add_development_dependency 'webmock', '~> 3.4'
30
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-hippie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-30 00:00:00.000000000 Z
11
+ date: 2020-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rubocop
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '4.0'
61
+ version: '6.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '4.0'
68
+ version: '6.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -88,10 +88,10 @@ executables:
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
+ - ".github/workflows/test.yml"
91
92
  - ".gitignore"
92
93
  - ".gitlab-ci.yml"
93
94
  - ".rubocop.yml"
94
- - ".travis.yml"
95
95
  - CHANGELOG.md
96
96
  - Gemfile
97
97
  - LICENSE.txt
@@ -105,8 +105,8 @@ files:
105
105
  - bin/test
106
106
  - exe/net-hippie
107
107
  - lib/net/hippie.rb
108
- - lib/net/hippie/api.rb
109
108
  - lib/net/hippie/client.rb
109
+ - lib/net/hippie/connection.rb
110
110
  - lib/net/hippie/content_type_mapper.rb
111
111
  - lib/net/hippie/version.rb
112
112
  - net-hippie.gemspec
@@ -120,16 +120,16 @@ require_paths:
120
120
  - lib
121
121
  required_ruby_version: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ">="
123
+ - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: '0'
125
+ version: '2.5'
126
126
  required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  requirements: []
132
- rubygems_version: 3.0.3
132
+ rubygems_version: 3.1.4
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: net/http for hippies. ☮️
@@ -1,8 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.4.5
5
- - 2.5.5
6
- - 2.6.3
7
- script:
8
- - bin/cibuild
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Net
4
- module Hippie
5
- # A no nonsense class to perform HTTP requests.
6
- class Api
7
- attr_reader :uri, :verify_mode
8
-
9
- def initialize(url, verify_none: false)
10
- @uri = URI.parse(url)
11
- @verify_mode = OpenSSL::SSL::VERIFY_NONE if verify_none
12
- end
13
-
14
- def get
15
- client.get(uri).body
16
- end
17
-
18
- def execute(request)
19
- client.execute(uri, request)
20
- end
21
-
22
- private
23
-
24
- def client
25
- @client ||= Client.new(headers: {}, verify_mode: verify_mode)
26
- end
27
- end
28
- end
29
- end