bwapi 10.0.0.pre.467 → 10.0.0.pre.470
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/bwapi/request.rb +40 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjlhYmZiMTNjMjdlN2QwNzA2YmM3MWZjNjg1MmYwZDZmZjg0NWQ0NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDYyNjNlMjM4M2YzNzMxMzMyNWVkYzMyODc4NjlkYTUzMmI3YjNiNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWI4MGRmMWYwNGRjOTBjOWNjMDg0ODFjN2VkOWYxODcyNWNhOGUxOTZiNzBm
|
10
|
+
OTdjNmZjMjMwOWE1NGI1NWZkYmQxMTQyZjBjYTNiMTYwNjExNWQ5ZjgzMjMz
|
11
|
+
NjAxOGE4NjQ5OTJjYWQyOTc0YTcxN2U3NDE0YTU3NTk4NDI3N2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTkwOTBjNzg3OWM0Yjc0OTQwMWZhMGVmZTM2M2JhNDg2NzM0ZmJkNTFiYjkz
|
14
|
+
ZGRjMWRlNzk4NGMzOTRhMTYxYTY2MTdiZDJhYjgwOTQ5NTRhZjAzZTA5OGZk
|
15
|
+
NDhkMjY3NDgyMThmOTk0MDlmNzNkMWZmY2MzMzEwMTYwYjhhYmE=
|
data/lib/bwapi/request.rb
CHANGED
@@ -57,21 +57,51 @@ module BWAPI
|
|
57
57
|
# @param opts [Hash] Request parameters
|
58
58
|
# @return [Hash] Response
|
59
59
|
def request(method, path, opts = {})
|
60
|
-
|
60
|
+
connection.send(method) do |req|
|
61
61
|
case method
|
62
62
|
when :get, :delete
|
63
|
-
|
63
|
+
request_url(req, path, opts)
|
64
64
|
when :patch, :post, :put
|
65
|
-
|
66
|
-
opts.delete(:force_urlencoded)
|
67
|
-
r.url path, opts
|
68
|
-
else
|
69
|
-
r.path = path
|
70
|
-
r.body = opts
|
71
|
-
end
|
65
|
+
request_body(req, path, opts)
|
72
66
|
end
|
73
67
|
end
|
74
|
-
|
68
|
+
end
|
69
|
+
|
70
|
+
# Configures url encoded request unless force_body key is passed
|
71
|
+
#
|
72
|
+
# @param req [Object] the request object
|
73
|
+
# @param path [String] URL path to send request
|
74
|
+
# @param opts [Hash] Request parameters
|
75
|
+
def request_url(req, path, opts)
|
76
|
+
if key?(opts, :force_body)
|
77
|
+
req.path, req.body = path, opts
|
78
|
+
else
|
79
|
+
req.url path, opts
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# Configures body request unless force_urlencoded key is passed
|
84
|
+
#
|
85
|
+
# @param req [Object] the request object
|
86
|
+
# @param path [String] URL path to send request
|
87
|
+
# @param opts [Hash] Request parameters
|
88
|
+
def request_body(req, path, opts)
|
89
|
+
if key?(opts, :force_urlencoded)
|
90
|
+
req.url path, opts
|
91
|
+
else
|
92
|
+
req.path, req.body = path, opts
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# Checks if a request options has a given key
|
97
|
+
# Deletes the key if it is present
|
98
|
+
#
|
99
|
+
# @param opts [Hash] Request parameters
|
100
|
+
# @param key [Symbol] The key to check for
|
101
|
+
# @return [Boolean] false or key value
|
102
|
+
def key?(opts, key)
|
103
|
+
return false unless opts.is_a?(Hash) && opts.key?(key)
|
104
|
+
opts.delete(key)
|
75
105
|
end
|
76
106
|
end
|
77
107
|
end
|