aitch 1.2.0 → 1.2.1

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: a3f4cd3269e5b709f85e34148b2ed6aad4a9080f9903dc625d4840d8ffc2293a
4
- data.tar.gz: d97a344ec31e5f6ba528f1d359b96aa2860ab51e1cdde507d5cbc0557e9a75a4
3
+ metadata.gz: ac6be3c16c842bbd1555aed0de859b6e62bf59f511cce28a6c441efd980e5751
4
+ data.tar.gz: 2ebc4b41d63c9dd41756bb7fff03b52a6cbca2f56ed310183bc158a822bbdbd9
5
5
  SHA512:
6
- metadata.gz: a11acc6e165677b372cd4c9a07b9fd33640611a056fb1c437917ffa1d89ab0520bcaf9943cd5e8f72a3f088942a8f7b9d968a59ec7207dc6a061f54364216aba
7
- data.tar.gz: a0228f9d4719ee0fddd2932fece69c454062d40f4526612b41044168198f7ec91478267163e343a995ceb5f8bbcdc1d4d228d8edb73a9845b5aa0d08145581c9
6
+ metadata.gz: 602da6e2d0aaf3812e7f19b84b48b47eaeac59086345bceb76c601eba64f369ae0833c32980f66b0c026338bb098ad72563d1a4d2fdf8384fe50792856d281a1
7
+ data.tar.gz: b35ef25d1e59cd76923e626fdd6d60a735977a35d6560a32fe3313a8421eeccbce9524163775651da6fc017fcd47f7ef20c7ec8a40460d4a627e2d75d334fae8
data/.rubocop.yml CHANGED
@@ -4,6 +4,7 @@ inherit_gem:
4
4
 
5
5
  AllCops:
6
6
  TargetRubyVersion: 2.5
7
+ NewCops: enable
7
8
 
8
9
  Layout/LineLength:
9
10
  Exclude:
@@ -13,14 +14,5 @@ Naming/AccessorMethodName:
13
14
  Exclude:
14
15
  - lib/aitch/request.rb
15
16
 
16
- Metrics/ClassLength:
17
- Enabled: false
18
-
19
- Metrics/AbcSize:
20
- Enabled: false
21
-
22
- Metrics/MethodLength:
23
- Enabled: false
24
-
25
- Metrics/ParameterLists:
17
+ Style/DocumentDynamicEvalDefinition:
26
18
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,40 +1,52 @@
1
1
  # Changelog
2
2
 
