policymap_wrap 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/policymap_wrap/client.rb +2 -2
- data/lib/policymap_wrap/connection.rb +24 -22
- metadata +41 -48
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.1
|
@@ -25,9 +25,9 @@ module PolicyMap
|
|
25
25
|
|
26
26
|
class << self
|
27
27
|
|
28
|
-
def set_credentials(client_id, username, password)
|
28
|
+
def set_credentials(client_id, username, password, proxy_url=nil)
|
29
29
|
@@default_options = { :id => client_id, :ty => 'data', :f => 'j', :af => '1' }
|
30
|
-
@@connection = Connection.new(client_id, username, password)
|
30
|
+
@@connection = Connection.new(client_id, username, password, proxy_url)
|
31
31
|
@@connection.debug = @@debug
|
32
32
|
true
|
33
33
|
end
|
@@ -1,43 +1,44 @@
|
|
1
1
|
module PolicyMap
|
2
|
-
|
2
|
+
|
3
3
|
class Connection
|
4
4
|
|
5
5
|
attr_accessor :debug
|
6
6
|
attr_reader :client_id
|
7
7
|
|
8
|
-
def initialize(client_id, username, password)
|
8
|
+
def initialize(client_id, username, password, proxy_url)
|
9
9
|
@client_id = client_id
|
10
10
|
@username = username
|
11
11
|
@password = password
|
12
|
+
@proxy_url = proxy_url
|
12
13
|
@debug = false
|
13
14
|
end
|
14
15
|
|
15
16
|
def get(endpoint, data=nil)
|
16
17
|
request :get, endpoint, data
|
17
18
|
end
|
18
|
-
|
19
|
+
|
19
20
|
class Response
|
20
|
-
|
21
|
+
|
21
22
|
attr_reader :code, :header, :body, :message
|
22
|
-
|
23
|
-
HTTP_RESPONSES = { '100' => 'Continue', '101' => 'SwitchProtocol', '200' => 'OK', '201' => 'Created', '202' => 'Accepted', '203' => 'NonAuthoritativeInformation',
|
24
|
-
'204' => 'NoContent', '205' => 'ResetContent', '206' => 'PartialContent', '300' => 'MultipleChoice', '301' => 'MovedPermanently',
|
25
|
-
'302' => 'Found', '303' => 'SeeOther', '304' => 'NotModified', '305' => 'UseProxy', '307' => 'TemporaryRedirect', '400' => 'BadRequest',
|
26
|
-
'401' => 'Unauthorized', '402' => 'PaymentRequired', '403' => 'Forbidden', '404' => 'NotFound', '405' => 'MethodNotAllowed',
|
27
|
-
'406' => 'NotAcceptable', '407' => 'ProxyAuthenticationRequired', '408' => 'RequestTimeOut', '409' => 'Conflict', '410' => 'Gone',
|
28
|
-
'411' => 'LengthRequired', '412' => 'PreconditionFailed', '413' => 'RequestEntityTooLarge', '414' => 'RequestURITooLong',
|
29
|
-
'415' => 'UnsupportedMediaType', '416' => 'RequestedRangeNotSatisfiable', '417' => 'ExpectationFailed', '500' => 'InternalServerError',
|
23
|
+
|
24
|
+
HTTP_RESPONSES = { '100' => 'Continue', '101' => 'SwitchProtocol', '200' => 'OK', '201' => 'Created', '202' => 'Accepted', '203' => 'NonAuthoritativeInformation',
|
25
|
+
'204' => 'NoContent', '205' => 'ResetContent', '206' => 'PartialContent', '300' => 'MultipleChoice', '301' => 'MovedPermanently',
|
26
|
+
'302' => 'Found', '303' => 'SeeOther', '304' => 'NotModified', '305' => 'UseProxy', '307' => 'TemporaryRedirect', '400' => 'BadRequest',
|
27
|
+
'401' => 'Unauthorized', '402' => 'PaymentRequired', '403' => 'Forbidden', '404' => 'NotFound', '405' => 'MethodNotAllowed',
|
28
|
+
'406' => 'NotAcceptable', '407' => 'ProxyAuthenticationRequired', '408' => 'RequestTimeOut', '409' => 'Conflict', '410' => 'Gone',
|
29
|
+
'411' => 'LengthRequired', '412' => 'PreconditionFailed', '413' => 'RequestEntityTooLarge', '414' => 'RequestURITooLong',
|
30
|
+
'415' => 'UnsupportedMediaType', '416' => 'RequestedRangeNotSatisfiable', '417' => 'ExpectationFailed', '500' => 'InternalServerError',
|
30
31
|
'501' => 'NotImplemented', '502' => 'BadGateway', '503' => 'ServiceUnavailable', '504' => 'GatewayTimeOut', '505' => 'VersionNotSupported' }
|
31
|
-
|
32
|
+
|
32
33
|
def initialize(http_client)
|
33
34
|
@code = http_client.response_code
|
34
35
|
@header = http_client.header_str.is_a?(String) ? parse_headers(http_client.header_str) : http_client.header_str
|
35
36
|
@body = http_client.body_str
|
36
37
|
@message = HTTP_RESPONSES[@code.to_s]
|
37
38
|
end
|
38
|
-
|
39
|
+
|
39
40
|
private
|
40
|
-
|
41
|
+
|
41
42
|
def parse_headers(header_string)
|
42
43
|
header_lines = header_string.split($/)
|
43
44
|
header_lines.shift
|
@@ -47,7 +48,7 @@ module PolicyMap
|
|
47
48
|
hsh
|
48
49
|
end
|
49
50
|
end
|
50
|
-
|
51
|
+
|
51
52
|
end
|
52
53
|
|
53
54
|
private
|
@@ -100,18 +101,19 @@ module PolicyMap
|
|
100
101
|
[key.to_s, URI.escape(value.to_s)].join('=')
|
101
102
|
end.join('&')
|
102
103
|
end
|
103
|
-
|
104
|
+
|
104
105
|
def send_request(method, endpoint, headers)
|
105
106
|
if method == :get
|
106
107
|
@http_client = Curl::Easy.new(endpoint) do |c|
|
107
108
|
c.headers = headers
|
108
109
|
end
|
109
110
|
end
|
110
|
-
|
111
|
+
|
111
112
|
@http_client.userpwd = [@username, @password].join(':')
|
112
|
-
|
113
|
+
@http_client.proxy_url = @proxy_url unless @proxy_url.nil?
|
114
|
+
|
113
115
|
@http_client.perform
|
114
|
-
|
116
|
+
|
115
117
|
Response.new(@http_client)
|
116
118
|
end
|
117
119
|
|
@@ -134,7 +136,7 @@ module PolicyMap
|
|
134
136
|
end
|
135
137
|
end
|
136
138
|
end
|
137
|
-
|
139
|
+
|
138
140
|
end
|
139
|
-
|
141
|
+
|
140
142
|
end
|
metadata
CHANGED
@@ -1,60 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: policymap_wrap
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.1
|
4
5
|
prerelease:
|
5
|
-
version: 0.6.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Mauricio Gomes
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-08-27 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: yajl-ruby
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70213337199520 !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
23
21
|
version: 0.7.7
|
24
22
|
type: :runtime
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: curb
|
28
23
|
prerelease: false
|
29
|
-
|
24
|
+
version_requirements: *70213337199520
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: curb
|
27
|
+
requirement: &70213337198580 !ruby/object:Gem::Requirement
|
30
28
|
none: false
|
31
|
-
requirements:
|
32
|
-
- -
|
33
|
-
- !ruby/object:Gem::Version
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
34
32
|
version: 0.7.7.1
|
35
33
|
type: :runtime
|
36
|
-
version_requirements: *id002
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rspec
|
39
34
|
prerelease: false
|
40
|
-
|
35
|
+
version_requirements: *70213337198580
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70213337024520 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
45
43
|
version: 1.2.9
|
46
44
|
type: :development
|
47
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70213337024520
|
48
47
|
description: Ruby wrapper around the PolicyMap API. Your API may vary.
|
49
48
|
email: mauricio@geminisbs.com
|
50
49
|
executables: []
|
51
|
-
|
52
50
|
extensions: []
|
53
|
-
|
54
|
-
extra_rdoc_files:
|
51
|
+
extra_rdoc_files:
|
55
52
|
- LICENSE
|
56
53
|
- README.rdoc
|
57
|
-
files:
|
54
|
+
files:
|
58
55
|
- LICENSE
|
59
56
|
- README.rdoc
|
60
57
|
- VERSION
|
@@ -66,30 +63,26 @@ files:
|
|
66
63
|
- lib/policymap_wrap/hash_utils.rb
|
67
64
|
homepage: http://github.com/geminisbs/policymap_wrap
|
68
65
|
licenses: []
|
69
|
-
|
70
66
|
post_install_message:
|
71
67
|
rdoc_options: []
|
72
|
-
|
73
|
-
require_paths:
|
68
|
+
require_paths:
|
74
69
|
- lib
|
75
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
71
|
none: false
|
77
|
-
requirements:
|
78
|
-
- -
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version:
|
81
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
77
|
none: false
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version:
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
87
82
|
requirements: []
|
88
|
-
|
89
83
|
rubyforge_project:
|
90
|
-
rubygems_version: 1.8.
|
84
|
+
rubygems_version: 1.8.16
|
91
85
|
signing_key:
|
92
86
|
specification_version: 3
|
93
87
|
summary: Ruby wrapper around the PolicyMap API
|
94
88
|
test_files: []
|
95
|
-
|