esp-commons 0.5.3 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/esp-commons/libraries/requester.rb +27 -6
- data/lib/esp-commons/version.rb +1 -1
- metadata +31 -55
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 97aa86b8429f52ebe262c6327af1aaeb7406c5cf
|
4
|
+
data.tar.gz: 047edc80b83b9067233a2a703bd1090ed14c768a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c90f207e5c98fd684a16c7548643387f0f14523f9b8c4b4f2517cc5a72d4427610673f0cbf689ba393b33457d9e7b06d35d440bd3fcefc1daaf57b49798011a9
|
7
|
+
data.tar.gz: 53ff0f6147130536e3b1d20361e1ab59040eacd6b7fca663d9c753c91cbe910bdbf8e2f461ca03603287c66133d6fdcb9670788c0f6b7755771b1d4d2dcc493f
|
@@ -1,9 +1,20 @@
|
|
1
1
|
require 'curb'
|
2
2
|
|
3
|
+
class RequesterException < Exception
|
4
|
+
end
|
5
|
+
|
3
6
|
class Requester
|
4
7
|
def initialize(url, headers_accept = nil)
|
5
|
-
@response
|
6
|
-
|
8
|
+
@response ||= RestClient::Request.execute(
|
9
|
+
:method => :get,
|
10
|
+
:url => url,
|
11
|
+
:timeout => 600,
|
12
|
+
:headers => {
|
13
|
+
:Accept => headers_accept,
|
14
|
+
:timeout => 600
|
15
|
+
}
|
16
|
+
) do |response, request, result, &block|
|
17
|
+
response
|
7
18
|
end
|
8
19
|
end
|
9
20
|
|
@@ -11,19 +22,29 @@ class Requester
|
|
11
22
|
@response
|
12
23
|
end
|
13
24
|
|
25
|
+
def stringify_headers(headers)
|
26
|
+
headers.map do |k, v|
|
27
|
+
{
|
28
|
+
k.to_s.split('_').map do |s|
|
29
|
+
s.capitalize.gsub('Etag', 'ETag').gsub('Ua', 'UA')
|
30
|
+
end.join('-') => v
|
31
|
+
}
|
32
|
+
end.reduce Hash.new, :merge
|
33
|
+
end
|
34
|
+
|
14
35
|
def response_headers
|
15
|
-
@response_headers ||=
|
36
|
+
@response_headers ||= stringify_headers response.headers
|
16
37
|
end
|
17
38
|
|
18
39
|
def response_status
|
19
|
-
@response_status ||= response.
|
40
|
+
@response_status ||= response.code
|
20
41
|
end
|
21
42
|
|
22
43
|
def response_body
|
23
|
-
@response_body ||= response.
|
44
|
+
@response_body ||= response.body.force_encoding 'UTF-8'
|
24
45
|
end
|
25
46
|
|
26
47
|
def response_hash
|
27
|
-
@response_hash ||= ActiveSupport::JSON.decode(response_body)
|
48
|
+
@response_hash ||= ActiveSupport::JSON.decode(response_body) rescue {}
|
28
49
|
end
|
29
50
|
end
|
data/lib/esp-commons/version.rb
CHANGED
metadata
CHANGED
@@ -1,142 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esp-commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- OpenTeam
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: active_attr
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: amqp
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: bunny
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
56
|
+
name: daemons
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
70
|
+
name: openteam-commons
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ">="
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :runtime
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ">="
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
84
|
+
name: rails
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - ">="
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :runtime
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - ">="
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
|
-
name:
|
98
|
+
name: rest-client
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :runtime
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - ">="
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: sqlite3
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - ">="
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0'
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- -
|
122
|
+
- - ">="
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '0'
|
142
125
|
description: Description of EspCommons.
|
@@ -146,47 +129,40 @@ executables: []
|
|
146
129
|
extensions: []
|
147
130
|
extra_rdoc_files: []
|
148
131
|
files:
|
132
|
+
- MIT-LICENSE
|
133
|
+
- README.rdoc
|
134
|
+
- Rakefile
|
149
135
|
- app/models/esp_commons/image.rb
|
150
136
|
- config/locales/commons.ru.yml
|
137
|
+
- lib/esp-commons.rb
|
151
138
|
- lib/esp-commons/engine.rb
|
152
139
|
- lib/esp-commons/libraries/message_maker.rb
|
153
140
|
- lib/esp-commons/libraries/requester.rb
|
154
141
|
- lib/esp-commons/libraries/subscriber.rb
|
155
142
|
- lib/esp-commons/version.rb
|
156
|
-
- lib/esp-commons.rb
|
157
143
|
- lib/generators/esp_commons/install/install_generator.rb
|
158
144
|
- lib/generators/esp_commons/install/templates/script/subscriber
|
159
|
-
- MIT-LICENSE
|
160
|
-
- Rakefile
|
161
|
-
- README.rdoc
|
162
145
|
homepage: http://github.com/openteam-esp/esp-commons
|
163
146
|
licenses: []
|
147
|
+
metadata: {}
|
164
148
|
post_install_message:
|
165
149
|
rdoc_options: []
|
166
150
|
require_paths:
|
167
151
|
- lib
|
168
152
|
required_ruby_version: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
153
|
requirements:
|
171
|
-
- -
|
154
|
+
- - ">="
|
172
155
|
- !ruby/object:Gem::Version
|
173
156
|
version: '0'
|
174
|
-
segments:
|
175
|
-
- 0
|
176
|
-
hash: 693550452088203428
|
177
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
|
-
none: false
|
179
158
|
requirements:
|
180
|
-
- -
|
159
|
+
- - ">="
|
181
160
|
- !ruby/object:Gem::Version
|
182
161
|
version: '0'
|
183
|
-
segments:
|
184
|
-
- 0
|
185
|
-
hash: 693550452088203428
|
186
162
|
requirements: []
|
187
163
|
rubyforge_project:
|
188
|
-
rubygems_version:
|
164
|
+
rubygems_version: 2.4.3
|
189
165
|
signing_key:
|
190
|
-
specification_version:
|
166
|
+
specification_version: 4
|
191
167
|
summary: Summary of EspCommons.
|
192
168
|
test_files: []
|