3
- * **1.0.1**
4
- * Fix a bug when JSON encoding body in a POST request.
5
- * **1.0.0**
6
- * Use frozen string magic comments
7
- * 307 redirections will honor the HTTP request method
8
- * Fix issue with redirection; it was including the target url for one level redirection.
9
- * Methods `Aitch::Response#html`, `Aitch::Response#json`, `Aitch::Response#xml` were removed; use `Aitch::Response#data` instead.
10
- * Add support to response parsers
11
- * **0.5.0** - May 24, 2015
12
- * Remove hard dependency on ActiveSupport
13
- * Add response validation
14
- * **0.4.1** - December 20, 2014
15
- * Consider default headers when returning content type (fixes issue with body's JSON encoding)
16
- * **0.4.0** - December 18, 2014
17
- * Add accessor method for setting request's content type
18
- * Automatically encodes body as JSON when content type matches `json`
19
- * JSON encoding now uses a parser
20
- * **0.3.0** - April 28, 2014
21
- * Make list of redirections available
22
- * Make the request URL available on responses
23
- * **0.2.1** - July 30, 2013
24
- * Add alias for `response.success?` (`response.ok?`)
25
- * **0.2.0** - July 28, 2013
26
- * Add DSL support
27
- * Create aliases for `response.data` (`response.xml` and `response.json`)
28
- * **0.1.5** - June 26, 2013
29
- * Fix issue with jRuby and `to_h` protocol
30
- * **0.1.4** - June 13, 2013
31
- * Accept headers as callable objects
32
- * Fix XML encoding, always converting values to UTF-8
33
- * **0.1.3** - May 12, 2013
34
- * Add response HTML parsing into Nokogiri object
35
- * **0.1.2** - May 10, 2013
36
- * Add response error code helpers, like `response.bad_request?` and `response.not_found?`
37
- * **0.1.1** - April 30, 2013
38
- * Add support for namespaces
39
- * **0.1.0** - April 29, 2013
40
- * Initial release
3
+ - **1.2.1**
4
+ - Avoid calling `to_h` when params are array-like.
5
+ - **1.2.0**
6
+ - Add support to base url.
7
+ - **1.1.0**
8
+ - Add keyword argument interface to methods like `Aitch.get` and alike.
9
+ - **1.0.2**
10
+ - Use `JSON.parse` rather than `JSON.load`.
11
+ - **1.0.1**
12
+ - Fix a bug when JSON encoding body in a POST request.
13
+ - **1.0.0**
14
+ - Use frozen string magic comments
15
+ - 307 redirections will honor the HTTP request method
16
+ - Fix issue with redirection; it was including the target url for one level
17
+ redirection.
18
+ - Methods `Aitch::Response#html`, `Aitch::Response#json`,
19
+ `Aitch::Response#xml` were removed; use `Aitch::Response#data` instead.
20
+ - Add support to response parsers
21
+ - **0.5.0** - May 24, 2015
22
+ - Remove hard dependency on ActiveSupport
23
+ - Add response validation
24
+ - **0.4.1** - December 20, 2014
25
+ - Consider default headers when returning content type (fixes issue with
26
+ body's JSON encoding)
27
+ - **0.4.0** - December 18, 2014
28
+ - Add accessor method for setting request's content type
29
+ - Automatically encodes body as JSON when content type matches `json`
30
+ - JSON encoding now uses a parser
31
+ - **0.3.0** - April 28, 2014
32
+ - Make list of redirections available
33
+ - Make the request URL available on responses
34
+ - **0.2.1** - July 30, 2013
35
+ - Add alias for `response.success?` (`response.ok?`)
36
+ - **0.2.0** - July 28, 2013
37
+ - Add DSL support
38
+ - Create aliases for `response.data` (`response.xml` and `response.json`)
39
+ - **0.1.5** - June 26, 2013
40
+ - Fix issue with jRuby and `to_h` protocol
41
+ - **0.1.4** - June 13, 2013
42
+ - Accept headers as callable objects
43
+ - Fix XML encoding, always converting values to UTF-8
44
+ - **0.1.3** - May 12, 2013
45
+ - Add response HTML parsing into Nokogiri object
46
+ - **0.1.2** - May 10, 2013
47
+ - Add response error code helpers, like `response.bad_request?` and
48
+ `response.not_found?`
49
+ - **0.1.1** - April 30, 2013
50
+ - Add support for namespaces
51
+ - **0.1.0** - April 29, 2013
52
+ - Initial release
data/aitch.gemspec CHANGED
@@ -6,16 +6,16 @@ Gem::Specification.new do |spec|
6
6
  spec.name = "aitch"
7
7
  spec.version = Aitch::VERSION
8
8
  spec.authors = ["Nando Vieira"]
9
- spec.email = ["fnando.vieira@gmail.com"]
9
+ spec.email = ["me@fnando.com"]
10
10
  spec.description = "A simple HTTP client"
11
11
  spec.summary = spec.description
12
12
  spec.homepage = "http://rubygems.org/gems/aitch"
13
13
  spec.license = "MIT"
14
14
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
15
+ spec.metadata["rubygems_mfa_required"] = "true"
15
16
 
16
17
  spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
18
  spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "nokogiri"
data/lib/aitch/request.rb CHANGED
@@ -77,7 +77,7 @@ module Aitch
77
77
 
78
78
  private def set_body(request)
79
79
  body_data = data
80
- body_data = data.to_h if data.respond_to?(:to_h)
80
+ body_data = data.to_h if data.respond_to?(:to_h) && !data.is_a?(Array)
81
81
 
82
82
  if content_type.to_s.match?(/\bjson\b/)
83
83
  body_data = ResponseParser::JSONParser.engine.dump(body_data)
@@ -53,15 +53,15 @@ module Aitch
53
53
  end
54
54
 
55
55
  def json?
56
- content_type =~ /json/
56
+ content_type.include?("json")
57
57
  end
58
58
 
59
59
  def xml?
60
- content_type =~ /xml/
60
+ content_type.include?("xml")
61
61
  end
62
62
 
63
63
  def html?
64
- content_type =~ /html/
64
+ content_type.include?("html")
65
65
  end
66
66
 
67
67
  def data
@@ -8,7 +8,7 @@ module Aitch
8
8
  end
9
9
 
10
10
  def self.match?(content_type)
11
- content_type =~ /html/
11
+ content_type.include?("html")
12
12
  end
13
13
 
14
14
  def self.load(source)
@@ -14,7 +14,7 @@ module Aitch
14
14
  end
15
15
 
16
16
  def self.match?(content_type)
17
- content_type =~ /json/
17
+ content_type.include?("json")
18
18
  end
19
19
 
20
20
  def self.load(source)
@@ -8,7 +8,7 @@ module Aitch
8
8
  end
9
9
 
10
10
  def self.match?(content_type)
11
- content_type =~ /xml/
11
+ content_type.include?("xml")
12
12
  end
13
13
 
14
14
  def self.load(source)
data/lib/aitch/uri.rb CHANGED
@@ -27,7 +27,7 @@ module Aitch
27
27
  end
28
28
 
29
29
  def request_uri
30
- [path, query, fragment].compact.join("")
30
+ [path, query, fragment].compact.join
31
31
  end
32
32
 
33
33
  def fragment
data/lib/aitch/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Aitch
4
- VERSION = "1.2.0"
4
+ VERSION = "1.2.1"
5
5
  end
@@ -87,6 +87,18 @@ class RequestTest < Minitest::Test
87
87
  assert_equal "a=1", request.body
88
88
  end
89
89
 
90
+ test "sets json body from array" do
91
+ data = [1, 2, 3]
92
+ request = build_request(
93
+ request_method: "post",
94
+ data: data,
95
+ content_type: "application/json",
96
+ options: {json_parser: JSON}
97
+ ).request
98
+
99
+ assert_equal "[1,2,3]", request.body
100
+ end
101
+
90
102
  test "sets request body from to_s protocol" do
91
103
  data = stub(to_s: "some body")
92
104
  request = build_request(request_method: "post", data: data).request
@@ -140,7 +152,7 @@ class RequestTest < Minitest::Test
140
152
  assert_equal :post, last_request.method
141
153
  assert_equal "a=1&b=2", last_request.body
142
154
  assert_equal "0.1", last_request.headers["Rendering"]
143
- assert_equal "user:pass", Base64.decode64(last_request.headers["Authorization"].split(" ").last)
155
+ assert_equal "user:pass", Base64.decode64(last_request.headers["Authorization"].split.last)
144
156
  end
145
157
 
146
158
  test "performs request when using kwargs" do
@@ -157,7 +169,7 @@ class RequestTest < Minitest::Test
157
169
  assert_equal :post, last_request.method
158
170
  assert_equal "a=1&b=2", last_request.body
159
171
  assert_equal "0.1", last_request.headers["Rendering"]
160
- assert_equal "user:pass", Base64.decode64(last_request.headers["Authorization"].split(" ").last)
172
+ assert_equal "user:pass", Base64.decode64(last_request.headers["Authorization"].split.last)
161
173
  end
162
174
 
163
175
  test "uses base url" do
@@ -7,7 +7,7 @@ class CustomResponseParserTest < Minitest::Test
7
7
  setup do
8
8
  parser = Class.new do
9
9
  def self.match?(content_type)
10
- content_type =~ /csv/
10
+ content_type.include?("csv")
11
11
  end
12
12
 
13
13
  def self.load(source)
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: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-18 00:00:00.000000000 Z
11
+ date: 2022-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -166,7 +166,7 @@ dependencies:
166
166
  version: '0'
167
167
  description: A simple HTTP client
168
168
  email:
169
- - fnando.vieira@gmail.com
169
+ - me@fnando.com
170
170
  executables: []
171
171
  extensions: []
172
172
  extra_rdoc_files: []
@@ -238,7 +238,8 @@ files:
238
238
  homepage: http://rubygems.org/gems/aitch
239
239
  licenses:
240
240
  - MIT
241
- metadata: {}
241
+ metadata:
242
+ rubygems_mfa_required: 'true'
242
243
  post_install_message:
243
244
  rdoc_options: []
244
245
  require_paths:
@@ -254,40 +255,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
255
  - !ruby/object:Gem::Version
255
256
  version: '0'
256
257
  requirements: []
257
- rubygems_version: 3.3.17
258
+ rubygems_version: 3.3.7
258
259
  signing_key:
259
260
  specification_version: 4
260
261
  summary: A simple HTTP client
261
- test_files:
262
- - test/aitch/aitch_test.rb
263
- - test/aitch/configuration_test.rb
264
- - test/aitch/dsl_test.rb
265
- - test/aitch/execute_test.rb
266
- - test/aitch/namespace_test.rb
267
- - test/aitch/request/client_https_test.rb
268
- - test/aitch/request/follow_redirect_test.rb
269
- - test/aitch/request/json_request_test.rb
270
- - test/aitch/request/request_class_test.rb
271
- - test/aitch/request/status_code_validation_test.rb
272
- - test/aitch/request_test.rb
273
- - test/aitch/response/custom_response_parser_test.rb
274
- - test/aitch/response/default_response_parser_test.rb
275
- - test/aitch/response/errors_test.rb
276
- - test/aitch/response/html_response_test.rb
277
- - test/aitch/response/json_response_test.rb
278
- - test/aitch/response/raw_response_test.rb
279
- - test/aitch/response/status_3xx_test.rb
280
- - test/aitch/response/status_4xx_test.rb
281
- - test/aitch/response/status_5xx_test.rb
282
- - test/aitch/response/xml_response_test.rb
283
- - test/aitch/response_parser/html_parser_test.rb
284
- - test/aitch/response_parser/json_parser_test.rb
285
- - test/aitch/response_parser/xml_parser_test.rb
286
- - test/aitch/response_test.rb
287
- - test/aitch/to_query_test.rb
288
- - test/aitch/uri_test.rb
289
- - test/aitch/utils/symbolize_keys_test.rb
290
- - test/aitch/utils/underscore_test.rb
291
- - test/fixtures/iso8859-1.xml
292
- - test/support/helpers.rb
293
- - test/test_helper.rb
262
+ test_files: []