http_api_builder 0.2.3 → 0.2.4

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
  SHA1:
3
- metadata.gz: 16f4c4049c99b8b57a337a7bca40772764900cb4
4
- data.tar.gz: 8374854880f0ad10a5ae4d771acd67f2aa296056
3
+ metadata.gz: d2ba7568dff46da3c44bd15a0a70375dded04c0d
4
+ data.tar.gz: 1f646668d14583ccb301540415fd0bd59b5584d4
5
5
  SHA512:
6
- metadata.gz: b3e8c5eb8d044ae54ae7560df211dad9047508232dad4a5ff0f77467f4ea2822f5220cd7c4f632c63aa26883391b36adb25b2dc11c203cb6cc822712338e39c4
7
- data.tar.gz: 355de4a286c278978c3e908818e75b9a74fe3f864264bc2b2eae8a4bceb045cdf4db1315cc4ab2f80778cd5b91781741ef5481d8e1744d68dc973923e22ff8b8
6
+ metadata.gz: acbba0f9e4d9b5db6ba13e7f3cc423343d842981d87e8a2431b9c9eee0d2c401c1d5eeee8c2b116b54fdc9379ede2eb8c64e5e4072aa6a6f899c5ac29a070ec8
7
+ data.tar.gz: 69f383447ccc9e97fe180ab121d2d1ffabc5833b3d21912c4046029d380228ab7511724b8df7204e05a721c4467bed67ca0f4ad8b383bf24508efe5cf083beb3
@@ -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 = ">= 2.2"
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'
@@ -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(resource, status, response) : resource
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 [Addressable::URI] uri The url to make the request to
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
@@ -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 = Addressable::URI.parse(self.class.base_url)
77
+ parsed_base = URI.parse(self.class.base_url)
78
78
  parsed_basepath = parsed_base.path.split('/').reject(&:empty?)
79
79
 
80
- addressable_path = Addressable::URI.parse(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
@@ -1,3 +1,3 @@
1
1
  module HttpApiBuilder
2
- VERSION = '0.2.3'.freeze
2
+ VERSION = '0.2.4'.freeze
3
3
  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.3
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-08 00:00:00.000000000 Z
11
+ date: 2016-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler