http_api_builder 0.2.3 → 0.2.4
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/http_api_builder.gemspec +1 -1
- data/lib/http_api_builder.rb +2 -2
- data/lib/http_api_builder/dsl.rb +2 -2
- data/lib/http_api_builder/helpers.rb +3 -3
- data/lib/http_api_builder/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: d2ba7568dff46da3c44bd15a0a70375dded04c0d
|
4
|
+
data.tar.gz: 1f646668d14583ccb301540415fd0bd59b5584d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acbba0f9e4d9b5db6ba13e7f3cc423343d842981d87e8a2431b9c9eee0d2c401c1d5eeee8c2b116b54fdc9379ede2eb8c64e5e4072aa6a6f899c5ac29a070ec8
|
7
|
+
data.tar.gz: 69f383447ccc9e97fe180ab121d2d1ffabc5833b3d21912c4046029d380228ab7511724b8df7204e05a721c4467bed67ca0f4ad8b383bf24508efe5cf083beb3
|
data/http_api_builder.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.required_ruby_version =
|
22
|
+
spec.required_ruby_version = '>= 2.2'
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.11'
|
25
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
data/lib/http_api_builder.rb
CHANGED
@@ -16,14 +16,14 @@ module HttpApiBuilder
|
|
16
16
|
response = request(method, url, form: form, query: query, body: body, json: json)
|
17
17
|
status = response.status
|
18
18
|
resource = response.body
|
19
|
-
block_given? ? yield(
|
19
|
+
block_given? ? yield(response, status, resource) : response
|
20
20
|
end
|
21
21
|
|
22
22
|
# Placeholder for your request method.
|
23
23
|
# Accepts these params, for you to do whatever you like with. See the HTTPrb_client implementation
|
24
24
|
#
|
25
25
|
# @param [Symbol] method The HTTP VERB to use
|
26
|
-
# @param [
|
26
|
+
# @param [URI] uri The url to make the request to
|
27
27
|
# @param [Hash] form: nil Form data, for encoding into HTTP form encoding
|
28
28
|
# @param [Hash] query: nil Query key/value pairs
|
29
29
|
# @param [String] body: nil A raw body
|
data/lib/http_api_builder/dsl.rb
CHANGED
@@ -47,14 +47,14 @@ module HttpApiBuilder
|
|
47
47
|
required, optional = requirements(path, params)
|
48
48
|
|
49
49
|
define_method :"#{name}!" do |opts = {}|
|
50
|
+
json = opts.delete(:json) || json
|
51
|
+
body = opts.delete(:body) || body
|
50
52
|
validate_args! opts.keys, required, optional
|
51
53
|
|
52
54
|
reqpath = interpolate_path(path, opts)
|
53
55
|
query = query_params(path, opts, required, optional)
|
54
56
|
|
55
57
|
form = Hash(form).merge(Hash(opts[:form]))
|
56
|
-
json = opts[:json] || json
|
57
|
-
body = opts[:body] || body
|
58
58
|
perform(using, reqpath, form: form, query: query, body: body, json: json) do |resource, *_|
|
59
59
|
run_processors resource, processors
|
60
60
|
end
|
@@ -74,17 +74,17 @@ module HttpApiBuilder
|
|
74
74
|
|
75
75
|
# Handle's building paths
|
76
76
|
def build_url(path)
|
77
|
-
parsed_base =
|
77
|
+
parsed_base = URI.parse(self.class.base_url)
|
78
78
|
parsed_basepath = parsed_base.path.split('/').reject(&:empty?)
|
79
79
|
|
80
|
-
addressable_path =
|
80
|
+
addressable_path = URI.parse(path)
|
81
81
|
|
82
82
|
return addressable_path unless addressable_path.relative?
|
83
83
|
parsed_path = addressable_path.path.split('/').reject(&:empty?)
|
84
84
|
|
85
85
|
parsed_basepath += parsed_path
|
86
86
|
|
87
|
-
parsed_base.path = parsed_basepath.join('/')
|
87
|
+
parsed_base.path = '/' + parsed_basepath.join('/')
|
88
88
|
|
89
89
|
parsed_base
|
90
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_api_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Sandberg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|