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 +4 -4
- data/.ruby-version +1 -1
- data/CHANGES +5 -1
- data/lib/resource_accessor/resource_accessor.rb +17 -7
- data/lib/resource_accessor/version.rb +1 -1
- data/spec/resource_accessor_spec.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91aa3aad7b244ffeaca70883e86d0fdded16ce78
|
4
|
+
data.tar.gz: ae227c4946db340b0c5fac159d2882e9dfc5638e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb81e9f1fc0921239f68f90b6f1e0a19317ab3374a28858f14837719e2d2700821f40a131c547538497f57688d66a1f94b3f7b027fa78f1c361b3cd5fa76d806
|
7
|
+
data.tar.gz: f6d405c25b15bccdf0f442111e0158b1919cac1242bc1327563db87998e7fcdd5c92c11a2e414b3d0c035d624acbb2939fc1fce2e59bc81b2dc19f34286ae0c7
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.4
|
data/CHANGES
CHANGED
@@ -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
|
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
|
@@ -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
|
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=¶m2=A%26B¶m3=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.
|
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-
|
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.
|
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
|