netdnarws 0.3.0 → 0.3.1
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.
- data/lib/netdnarws.rb +16 -16
- data/lib/netdnarws/version.rb +1 -1
- metadata +1 -1
data/lib/netdnarws.rb
CHANGED
@@ -3,6 +3,20 @@ require 'curb-fu'
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
module NetDNARWS
|
6
|
+
module Utils
|
7
|
+
RESERVED_CHARACTERS = /[^a-zA-Z0-9\-\.\_\~]/
|
8
|
+
|
9
|
+
def escape(value)
|
10
|
+
URI::escape(value.to_s, NetDNARWS::Utils::RESERVED_CHARACTERS)
|
11
|
+
rescue ArgumentError
|
12
|
+
URI::escape(value.to_s.force_encoding(Encoding::UTF_8), NetDNARWS::Utils::RESERVED_CHARACTERS)
|
13
|
+
end
|
14
|
+
|
15
|
+
def encode_params params={}
|
16
|
+
Hash[params.map { |k, v| [escape(k), escape(v)] }]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
6
20
|
class NetDNA
|
7
21
|
include NetDNARWS::Utils
|
8
22
|
|
@@ -32,7 +46,7 @@ module NetDNARWS
|
|
32
46
|
|
33
47
|
def _get_url uri, params={}
|
34
48
|
url = "#{_connection_type}://#{@server}/#{@company_alias}#{uri}"
|
35
|
-
if not
|
49
|
+
if not params.empty?
|
36
50
|
url += "?#{_encode_params(params)}"
|
37
51
|
end
|
38
52
|
|
@@ -55,7 +69,7 @@ module NetDNARWS
|
|
55
69
|
|
56
70
|
begin
|
57
71
|
curb_options = {}
|
58
|
-
curb_options[:url] =
|
72
|
+
curb_options[:url] = request_options[:uri]
|
59
73
|
curb_options[:headers] = request.headers
|
60
74
|
|
61
75
|
if not options[:body]
|
@@ -130,18 +144,4 @@ module NetDNARWS
|
|
130
144
|
self.delete("/zones/pull.json/#{zone_id}/cache", {}, options)
|
131
145
|
end
|
132
146
|
end
|
133
|
-
|
134
|
-
module Utils
|
135
|
-
RESERVED_CHARACTERS = /[^a-zA-Z0-9\-\.\_\~]/
|
136
|
-
|
137
|
-
def escape(value)
|
138
|
-
URI::escape(value.to_s, NetDNARWS::Utils::RESERVED_CHARACTERS)
|
139
|
-
rescue ArgumentError
|
140
|
-
URI::escape(value.to_s.force_encoding(Encoding::UTF_8), NetDNARWS::Utils::RESERVED_CHARACTERS)
|
141
|
-
end
|
142
|
-
|
143
|
-
def encode_params params={}
|
144
|
-
Hash[params.map { |k, v| [NetDNARWS::Utils::escape(k), NetDNARWS::Utils::escape(v)] }]
|
145
|
-
end
|
146
|
-
end
|
147
147
|
end
|
data/lib/netdnarws/version.rb
CHANGED