netdnarws 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/netdnarws.rb +16 -16
  2. data/lib/netdnarws/version.rb +1 -1
  3. 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 attributes.empty?
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] = _get_url(uri, attributes)
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
@@ -1,3 +1,3 @@
1
1
  module NetDNARWS
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netdnarws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: