esi 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/esi/client.rb +7 -14
- data/lib/esi/response.rb +13 -2
- data/lib/esi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8f83e980f923caa2cc0f9b5bf31acfb9c7abadc
|
4
|
+
data.tar.gz: 44bcbebf9363236aef4ff71f40fa799a077b620f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0019d599abad8664a7f6061ddbfe2d94d92d5a3be758bc020a73b6a200b6736250a9a5fd93e9b5ee0ed2f82b3b4519d42ab1d167778c8e588018aa8507281fe4'
|
7
|
+
data.tar.gz: 31927f969d9509558722496c08c67360f5408deac60a51d2c9697156e7615445a567ae63fcb8e9c77f7b057abe4d02a55bb07f5cbda3a47078ccdcc92a0b0b29
|
data/lib/esi/client.rb
CHANGED
@@ -112,11 +112,11 @@ module Esi
|
|
112
112
|
when 403 # Forbidden
|
113
113
|
logger.error "ApiForbiddenError: #{e.response.status}: #{e.response.body}"
|
114
114
|
logger.error url
|
115
|
-
raise Esi::ApiForbiddenError.new(Response.new(e.response))
|
115
|
+
raise Esi::ApiForbiddenError.new(Response.new(e.response, call))
|
116
116
|
when 404 # Not Found
|
117
|
-
raise Esi::ApiNotFoundError.new(Response.new(e.response))
|
117
|
+
raise Esi::ApiNotFoundError.new(Response.new(e.response, call))
|
118
118
|
else
|
119
|
-
response = Response.new(e.response)
|
119
|
+
response = Response.new(e.response, call)
|
120
120
|
logger.error "ApiUnknownError (#{response.status}): #{url}"
|
121
121
|
|
122
122
|
case response.error
|
@@ -139,18 +139,11 @@ module Esi
|
|
139
139
|
|
140
140
|
debug "Request successful"
|
141
141
|
|
142
|
-
ActiveSupport::Notifications.instrument('esi.client.response.
|
143
|
-
response = Response.new(response)
|
142
|
+
ActiveSupport::Notifications.instrument('esi.client.response.render') do
|
143
|
+
response = Response.new(response, call)
|
144
|
+
response.save
|
144
145
|
end
|
145
|
-
ActiveSupport::Notifications.instrument('esi.client.response.
|
146
|
-
if Esi.config.response_log_path && Dir.exists?(Esi.config.response_log_path)
|
147
|
-
call_name = call.class.to_s.downcase.split('::').last
|
148
|
-
folder = Pathname.new(Esi.config.response_log_path).join(call_name)
|
149
|
-
FileUtils.mkdir_p(folder)
|
150
|
-
File.write(folder.join("#{Time.now.to_i.to_s}.json"), response.to_s)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
ActiveSupport::Notifications.instrument('esi.client.response.classify') do
|
146
|
+
ActiveSupport::Notifications.instrument('esi.client.response.callback') do
|
154
147
|
response.data.each { |item| block.call(item) } if block
|
155
148
|
end
|
156
149
|
response
|
data/lib/esi/response.rb
CHANGED
@@ -4,12 +4,13 @@ module Esi
|
|
4
4
|
class Response
|
5
5
|
extend Forwardable
|
6
6
|
|
7
|
-
attr_reader :original_response, :data
|
7
|
+
attr_reader :original_response, :call, :data
|
8
8
|
def_delegators :original_response, :status, :body, :headers
|
9
9
|
def_delegators :data, :each
|
10
10
|
|
11
|
-
def initialize(response)
|
11
|
+
def initialize(response, call=nil)
|
12
12
|
@original_response = response
|
13
|
+
@call = call
|
13
14
|
@data = normalize_results
|
14
15
|
end
|
15
16
|
|
@@ -34,6 +35,16 @@ module Esi
|
|
34
35
|
@response_json ||= MultiJson.load(body, symbolize_keys: true) rescue {}
|
35
36
|
end
|
36
37
|
|
38
|
+
def save
|
39
|
+
return if call.nil?
|
40
|
+
return if Esi.config.response_log_path.blank? || !Dir.exists?(Esi.config.response_log_path)
|
41
|
+
|
42
|
+
call_name = call.class.to_s.split('::').last.underscore
|
43
|
+
folder = Pathname.new(Esi.config.response_log_path).join(call_name)
|
44
|
+
FileUtils.mkdir_p(folder)
|
45
|
+
File.write(folder.join("#{Time.now.to_i.to_s}.json"), to_json)
|
46
|
+
end
|
47
|
+
|
37
48
|
def method_missing(method, *args, &block)
|
38
49
|
begin
|
39
50
|
data.send(method, *args, &block)
|
data/lib/esi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Hiemstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|