sentofu 0.3.0 → 0.4.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.md +5 -0
- data/README.md +23 -0
- data/lib/sentofu/http.rb +25 -3
- data/lib/sentofu.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cf89a26a83c77e1de102c5281a142ef68883f7f5a3b6074deddc4b4699c4b75
|
4
|
+
data.tar.gz: b3e1cf4e374db9a2e4ad7e909151b1914c5dcb9503f25000b5bb66e08766114e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7871ee50c8e327317c41d604217e2e8fbecb62930adba09d7b53e3ad9268cfd9deb07cbaccb8f33ee62e080d000cb6d72ea6251213d40ab6e5baf224d10af819
|
7
|
+
data.tar.gz: afa1bf96c6fca1142c4d1e60e4e5af1256d891e8c3c8abe0a5ae06d1c07eb2a796d95aa2c59d266343c7dab6e97b83e345663214f21579f22d068d48a9d83752
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,29 @@
|
|
3
3
|
|
4
4
|
A Ruby client to some of the 1.0.0 Sentifi.com APIs.
|
5
5
|
|
6
|
+
## proxy
|
7
|
+
|
8
|
+
Sentofu follows the vanilla `ENV['http_proxy']` Ruby proxy setting.
|
9
|
+
|
10
|
+
It also accepts a dedicated `ENV['sentofu_http_proxy']` environment variable.
|
11
|
+
|
12
|
+
In Ruby:
|
13
|
+
```ruby
|
14
|
+
ENV['sentofu_http_proxy'] = 'http://proxy.example.com'
|
15
|
+
# or
|
16
|
+
ENV['sentofu_http_proxy'] = 'http://proxy.example.com:8080'
|
17
|
+
# or
|
18
|
+
ENV['sentofu_http_proxy'] = 'http://user:pass@proxy.example.com'
|
19
|
+
# or
|
20
|
+
ENV['sentofu_http_proxy'] = 'http://user:pass@proxy.example.com:8080'
|
21
|
+
```
|
22
|
+
|
23
|
+
From the command line:
|
24
|
+
```
|
25
|
+
$ http_proxy = 'http://user:pass@proxy.example.com'
|
26
|
+
$ sentofu_http_proxy = 'http://user:pass@proxy.example.com'
|
27
|
+
```
|
28
|
+
|
6
29
|
## license
|
7
30
|
|
8
31
|
MIT, see [LICENSE.txt](LICENSE.txt)
|
data/lib/sentofu/http.rb
CHANGED
@@ -26,17 +26,39 @@ module Sentofu
|
|
26
26
|
request(uri, make_get_req(uri, token))
|
27
27
|
end
|
28
28
|
|
29
|
+
PROXY_REX = /\A(([^:@]+)(:([^@]+))?@)?([^:]+)(:(\d+))?\z/
|
30
|
+
|
31
|
+
def make_net_http(uri)
|
32
|
+
|
33
|
+
http =
|
34
|
+
if pm = PROXY_REX.match(ENV['sentofu_http_proxy'] || '')
|
35
|
+
Net::HTTP.new(
|
36
|
+
uri.host, uri.port,
|
37
|
+
pm[5], pm[7] ? pm[7].to_i : nil, # proxy host and port
|
38
|
+
pm[2], pm[4]) # proxy user and pass
|
39
|
+
else
|
40
|
+
Net::HTTP.new(
|
41
|
+
uri.host, uri.port)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Nota Bene:
|
45
|
+
# even if ENV['sentofu_http_proxy'], ENV['http_proxy'] could kick in
|
46
|
+
|
47
|
+
http.use_ssl = (uri.scheme == 'https')
|
48
|
+
|
49
|
+
http
|
50
|
+
end
|
51
|
+
|
29
52
|
def request(uri, req)
|
30
53
|
|
31
54
|
u = uri.is_a?(String) ? URI(uri) : uri
|
32
55
|
|
33
56
|
t0 = monow
|
34
57
|
|
35
|
-
|
36
|
-
t.use_ssl = (u.scheme == 'https')
|
58
|
+
http = make_net_http(u)
|
37
59
|
#t.set_debug_output($stdout) if u.to_s.match(/search/)
|
38
60
|
|
39
|
-
res =
|
61
|
+
res = http.request(req)
|
40
62
|
|
41
63
|
class << res; attr_accessor :_elapsed; end
|
42
64
|
res._elapsed = monow - t0
|
data/lib/sentofu.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentofu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mettraux
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|