resource_accessor 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6169d6db0bcfd5e5cf81ae4c8e6e505fc0750753
4
- data.tar.gz: b34e9360c0a8f64f56d4893069157341ea1444ff
3
+ metadata.gz: 91aa3aad7b244ffeaca70883e86d0fdded16ce78
4
+ data.tar.gz: ae227c4946db340b0c5fac159d2882e9dfc5638e
5
5
  SHA512:
6
- metadata.gz: a33e7e4f12caaeff42aad4933991468617b8ed0d7e883fdab557c8ac3e5920d80934fb12b1b7694c338a8d954324f5e94f1a8de732ea1b6df56502ae9a7f9238
7
- data.tar.gz: dfdb921a481be36821c21e54103d8e116caf6b0ad2093c3db80eada4fb6a105176aa1ecf6095b2de4837e13e2c8378cfbbc9a937715bd74106380625ece17ce7
6
+ metadata.gz: cb81e9f1fc0921239f68f90b6f1e0a19317ab3374a28858f14837719e2d2700821f40a131c547538497f57688d66a1f94b3f7b027fa78f1c361b3cd5fa76d806
7
+ data.tar.gz: f6d405c25b15bccdf0f442111e0158b1919cac1242bc1327563db87998e7fcdd5c92c11a2e414b3d0c035d624acbb2939fc1fce2e59bc81b2dc19f34286ae0c7
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.1
1
+ 2.1.4
data/CHANGES CHANGED
@@ -30,4 +30,8 @@
30
30
 
31
31
  == Version 1.2.3
32
32
 
33
- * Adding escape flag in order to control whether we want to escape parameter or not.
33
+ * Adding escape flag in order to control whether we want to escape parameter or not.
34
+
35
+ == Version 1.2.4
36
+
37
+ * Bug fix
@@ -49,15 +49,9 @@ class ResourceAccessor
49
49
  def self.query_from_hash(params, escape=true)
50
50
  return nil if params.nil? or params.empty?
51
51
 
52
- params.sort.map do |key, value|
53
- new_value = value.nil? ? '' : (escape ? CGI.escape(value) : value)
54
-
55
- "#{key}=#{new_value}"
56
- end.join("&")
52
+ encode params, escape
57
53
  end
58
54
 
59
- private
60
-
61
55
  def locate_response url, query, method, headers, body, escape=true, cookie=nil
62
56
  response = execute_request url, query, method, headers, body, escape, cookie
63
57
 
@@ -123,4 +117,20 @@ class ResourceAccessor
123
117
  end
124
118
  end
125
119
 
120
+ private
121
+
122
+ def self.encode(value, escape=true, key = nil)
123
+ case value
124
+ when Hash then value.map { |k,v| encode(v, escape, append_key(key,k)) }.join('&')
125
+ when Array then value.map { |v| encode(v, escape, "#{key}[]") }.join('&')
126
+ when nil then "#{key}="
127
+ else
128
+ escape ? "#{key}=#{CGI.escape(value.to_s)}" : "#{key}=#{value.to_s}"
129
+ end
130
+ end
131
+
132
+ def self.append_key(root_key, key)
133
+ root_key.nil? ? key : "#{root_key}[#{key.to_s}]"
134
+ end
135
+
126
136
  end
@@ -1,3 +1,3 @@
1
1
  class ResourceAccessor
2
- VERSION = "1.2.3"
2
+ VERSION = "1.2.4"
3
3
  end
@@ -25,7 +25,7 @@ describe ResourceAccessor do
25
25
  subject.class.query_from_hash({:name1 => "name 1", :name2 => "name 2"}).should eql "name1=name+1&name2=name+2"
26
26
  end
27
27
 
28
- it "maps properly nil values " do
28
+ it "maps properly nil values" do
29
29
  subject.class.query_from_hash({:param1 => nil, :param2 => "A&B", :param3 => "C & D"}).should eql "param1=&param2=A%26B&param3=C+%26+D"
30
30
  end
31
31
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resource_accessor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Shvets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-21 00:00:00.000000000 Z
11
+ date: 2014-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gemspec_deps_gen
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  version: '0'
86
86
  requirements: []
87
87
  rubyforge_project:
88
- rubygems_version: 2.2.2
88
+ rubygems_version: 2.4.2
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: This library is used to simplify access to protected or unprotected http