saddle 0.0.22 → 0.0.23
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 +8 -8
- data/lib/saddle/requester.rb +13 -8
- data/lib/saddle/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWZjMDk3MDczMTlkYjllMDk3MmQ2NDRlNWY1ODE3Yjk5NTFiNmQ0Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODlkYTE3OGJhNjU3Mjc3ODUwYmVjODEyNWRhMzNlMTA0MzczOGEzZQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTY1MTFiZmIxYTIyOWZhNWZhZGY5ZTA5NTE5ZDdjMWExOGNmNGU0M2Q5ODUx
|
10
|
+
NjFjYzM0MjFhOGVjNjkxZTYyYTkyMzc0MTY2YTEzYzBiMDVlYTAyMTBlMmEz
|
11
|
+
OTdlNjc0OWFmNGU4OWVhMTY5MTg0ODUzODBiM2JlNTY5M2U2MzI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2QyNTVjMjllZGY3MTlmYjI5NmQ2ZDYzODhmM2ZkYmFjYmNkN2RjYjljNjc3
|
14
|
+
MjdmYjc5ZDE1N2MyM2Q2ZDRkMDVhMzhiM2RmNjhkOWZiM2U5ODRlMGQ1MTM2
|
15
|
+
NDkyYzFlZTE1M2IyYjZlZTRhY2M1NGUxYWUwMGQ1ODk5OGZhZmE=
|
data/lib/saddle/requester.rb
CHANGED
@@ -30,6 +30,8 @@ module Saddle
|
|
30
30
|
## - each middleware consists of hash of klass, and optionally args (an array)
|
31
31
|
## stubs - test stubs for specs
|
32
32
|
def initialize(opt={})
|
33
|
+
# Store the options for later use
|
34
|
+
@options = opt
|
33
35
|
@host = opt[:host] || 'localhost'
|
34
36
|
raise ':host must be a string' unless @host.is_a?(String)
|
35
37
|
@port = opt[:port] || 80
|
@@ -58,8 +60,8 @@ module Saddle
|
|
58
60
|
# Make a GET request
|
59
61
|
def get(url, params={}, options={})
|
60
62
|
response = connection.get do |req|
|
61
|
-
req.options.merge!
|
62
|
-
req.url
|
63
|
+
req.options.merge!(options)
|
64
|
+
req.url(url, params)
|
63
65
|
end
|
64
66
|
response.body
|
65
67
|
end
|
@@ -67,8 +69,8 @@ module Saddle
|
|
67
69
|
# Make a POST request
|
68
70
|
def post(url, data={}, options={})
|
69
71
|
response = connection.post do |req|
|
70
|
-
req.options.merge!
|
71
|
-
req.url
|
72
|
+
req.options.merge!(options)
|
73
|
+
req.url(url)
|
72
74
|
req.body = data
|
73
75
|
end
|
74
76
|
response.body
|
@@ -77,8 +79,8 @@ module Saddle
|
|
77
79
|
# Make a PUT request
|
78
80
|
def put(url, data={}, options={})
|
79
81
|
response = connection.put do |req|
|
80
|
-
req.options.merge!
|
81
|
-
req.url
|
82
|
+
req.options.merge!(options)
|
83
|
+
req.url(url)
|
82
84
|
req.body = data
|
83
85
|
end
|
84
86
|
response.body
|
@@ -87,8 +89,8 @@ module Saddle
|
|
87
89
|
# Make a DELETE request
|
88
90
|
def delete(url, params={}, options={})
|
89
91
|
response = connection.delete do |req|
|
90
|
-
req.options.merge!
|
91
|
-
req.url
|
92
|
+
req.options.merge!(options)
|
93
|
+
req.url(url, params)
|
92
94
|
end
|
93
95
|
response.body
|
94
96
|
end
|
@@ -105,6 +107,9 @@ module Saddle
|
|
105
107
|
# Build a connection instance, wrapped in the middleware that we want
|
106
108
|
def connection
|
107
109
|
@connection ||= Faraday.new(base_url) do |builder|
|
110
|
+
# Include the requester level options
|
111
|
+
builder.options[:client_options] = @options
|
112
|
+
|
108
113
|
# Config options
|
109
114
|
unless @timeout.nil?
|
110
115
|
builder.options[:timeout] = @timeout
|
data/lib/saddle/version.rb
CHANGED