aitch 1.2.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +3 -0
- data/README.md +1 -1
- data/aitch.gemspec +1 -1
- data/lib/aitch/ext/to_query.rb +2 -2
- data/lib/aitch/location.rb +1 -1
- data/lib/aitch/request.rb +3 -3
- data/lib/aitch/response.rb +3 -5
- data/lib/aitch/utils.rb +1 -1
- data/lib/aitch/version.rb +1 -1
- data/test/aitch/request_test.rb +1 -1
- data/test/aitch/response/errors_test.rb +1 -1
- data/test/aitch/response/status_3xx_test.rb +11 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac06612095a2a08635037c6113a7cb93ce1e22463192ba8f1381e1c7b5657f85
|
4
|
+
data.tar.gz: 50b0cfb79bc02cf46ff4f4fd4b762fd06bb44d577c6c6afd9640f1a0141f3dfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfc6752814d6b44d4cf455a8cbb269cf8aaabcf3afa6379e34e7fae3a2bc53f2a3218ec33537a05bc8c5cf50c442f95cb126b0f011452caa811f9c2e74c4df5d
|
7
|
+
data.tar.gz: b2b1bee33eca007e77e36d687476eb8b3c34f6fa0d5d9d434feabeddef13a42a23bddabe2122000a47d5514b3b16581195cbd9f8fc5d4330dfe6b771c38346c1
|
data/.github/workflows/tests.yml
CHANGED
@@ -15,12 +15,12 @@ jobs:
|
|
15
15
|
strategy:
|
16
16
|
fail-fast: false
|
17
17
|
matrix:
|
18
|
-
ruby: ["
|
18
|
+
ruby: ["3.0", "3.1", "3.2"]
|
19
19
|
|
20
20
|
steps:
|
21
|
-
- uses: actions/checkout@
|
21
|
+
- uses: actions/checkout@v4
|
22
22
|
|
23
|
-
- uses: actions/cache@
|
23
|
+
- uses: actions/cache@v3
|
24
24
|
with:
|
25
25
|
path: vendor/bundle
|
26
26
|
key: >
|
@@ -31,7 +31,7 @@ jobs:
|
|
31
31
|
hashFiles('aitch.gemspec') }}
|
32
32
|
|
33
33
|
- name: Set up Ruby
|
34
|
-
uses:
|
34
|
+
uses: ruby/setup-ruby@v1
|
35
35
|
with:
|
36
36
|
ruby-version: ${{ matrix.ruby }}
|
37
37
|
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Aitch
|
2
2
|
|
3
|
-
[![Tests](https://github.com/fnando/aitch/workflows/
|
3
|
+
[![Tests](https://github.com/fnando/aitch/actions/workflows/tests.yml/badge.svg)](https://github.com/fnando/aitch/actions/workflows/tests.yml)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/fnando/aitch/badges/gpa.svg)](https://codeclimate.com/github/fnando/aitch)
|
5
5
|
[![Gem Version](https://img.shields.io/gem/v/aitch.svg)](https://rubygems.org/gems/aitch)
|
6
6
|
[![Gem Downloads](https://img.shields.io/gem/dt/aitch.svg)](https://rubygems.org/gems/aitch)
|
data/aitch.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = spec.description
|
12
12
|
spec.homepage = "http://rubygems.org/gems/aitch"
|
13
13
|
spec.license = "MIT"
|
14
|
-
spec.required_ruby_version = Gem::Requirement.new(">=
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
|
15
15
|
spec.metadata["rubygems_mfa_required"] = "true"
|
16
16
|
|
17
17
|
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
data/lib/aitch/ext/to_query.rb
CHANGED
@@ -70,11 +70,11 @@ class Hash
|
|
70
70
|
#
|
71
71
|
# This method is also aliased as +to_param+.
|
72
72
|
def to_query(namespace = nil)
|
73
|
-
|
73
|
+
filter_map do |key, value|
|
74
74
|
unless (value.is_a?(Hash) || value.is_a?(Array)) && value.empty?
|
75
75
|
value.to_query(namespace ? "#{namespace}[#{key}]" : key)
|
76
76
|
end
|
77
|
-
end.
|
77
|
+
end.sort! * "&"
|
78
78
|
end
|
79
79
|
|
80
80
|
alias to_param to_query
|
data/lib/aitch/location.rb
CHANGED
data/lib/aitch/request.rb
CHANGED
@@ -9,8 +9,8 @@ module Aitch
|
|
9
9
|
ACCEPT_ENCODING = "Accept-Encoding"
|
10
10
|
GZIP_DEFLATE = "gzip,deflate"
|
11
11
|
HTTPS = "https"
|
12
|
-
HEADER_SEPARATOR_RE = /[-_]
|
13
|
-
JSON_RE = /\bjson\b
|
12
|
+
HEADER_SEPARATOR_RE = /[-_]/
|
13
|
+
JSON_RE = /\bjson\b/
|
14
14
|
|
15
15
|
alias params= data=
|
16
16
|
alias body= data=
|
@@ -102,7 +102,7 @@ module Aitch
|
|
102
102
|
all_headers = options.fetch(:default_headers, {}).merge(headers)
|
103
103
|
|
104
104
|
all_headers.each do |name, value|
|
105
|
-
value = value.respond_to?(:call)
|
105
|
+
value = value.call if value.respond_to?(:call)
|
106
106
|
name = name.to_s.split(HEADER_SEPARATOR_RE).map(&:capitalize).join("-")
|
107
107
|
request[name] = value.to_s
|
108
108
|
end
|
data/lib/aitch/response.rb
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
module Aitch
|
4
4
|
class Response
|
5
|
-
extend Forwardable
|
6
|
-
|
7
5
|
JSON_STR = "json"
|
8
6
|
XML_STR = "xml"
|
9
7
|
HTML_STR = "html"
|
@@ -11,10 +9,9 @@ module Aitch
|
|
11
9
|
DOUBLE_COLON = "::"
|
12
10
|
SPACE_STR = " "
|
13
11
|
ERROR_SUFFIX = "_error"
|
14
|
-
X_RE = /^x
|
12
|
+
X_RE = /^x-/
|
15
13
|
|
16
|
-
|
17
|
-
attr_accessor :redirected_from, :url
|
14
|
+
attr_accessor :redirected_from, :url, :content_type
|
18
15
|
|
19
16
|
def self.description_for_code(code)
|
20
17
|
[code, DESCRIPTION[code]].compact.join(SPACE_STR)
|
@@ -24,6 +21,7 @@ module Aitch
|
|
24
21
|
@options = options
|
25
22
|
@http_response = http_response
|
26
23
|
@redirected_from = options.fetch(:redirected_from, [])
|
24
|
+
@content_type = http_response.content_type.to_s
|
27
25
|
end
|
28
26
|
|
29
27
|
ERRORS.each do |status_code, exception|
|
data/lib/aitch/utils.rb
CHANGED
data/lib/aitch/version.rb
CHANGED
data/test/aitch/request_test.rb
CHANGED
@@ -150,7 +150,7 @@ class RequestTest < Minitest::Test
|
|
150
150
|
|
151
151
|
test "sets basic auth credentials" do
|
152
152
|
request = build_request(options: {user: "USER", password: "PASS"}).request
|
153
|
-
credentials = Base64.decode64(request["Authorization"].gsub(
|
153
|
+
credentials = Base64.decode64(request["Authorization"].gsub("Basic ", ""))
|
154
154
|
|
155
155
|
assert_equal "USER:PASS", credentials
|
156
156
|
end
|
@@ -8,7 +8,7 @@ class ErrorsTest < Minitest::Test
|
|
8
8
|
|
9
9
|
test "detects response as #{name}" do
|
10
10
|
config = {}
|
11
|
-
http_response = stub(code: code)
|
11
|
+
http_response = stub(code: code, content_type: "text/html")
|
12
12
|
response = Aitch::Response.new(config, http_response)
|
13
13
|
|
14
14
|
assert response.public_send("#{name}?")
|
@@ -6,11 +6,20 @@ class Status3xxTest < Minitest::Test
|
|
6
6
|
setup { Aitch.configuration.follow_redirect = false }
|
7
7
|
|
8
8
|
test "sets default redirected from" do
|
9
|
-
|
9
|
+
response =
|
10
|
+
Aitch::Response.new({}, stub("response", content_type: "text/html"))
|
11
|
+
|
12
|
+
assert_empty response.redirected_from
|
10
13
|
end
|
11
14
|
|
12
15
|
test "uses provided redirected from" do
|
13
|
-
|
16
|
+
response =
|
17
|
+
Aitch::Response.new(
|
18
|
+
{redirected_from: ["URL"]},
|
19
|
+
stub("response", content_type: "text/html")
|
20
|
+
)
|
21
|
+
|
22
|
+
assert_equal ["URL"], response.redirected_from
|
14
23
|
end
|
15
24
|
|
16
25
|
test "has body" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aitch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -248,14 +248,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
248
248
|
requirements:
|
249
249
|
- - ">="
|
250
250
|
- !ruby/object:Gem::Version
|
251
|
-
version:
|
251
|
+
version: 3.0.0
|
252
252
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
253
253
|
requirements:
|
254
254
|
- - ">="
|
255
255
|
- !ruby/object:Gem::Version
|
256
256
|
version: '0'
|
257
257
|
requirements: []
|
258
|
-
rubygems_version: 3.4.
|
258
|
+
rubygems_version: 3.4.6
|
259
259
|
signing_key:
|
260
260
|
specification_version: 4
|
261
261
|
summary: A simple HTTP client
|