endpointer 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/endpointer/argument_parser.rb +1 -1
- data/lib/endpointer/cacher.rb +1 -1
- data/lib/endpointer/performers/get.rb +1 -2
- data/lib/endpointer/performers/method.rb +9 -10
- data/lib/endpointer/performers/post.rb +1 -2
- data/lib/endpointer/resource_executor.rb +1 -1
- data/lib/endpointer/response_presenter.rb +2 -2
- data/lib/endpointer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e705dec6f55d6ae9e87f60e415451ec35f1826d7
|
4
|
+
data.tar.gz: f99559081ebf4ff13bc782e5c4d3dbe13a0f7fc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 231c82787a365665c0c322f0c4dd6c70a03c3a461db9771d98de63c37fa4b6c6f67ce6a90b10d580a59f88d19e8df4370b0a3c02336b27f54680f7c4ab85dffd
|
7
|
+
data.tar.gz: 2292181e7d9aaf294428cca8189d7ce6fae38a14ca37424b13d0a9842c929524530038d49c2dd230d92cb089cb9c58bd5cd035b2290210ae92cc95037a1d9b25
|
data/lib/endpointer/cacher.rb
CHANGED
@@ -43,7 +43,7 @@ module Endpointer
|
|
43
43
|
def initialize_path(path)
|
44
44
|
begin
|
45
45
|
@path = path
|
46
|
-
Dir.mkdir(@path) unless File.
|
46
|
+
Dir.mkdir(@path) unless File.exist?(@path)
|
47
47
|
rescue Errno::ENOENT => e
|
48
48
|
raise Endpointer::Errors::InvalidCacheDirError.new(e.message)
|
49
49
|
end
|
@@ -15,8 +15,7 @@ module Endpointer
|
|
15
15
|
|
16
16
|
def execute_method(method, request, resource)
|
17
17
|
begin
|
18
|
-
|
19
|
-
response = RestClient::Request.execute(method: method, url: url, headers: create_headers(request, resource))
|
18
|
+
response = RestClient::Request.execute(method: method, url: construct_uri(request, resource), headers: create_headers(request, resource))
|
20
19
|
rescue RestClient::ExceptionWithResponse => e
|
21
20
|
response = e.response
|
22
21
|
end
|
@@ -18,17 +18,16 @@ module Endpointer
|
|
18
18
|
"HTTP_#{header_name.upcase.tr('-', '_')}"
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
def construct_uri(request, resource)
|
22
|
+
parsed_request_url = URI.parse(request.url)
|
23
|
+
parsed_resource_url = URI.parse(resource.url)
|
24
|
+
|
25
|
+
parsed_request_url.scheme = parsed_resource_url.scheme
|
26
|
+
parsed_request_url.userinfo = parsed_resource_url.userinfo
|
27
|
+
parsed_request_url.host = parsed_resource_url.host
|
28
|
+
parsed_request_url.port = parsed_resource_url.port
|
26
29
|
|
27
|
-
|
28
|
-
path = request.path
|
29
|
-
query_string = request.env['QUERY_STRING']
|
30
|
-
path << "?#{query_string}" unless query_string.nil?
|
31
|
-
path
|
30
|
+
parsed_request_url.to_s
|
32
31
|
end
|
33
32
|
end
|
34
33
|
end
|
@@ -15,9 +15,8 @@ module Endpointer
|
|
15
15
|
|
16
16
|
def execute_method(method, request, resource)
|
17
17
|
begin
|
18
|
-
url = File.join(create_hostname(resource), create_path(request))
|
19
18
|
response = RestClient.send(method,
|
20
|
-
|
19
|
+
construct_uri(request, resource),
|
21
20
|
request.body.read,
|
22
21
|
create_headers(request, resource)
|
23
22
|
)
|
@@ -7,7 +7,7 @@ module Endpointer
|
|
7
7
|
def perform(request, resource, options)
|
8
8
|
begin
|
9
9
|
cache(options.cache_dir).get(resource)
|
10
|
-
rescue Endpointer::Errors::CachedItemNotFoundError
|
10
|
+
rescue Endpointer::Errors::CachedItemNotFoundError
|
11
11
|
response = Endpointer::PerformerFactory.create(resource.method).execute(request, resource)
|
12
12
|
cache(options.cache_dir).set(resource, response)
|
13
13
|
response
|
@@ -13,13 +13,13 @@ module Endpointer
|
|
13
13
|
|
14
14
|
def uglify_headers(headers)
|
15
15
|
headers.inject({}) { |out, (key, value)|
|
16
|
-
out[key.to_s.upcase.
|
16
|
+
out[key.to_s.upcase.tr('_', '-')] = value
|
17
17
|
out
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
21
21
|
def sanitise_headers(headers)
|
22
|
-
headers.reject {|header,
|
22
|
+
headers.reject {|header, _|
|
23
23
|
header.match(/TRANSFER-ENCODING/)
|
24
24
|
}
|
25
25
|
end
|
data/lib/endpointer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: endpointer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zen Kyprianou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|