esp-commons 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/esp-commons.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'esp-commons/engine'
2
+ require 'esp-commons/requester'
2
3
 
3
4
  module EspCommons
4
5
  end
@@ -0,0 +1,27 @@
1
+ class Requester
2
+ def initialize(url, headers_accept = nil)
3
+ @response = Curl::Easy.perform(url) do |curl|
4
+ curl.headers['Accept'] = headers_accept
5
+ end
6
+ end
7
+
8
+ def response
9
+ @response
10
+ end
11
+
12
+ def response_headers
13
+ @response_headers ||= Hash[response.header_str.split("\r\n").map { |s| s.split(': ').map(&:strip) }]
14
+ end
15
+
16
+ def response_status
17
+ @response_status ||= response.response_code
18
+ end
19
+
20
+ def response_body
21
+ @response_body ||= response.body_str
22
+ end
23
+
24
+ def response_hash
25
+ @response_hash ||= ActiveSupport::JSON.decode(response_body)
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module EspCommons
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esp-commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-21 00:00:00.000000000 Z
12
+ date: 2012-04-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: openteam-commons
16
- requirement: &19480540 !ruby/object:Gem::Requirement
16
+ requirement: &22195340 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *19480540
24
+ version_requirements: *22195340
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rails
27
- requirement: &19505060 !ruby/object:Gem::Requirement
27
+ requirement: &22190780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *19505060
35
+ version_requirements: *22190780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: active_attr
38
- requirement: &19500040 !ruby/object:Gem::Requirement
38
+ requirement: &22189700 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *19500040
46
+ version_requirements: *22189700
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sqlite3
49
- requirement: &19499160 !ruby/object:Gem::Requirement
49
+ requirement: &22188940 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *19499160
57
+ version_requirements: *22188940
58
58
  description: Description of EspCommons.
59
59
  email:
60
60
  - mail@openteam.ru
@@ -65,6 +65,7 @@ files:
65
65
  - app/models/esp_commons/image.rb
66
66
  - config/locales/commons.ru.yml
67
67
  - lib/esp-commons/engine.rb
68
+ - lib/esp-commons/requester.rb
68
69
  - lib/esp-commons/version.rb
69
70
  - lib/esp-commons.rb
70
71
  - lib/generators/esp_commons/install/config/schedule.rb
@@ -86,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
87
  version: '0'
87
88
  segments:
88
89
  - 0
89
- hash: 306898731652434501
90
+ hash: 3117828154911893693
90
91
  required_rubygems_version: !ruby/object:Gem::Requirement
91
92
  none: false
92
93
  requirements:
@@ -95,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
96
  version: '0'
96
97
  segments:
97
98
  - 0
98
- hash: 306898731652434501
99
+ hash: 3117828154911893693
99
100
  requirements: []
100
101
  rubyforge_project:
101
102
  rubygems_version: 1.8.16