http.rb 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +24 -0
- data/README.md +1 -1
- data/http.rb.gemspec +2 -2
- data/lib/HTTP/VERSION.rb +1 -1
- data/lib/HTTP/verbs.rb +2 -3
- data/lib/HTTP.rb +0 -3
- metadata +3 -7
- data/lib/String/to_const.rb +0 -7
- data/lib/Thoran/Array/AllButFirst/all_but_first.rb +0 -28
- data/lib/Thoran/Array/FirstX/firstX.rb +0 -32
- data/lib/Thoran/String/ToConst/to_const.rb +0 -47
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eb37f747fc1a26c9785c5091e588c184c5b4718f2a407bb3c1390a93fc29213a
|
|
4
|
+
data.tar.gz: 422e9c8af9ec867e72fcbbbb4d824187cede13302341f74ab33e1854fc573c3d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: df47a27bc34caf88683b305710d2073a99086222ed77eb3ad5d3f4c2858fc59e82b8dcbb56459e883d19f1b06f33d48ee5e3a324f200a123c90756ecd679dad7
|
|
7
|
+
data.tar.gz: 80374cb8c16fa8edf649d541523f06d9bdce79f509342c31d49cdec7a6313c291ff863f878c15d9b7ea32aaa8594104588f5544b4120c1027e95a618a5fa2312
|
data/CHANGELOG
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
## 20260522
|
|
4
4
|
|
|
5
|
+
0.26.0: Documentation and housekeeping polish before 1.0.
|
|
6
|
+
|
|
7
|
+
1. ~ README.md: Opening blurb now lists all supported verbs (get, head, options, trace, post, put, patch, delete) rather than claiming only GET/POST support.
|
|
8
|
+
2. - TODO: All entries were marked (Done as of …); CHANGELOG carries the same history more legibly.
|
|
9
|
+
3. ~ http.rb.gemspec: /http:\/\/github.com\/thoran\/HTTP/https:\/\/github.com\/thoran\/http/. Lowercase matches the actual repo; https since GitHub no longer serves plain http.
|
|
10
|
+
4. ~ HTTP::VERSION: /0.25.0/0.26.0/
|
|
11
|
+
5. ~ CHANGELOG: + 0.26.0 entry
|
|
12
|
+
|
|
13
|
+
## 20260522
|
|
14
|
+
|
|
15
|
+
0.25.0: Remove unused internal machinery; require Ruby >= 3.2.
|
|
16
|
+
|
|
17
|
+
1. ~ HTTP/verbs.rb: /"Net::HTTP::#{verb.to_s.capitalize}".to_const/Net::HTTP.const_get(verb.to_s.capitalize)/. The recursive String#to_const was overkill for a single-level lookup inside Net::HTTP; const_get does it directly.
|
|
18
|
+
2. - lib/String/to_const.rb
|
|
19
|
+
3. - lib/Thoran/String/ToConst/to_const.rb
|
|
20
|
+
4. - lib/Thoran/Array/AllButFirst/all_but_first.rb (was only used by to_const)
|
|
21
|
+
5. - lib/Thoran/Array/FirstX/firstX.rb (was only used by all_but_first)
|
|
22
|
+
6. ~ lib/HTTP.rb: Remove $LOAD_PATH.unshift; rubygems puts lib/ on the load path for installed gems and bundler does the same for local development.
|
|
23
|
+
7. ~ http.rb.gemspec: /required_ruby_version = '>= 2.7'/required_ruby_version = '>= 3.2'/. Aligns with the minitest 6.0 floor used in development; the runtime would still load on 2.7, but claiming compatibility with a Ruby the test suite can't be run against is a fiction worth ending before 1.0.
|
|
24
|
+
8. ~ HTTP::VERSION: /0.24.0/0.25.0/
|
|
25
|
+
9. ~ CHANGELOG: + 0.25.0 entry
|
|
26
|
+
|
|
27
|
+
## 20260522
|
|
28
|
+
|
|
5
29
|
0.24.0: ok? predicate now means 200 specifically.
|
|
6
30
|
|
|
7
31
|
1. ~ Net::HTTPResponse::StatusPredicates: ok? is now defined as @code == '200' rather than aliased to successful?. The alias semantics (any 2xx) misled — "OK" is the reason-phrase for 200 specifically, not the 2xx class. Migration: callers wanting any-2xx should use successful? (or its alias success?).
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@ For many years this was a personal library, from around the middle of 2009 from
|
|
|
4
4
|
|
|
5
5
|
Like many others before and after me with their respective libraries, I created it to simplify the heinous interface that is Net::HTTP. At the time of it's original creation I was doing a lot of a webscraping and didn't want a half-dozen line setup to make simple requests. It has stood the test of time, for me personally insofar as the interface remaining simpler than most other similar libraries, though it is also less full featured, but nevertheless for it's tiny size it packs in quite a bit.
|
|
6
6
|
|
|
7
|
-
Perhaps some will appreciate its relative simplicity, since it is much smaller and the usage simpler than any of the other 'wrapper' libraries, such that it can be read and comprehended in full in as little as a couple of minutes.
|
|
7
|
+
Perhaps some will appreciate its relative simplicity, since it is much smaller and the usage simpler than any of the other 'wrapper' libraries, such that it can be read and comprehended in full in as little as a couple of minutes. All the standard verbs — `get`, `head`, `options`, `trace`, `post`, `put`, `patch`, `delete` — are supported through a single uniform interface.
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
## Installation
|
data/http.rb.gemspec
CHANGED
|
@@ -17,10 +17,10 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
|
|
18
18
|
spec.author = 'thoran'
|
|
19
19
|
spec.email = 'code@thoran.com'
|
|
20
|
-
spec.homepage = "
|
|
20
|
+
spec.homepage = "https://github.com/thoran/http"
|
|
21
21
|
spec.license = 'MIT'
|
|
22
22
|
|
|
23
|
-
spec.required_ruby_version = '>= 2
|
|
23
|
+
spec.required_ruby_version = '>= 3.2'
|
|
24
24
|
spec.require_paths = ['lib']
|
|
25
25
|
|
|
26
26
|
spec.files = [
|
data/lib/HTTP/VERSION.rb
CHANGED
data/lib/HTTP/verbs.rb
CHANGED
|
@@ -6,7 +6,6 @@ require 'net/http'
|
|
|
6
6
|
|
|
7
7
|
require_relative '../Hash/x_www_form_urlencode'
|
|
8
8
|
require_relative './request'
|
|
9
|
-
require_relative '../String/to_const'
|
|
10
9
|
|
|
11
10
|
module HTTP
|
|
12
11
|
module VERBS
|
|
@@ -21,7 +20,7 @@ module HTTP
|
|
|
21
20
|
unless args.empty?
|
|
22
21
|
request_uri += '?' + args.x_www_form_urlencode
|
|
23
22
|
end
|
|
24
|
-
request_object =
|
|
23
|
+
request_object = Net::HTTP.const_get(verb.to_s.capitalize).new(request_uri)
|
|
25
24
|
request(uri, request_object, headers, options, &block)
|
|
26
25
|
end
|
|
27
26
|
|
|
@@ -31,7 +30,7 @@ module HTTP
|
|
|
31
30
|
VERBS::WITH_BODY.each do |verb|
|
|
32
31
|
define_method(verb) do |uri, data = {}, headers = {}, options = {}, &block|
|
|
33
32
|
uri = uri.is_a?(URI) ? uri : URI.parse(uri)
|
|
34
|
-
request_object =
|
|
33
|
+
request_object = Net::HTTP.const_get(verb.to_s.capitalize).new(uri.request_uri)
|
|
35
34
|
content_type = headers.find{|k, v| k.downcase == 'content-type'}&.last.to_s
|
|
36
35
|
if data.is_a?(String)
|
|
37
36
|
request_object.body = data
|
data/lib/HTTP.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: http.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.26.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thoran
|
|
@@ -102,11 +102,7 @@ files:
|
|
|
102
102
|
- lib/Net/HTTP/set_options.rb
|
|
103
103
|
- lib/Net/HTTPRequest/set_headers.rb
|
|
104
104
|
- lib/Net/HTTPResponse/StatusPredicates.rb
|
|
105
|
-
- lib/String/to_const.rb
|
|
106
105
|
- lib/String/url_encode.rb
|
|
107
|
-
- lib/Thoran/Array/AllButFirst/all_but_first.rb
|
|
108
|
-
- lib/Thoran/Array/FirstX/firstX.rb
|
|
109
|
-
- lib/Thoran/String/ToConst/to_const.rb
|
|
110
106
|
- lib/URI/Generic/use_sslQ.rb
|
|
111
107
|
- test/HTTP/RETRY_test.rb
|
|
112
108
|
- test/HTTP/delete_test.rb
|
|
@@ -119,7 +115,7 @@ files:
|
|
|
119
115
|
- test/HTTP/trace_test.rb
|
|
120
116
|
- test/Net/HTTPResponse/StatusPredicates_test.rb
|
|
121
117
|
- test/helper.rb
|
|
122
|
-
homepage:
|
|
118
|
+
homepage: https://github.com/thoran/http
|
|
123
119
|
licenses:
|
|
124
120
|
- MIT
|
|
125
121
|
metadata: {}
|
|
@@ -130,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
130
126
|
requirements:
|
|
131
127
|
- - ">="
|
|
132
128
|
- !ruby/object:Gem::Version
|
|
133
|
-
version: '2
|
|
129
|
+
version: '3.2'
|
|
134
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
131
|
requirements:
|
|
136
132
|
- - ">="
|
data/lib/String/to_const.rb
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# Thoran/Array/AllButFirst/all_but_first.rb
|
|
2
|
-
# Thoran::Array::AllButFirst#all_but_first
|
|
3
|
-
|
|
4
|
-
# 20141223
|
|
5
|
-
# 0.1.0
|
|
6
|
-
|
|
7
|
-
# Description: This returns a copy of the receiving array with the first element removed.
|
|
8
|
-
|
|
9
|
-
# Changes:
|
|
10
|
-
# 1. + Thoran namespace.
|
|
11
|
-
|
|
12
|
-
require 'Thoran/Array/FirstX/firstX'
|
|
13
|
-
|
|
14
|
-
module Thoran
|
|
15
|
-
module Array
|
|
16
|
-
module AllButFirst
|
|
17
|
-
|
|
18
|
-
def all_but_first
|
|
19
|
-
d = self.dup
|
|
20
|
-
d.first!
|
|
21
|
-
d
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
Array.send(:include, Thoran::Array::AllButFirst)
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# Thoran/Array/FirstX/firstX.rb
|
|
2
|
-
# Thoran::Array::FirstX#first!
|
|
3
|
-
|
|
4
|
-
# 20180804
|
|
5
|
-
# 0.3.3
|
|
6
|
-
|
|
7
|
-
# Description: Sometimes it makes more sense to treat arrays this way.
|
|
8
|
-
|
|
9
|
-
# Changes since 0.2:
|
|
10
|
-
# 1. Added the original version 0.1.0 of the implementation to the later 0.1.0!
|
|
11
|
-
# 0/1
|
|
12
|
-
# 2. Switched the tests to spec-style.
|
|
13
|
-
# 1/2
|
|
14
|
-
# 3. Added a test for the state of the array afterward, since this is meant to be an in place change.
|
|
15
|
-
# 2/3
|
|
16
|
-
# 4. Added tests for the extended functionality introduced in the first version 0.1.0.
|
|
17
|
-
|
|
18
|
-
module Thoran
|
|
19
|
-
module Array
|
|
20
|
-
module FirstX
|
|
21
|
-
|
|
22
|
-
def first!(n = 1)
|
|
23
|
-
return_value = []
|
|
24
|
-
n.times{return_value << self.shift}
|
|
25
|
-
return_value.size == 1 ? return_value[0] : return_value
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
Array.send(:include, Thoran::Array::FirstX)
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# Thoran/String/ToConst/to_const.rb
|
|
2
|
-
# Thoran::String::ToConst#to_const
|
|
3
|
-
|
|
4
|
-
# 20141223
|
|
5
|
-
# 0.2.0
|
|
6
|
-
|
|
7
|
-
# Description: This takes a string and returns a constant, with unlimited namespacing.
|
|
8
|
-
|
|
9
|
-
# History: Derived from Object#to_const 0.3.0, and superceding Object#to_const.
|
|
10
|
-
|
|
11
|
-
# Changes:
|
|
12
|
-
# 1. + Thoran namespace.
|
|
13
|
-
|
|
14
|
-
# Todo:
|
|
15
|
-
# 1. This only works for two levels of constants. Three and you're stuffed. So, this needs to be recursive...
|
|
16
|
-
# Done iteratively as of 0.1.0.
|
|
17
|
-
# 2. Make this work for symbols. However, this will only work if there's no namespacing. ie. :A is OK, but :A::B is not.
|
|
18
|
-
|
|
19
|
-
# Discussion:
|
|
20
|
-
# 1. Should this go separately into classes for which ::const_get will work and be removed from Object? Done as of 0.1.0.
|
|
21
|
-
|
|
22
|
-
require 'Thoran/Array/AllButFirst/all_but_first'
|
|
23
|
-
|
|
24
|
-
module Thoran
|
|
25
|
-
module String
|
|
26
|
-
module ToConst
|
|
27
|
-
|
|
28
|
-
def to_const
|
|
29
|
-
if self =~ /::/
|
|
30
|
-
constants = self.split('::')
|
|
31
|
-
constant = Object.const_get(constants.first)
|
|
32
|
-
constants = constants.all_but_first
|
|
33
|
-
until constants.empty? do
|
|
34
|
-
constant = constant.const_get(constants.shift)
|
|
35
|
-
end
|
|
36
|
-
else
|
|
37
|
-
constant = Object.const_get(self)
|
|
38
|
-
end
|
|
39
|
-
constant
|
|
40
|
-
end
|
|
41
|
-
alias_method :to_constant, :to_const
|
|
42
|
-
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
String.send(:include, Thoran::String::ToConst)
|