grac 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/grac/client.rb +23 -8
- data/lib/grac/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b7388a3893226c18a95cf03b7f9c11dada6f6bc
|
4
|
+
data.tar.gz: 617dd5a6f749929bbe26277bfd0ae9b26fe91091
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf132d0ea4f5d427c36b79c5a3fa124bad63990eef29e8974252b09658cc78e6e3c0df9e95ed914cb9416a144569a942bccdf7a57c25f2076e19c055324640f0
|
7
|
+
data.tar.gz: b1dc8341930b7352ff18484f0591c038fc8d4269915195b69b340cbb50bf8a802448f83e9a0c43a18d63e1b30bca32be489d517952d195677ee18c74c81be13c
|
data/lib/grac/client.rb
CHANGED
@@ -18,13 +18,20 @@ module Grac
|
|
18
18
|
:timeout => options[:timeout] || 15,
|
19
19
|
:params => options[:params] || {},
|
20
20
|
:headers => { "User-Agent" => "Grac v#{Grac::VERSION}" }.merge(options[:headers] || {}),
|
21
|
-
:postprocessing => options[:postprocessing] || {}
|
21
|
+
:postprocessing => options[:postprocessing] || {},
|
22
|
+
:middleware => options[:middleware] || []
|
22
23
|
}
|
24
|
+
@options.freeze
|
25
|
+
[:params, :headers, :postprocessing, :middleware].each do |k|
|
26
|
+
@options[k].freeze
|
27
|
+
end
|
28
|
+
@uri.freeze
|
23
29
|
end
|
24
30
|
|
25
31
|
def set(options = {})
|
26
32
|
options = options.merge({
|
27
|
-
headers:
|
33
|
+
headers: @options[:headers].merge(options[:headers] || {}),
|
34
|
+
middleware: @options[:middleware] + (options[:middleware] || [])
|
28
35
|
})
|
29
36
|
|
30
37
|
self.class.new(@uri, @options.merge(options))
|
@@ -53,16 +60,24 @@ module Grac
|
|
53
60
|
|
54
61
|
private
|
55
62
|
def build_request(method, options = {})
|
56
|
-
body
|
63
|
+
body = options[:body].nil? || options[:body].empty? ? nil : options[:body].to_json
|
64
|
+
params = @options[:params].merge(options[:params] || {})
|
65
|
+
|
66
|
+
opts = @options
|
67
|
+
request_uri = uri
|
68
|
+
|
69
|
+
@options[:middleware].each do |mw|
|
70
|
+
opts, request_uri, method, params, body = mw.call(opts, request_uri, method, params, body)
|
71
|
+
end
|
57
72
|
|
58
73
|
request_hash = { :method => method }
|
59
|
-
request_hash[:params] =
|
74
|
+
request_hash[:params] = params
|
60
75
|
request_hash[:body] = body
|
61
|
-
request_hash[:connecttimeout] =
|
62
|
-
request_hash[:timeout] =
|
63
|
-
request_hash[:headers] =
|
76
|
+
request_hash[:connecttimeout] = opts[:connecttimeout]
|
77
|
+
request_hash[:timeout] = opts[:timeout]
|
78
|
+
request_hash[:headers] = opts[:headers]
|
64
79
|
|
65
|
-
return ::Typhoeus::Request.new(
|
80
|
+
return ::Typhoeus::Request.new(request_uri, request_hash)
|
66
81
|
end
|
67
82
|
|
68
83
|
def postprocessing(data, processing = nil)
|
data/lib/grac/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Schoknecht
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
128
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
129
|
+
rubygems_version: 2.4.6
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
132
|
summary: Very generic client for REST API with basic error handling
|