alephant-broker 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13b219a0a816af81e147be4076441a641d597094
4
- data.tar.gz: d1a8e7340e1928c339fded8e0ea1b47cc8cfa3a0
3
+ metadata.gz: 0d298df3c0ecc64c933b538cf9996c1075ca45be
4
+ data.tar.gz: e23d34bff06c5add699e2cd0f9e6c297e825ca38
5
5
  SHA512:
6
- metadata.gz: 3493cad83967ed33668d6fd191e57aa3b58c30628f8ffad8e82e75dc72ef0ec888c7ffd16cca35cbfd015d7b70a6e7b7319323ba4f5db06fd6531a8fa30c99d1
7
- data.tar.gz: 2d398103e43e2945664a7d879578eed73b28b2386f340517a84b4aa107a5645c1c80954555608fdd32512b4d7aa060a0b4fb0684aa5c0403df8166f913a49c75
6
+ metadata.gz: 2d6f9d6f4e88b2a6a92c9b8fc4ec70d63046b7aea5fcac89c1541c75c65024ea16c8201868541628fd882181416747d6686c11b97fd4de790c43c2b34e05ac39
7
+ data.tar.gz: f1014f49a9d43b23d41e2020b30c64bab6704749a461c9b27ef0d9fe9881eb98bfa55107f41a2a8b53a4fea945ddecd6564c55c248fb016551ea71f48f863930
@@ -18,9 +18,9 @@ module Alephant
18
18
  component_meta,
19
19
  @load_strategy.load(component_meta)
20
20
  )
21
- rescue Alephant::Broker::Errors::ContentNotFound
21
+ rescue Alephant::Broker::Errors::ContentNotFound => e
22
22
  logger.warn 'Broker.ComponentFactory.create: Exception raised (ContentNotFound)'
23
- ErrorComponent.new(component_meta, 404)
23
+ ErrorComponent.new(component_meta, 404, e)
24
24
  rescue => e
25
25
  logger.warn("Broker.ComponentFactory.create: Exception raised (#{e.message}, #{e.backtrace.join('\n')})")
26
26
  ErrorComponent.new(component_meta, 500, e)
@@ -3,10 +3,10 @@ module Alephant
3
3
  class ErrorComponent
4
4
  attr_reader :batch_id, :content, :id, :options, :status
5
5
 
6
- def initialize(meta, status, body = nil)
6
+ def initialize(meta, status, exception)
7
7
  @batch_id = meta.batch_id
8
8
  @status = status
9
- @content = content_for body
9
+ @content = content_for exception
10
10
  @id = meta.id
11
11
  @options = {}
12
12
  end
@@ -23,19 +23,8 @@ module Alephant
23
23
 
24
24
  private
25
25
 
26
- STATUS_CODE_MAPPING = {
27
- 404 => 'Not found',
28
- 500 => 'Error retrieving content'
29
- }
30
-
31
- def content_for(body)
32
- body.nil? ? STATUS_CODE_MAPPING[status]
33
- : format_content_for(body)
34
- end
35
-
36
- def format_content_for(body)
37
- body.is_a? Exception ? "#{e.message}\n#{e.backtrace.join('\n')}"
38
- : body
26
+ def content_for(exception)
27
+ "#{exception.message}\n#{exception.backtrace.join('\n')}"
39
28
  end
40
29
  end
41
30
  end
@@ -1,7 +1,11 @@
1
1
  module Alephant
2
2
  module Broker
3
3
  module Errors
4
- class ContentNotFound < StandardError; end
4
+ class ContentNotFound < StandardError
5
+ def message
6
+ 'Not Found'
7
+ end
8
+ end
5
9
  end
6
10
  end
7
11
  end
@@ -6,8 +6,6 @@ module Alephant
6
6
  module Broker
7
7
  module LoadStrategy
8
8
  class HTTP
9
- class RequestFailed < StandardError; end
10
-
11
9
  class URL
12
10
  def generate
13
11
  raise NotImplementedError
@@ -50,10 +48,9 @@ module Alephant
50
48
 
51
49
  def request(component_meta)
52
50
  component_meta.cached = false
53
- Faraday.get(url_for component_meta).
54
- tap { |r| raise ContentNotFound unless r.success? }
55
- rescue => e
56
- raise RequestFailed, e
51
+ Faraday.get(url_for component_meta).tap do |r|
52
+ raise Alephant::Broker::Errors::ContentNotFound unless r.success?
53
+ end
57
54
  end
58
55
 
59
56
  def url_for(component_meta)
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  module Broker
3
- VERSION = "2.0.0"
3
+ VERSION = "2.0.1"
4
4
  end
5
5
  end
data/spec/http_spec.rb CHANGED
@@ -65,7 +65,7 @@ describe Alephant::Broker::LoadStrategy::HTTP do
65
65
  specify do
66
66
  expect do
67
67
  subject.load component_meta
68
- end.to raise_error Alephant::Broker::LoadStrategy::HTTP::RequestFailed
68
+ end.to raise_error
69
69
  end
70
70
  end
71
71
 
@@ -79,7 +79,7 @@ describe Alephant::Broker::LoadStrategy::HTTP do
79
79
  specify do
80
80
  expect do
81
81
  subject.load component_meta
82
- end.to raise_error Alephant::Broker::LoadStrategy::HTTP::RequestFailed
82
+ end.to raise_error
83
83
  end
84
84
  end
85
85
  end
metadata CHANGED
@@ -1,267 +1,267 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alephant-broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Jack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-22 00:00:00.000000000 Z
11
+ date: 2014-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
14
20
  requirement: !ruby/object:Gem::Requirement
15
21
  requirements:
16
22
  - - '>='
17
23
  - !ruby/object:Gem::Version
18
24
  version: '0'
19
- name: rspec
20
25
  prerelease: false
21
26
  type: :development
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-nc
22
29
  version_requirements: !ruby/object:Gem::Requirement
23
30
  requirements:
24
31
  - - '>='
25
32
  - !ruby/object:Gem::Version
26
33
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
34
  requirement: !ruby/object:Gem::Requirement
29
35
  requirements:
30
36
  - - '>='
31
37
  - !ruby/object:Gem::Version
32
38
  version: '0'
33
- name: rspec-nc
34
39
  prerelease: false
35
40
  type: :development
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard
36
43
  version_requirements: !ruby/object:Gem::Requirement
37
44
  requirements:
38
45
  - - '>='
39
46
  - !ruby/object:Gem::Version
40
47
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
48
  requirement: !ruby/object:Gem::Requirement
43
49
  requirements:
44
50
  - - '>='
45
51
  - !ruby/object:Gem::Version
46
52
  version: '0'
47
- name: guard
48
53
  prerelease: false
49
54
  type: :development
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
50
57
  version_requirements: !ruby/object:Gem::Requirement
51
58
  requirements:
52
59
  - - '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
62
  requirement: !ruby/object:Gem::Requirement
57
63
  requirements:
58
64
  - - '>='
59
65
  - !ruby/object:Gem::Version
60
66
  version: '0'
61
- name: guard-rspec
62
67
  prerelease: false
63
68
  type: :development
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
64
71
  version_requirements: !ruby/object:Gem::Requirement
65
72
  requirements:
66
73
  - - '>='
67
74
  - !ruby/object:Gem::Version
68
75
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
76
  requirement: !ruby/object:Gem::Requirement
71
77
  requirements:
72
78
  - - '>='
73
79
  - !ruby/object:Gem::Version
74
80
  version: '0'
75
- name: pry
76
81
  prerelease: false
77
82
  type: :development
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-remote
78
85
  version_requirements: !ruby/object:Gem::Requirement
79
86
  requirements:
80
87
  - - '>='
81
88
  - !ruby/object:Gem::Version
82
89
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
90
  requirement: !ruby/object:Gem::Requirement
85
91
  requirements:
86
92
  - - '>='
87
93
  - !ruby/object:Gem::Version
88
94
  version: '0'
89
- name: pry-remote
90
95
  prerelease: false
91
96
  type: :development
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry-nav
92
99
  version_requirements: !ruby/object:Gem::Requirement
93
100
  requirements:
94
101
  - - '>='
95
102
  - !ruby/object:Gem::Version
96
103
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
104
  requirement: !ruby/object:Gem::Requirement
99
105
  requirements:
100
106
  - - '>='
101
107
  - !ruby/object:Gem::Version
102
108
  version: '0'
103
- name: pry-nav
104
109
  prerelease: false
105
110
  type: :development
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake-rspec
106
113
  version_requirements: !ruby/object:Gem::Requirement
107
114
  requirements:
108
115
  - - '>='
109
116
  - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
117
+ version: 0.0.2
112
118
  requirement: !ruby/object:Gem::Requirement
113
119
  requirements:
114
120
  - - '>='
115
121
  - !ruby/object:Gem::Version
116
122
  version: 0.0.2
117
- name: rake-rspec
118
123
  prerelease: false
119
124
  type: :development
125
+ - !ruby/object:Gem::Dependency
126
+ name: bundler
120
127
  version_requirements: !ruby/object:Gem::Requirement
121
128
  requirements:
122
- - - '>='
129
+ - - ~>
123
130
  - !ruby/object:Gem::Version
124
- version: 0.0.2
125
- - !ruby/object:Gem::Dependency
131
+ version: '1.5'
126
132
  requirement: !ruby/object:Gem::Requirement
127
133
  requirements:
128
134
  - - ~>
129
135
  - !ruby/object:Gem::Version
130
136
  version: '1.5'
131
- name: bundler
132
137
  prerelease: false
133
138
  type: :development
139
+ - !ruby/object:Gem::Dependency
140
+ name: rake
134
141
  version_requirements: !ruby/object:Gem::Requirement
135
142
  requirements:
136
- - - ~>
143
+ - - '>='
137
144
  - !ruby/object:Gem::Version
138
- version: '1.5'
139
- - !ruby/object:Gem::Dependency
145
+ version: '0'
140
146
  requirement: !ruby/object:Gem::Requirement
141
147
  requirements:
142
148
  - - '>='
143
149
  - !ruby/object:Gem::Version
144
150
  version: '0'
145
- name: rake
146
151
  prerelease: false
147
152
  type: :development
153
+ - !ruby/object:Gem::Dependency
154
+ name: rack-test
148
155
  version_requirements: !ruby/object:Gem::Requirement
149
156
  requirements:
150
157
  - - '>='
151
158
  - !ruby/object:Gem::Version
152
159
  version: '0'
153
- - !ruby/object:Gem::Dependency
154
160
  requirement: !ruby/object:Gem::Requirement
155
161
  requirements:
156
162
  - - '>='
157
163
  - !ruby/object:Gem::Version
158
164
  version: '0'
159
- name: rack-test
160
165
  prerelease: false
161
166
  type: :development
167
+ - !ruby/object:Gem::Dependency
168
+ name: alephant-lookup
162
169
  version_requirements: !ruby/object:Gem::Requirement
163
170
  requirements:
164
171
  - - '>='
165
172
  - !ruby/object:Gem::Version
166
173
  version: '0'
167
- - !ruby/object:Gem::Dependency
168
174
  requirement: !ruby/object:Gem::Requirement
169
175
  requirements:
170
176
  - - '>='
171
177
  - !ruby/object:Gem::Version
172
178
  version: '0'
173
- name: alephant-lookup
174
179
  prerelease: false
175
180
  type: :runtime
181
+ - !ruby/object:Gem::Dependency
182
+ name: alephant-cache
176
183
  version_requirements: !ruby/object:Gem::Requirement
177
184
  requirements:
178
185
  - - '>='
179
186
  - !ruby/object:Gem::Version
180
187
  version: '0'
181
- - !ruby/object:Gem::Dependency
182
188
  requirement: !ruby/object:Gem::Requirement
183
189
  requirements:
184
190
  - - '>='
185
191
  - !ruby/object:Gem::Version
186
192
  version: '0'
187
- name: alephant-cache
188
193
  prerelease: false
189
194
  type: :runtime
195
+ - !ruby/object:Gem::Dependency
196
+ name: alephant-logger
190
197
  version_requirements: !ruby/object:Gem::Requirement
191
198
  requirements:
192
199
  - - '>='
193
200
  - !ruby/object:Gem::Version
194
201
  version: '0'
195
- - !ruby/object:Gem::Dependency
196
202
  requirement: !ruby/object:Gem::Requirement
197
203
  requirements:
198
204
  - - '>='
199
205
  - !ruby/object:Gem::Version
200
206
  version: '0'
201
- name: alephant-logger
202
207
  prerelease: false
203
208
  type: :runtime
209
+ - !ruby/object:Gem::Dependency
210
+ name: alephant-sequencer
204
211
  version_requirements: !ruby/object:Gem::Requirement
205
212
  requirements:
206
213
  - - '>='
207
214
  - !ruby/object:Gem::Version
208
215
  version: '0'
209
- - !ruby/object:Gem::Dependency
210
216
  requirement: !ruby/object:Gem::Requirement
211
217
  requirements:
212
218
  - - '>='
213
219
  - !ruby/object:Gem::Version
214
220
  version: '0'
215
- name: alephant-sequencer
216
221
  prerelease: false
217
222
  type: :runtime
223
+ - !ruby/object:Gem::Dependency
224
+ name: dalli-elasticache
218
225
  version_requirements: !ruby/object:Gem::Requirement
219
226
  requirements:
220
227
  - - '>='
221
228
  - !ruby/object:Gem::Version
222
229
  version: '0'
223
- - !ruby/object:Gem::Dependency
224
230
  requirement: !ruby/object:Gem::Requirement
225
231
  requirements:
226
232
  - - '>='
227
233
  - !ruby/object:Gem::Version
228
234
  version: '0'
229
- name: dalli-elasticache
230
235
  prerelease: false
231
236
  type: :runtime
237
+ - !ruby/object:Gem::Dependency
238
+ name: pmap
232
239
  version_requirements: !ruby/object:Gem::Requirement
233
240
  requirements:
234
241
  - - '>='
235
242
  - !ruby/object:Gem::Version
236
243
  version: '0'
237
- - !ruby/object:Gem::Dependency
238
244
  requirement: !ruby/object:Gem::Requirement
239
245
  requirements:
240
246
  - - '>='
241
247
  - !ruby/object:Gem::Version
242
248
  version: '0'
243
- name: pmap
244
249
  prerelease: false
245
250
  type: :runtime
251
+ - !ruby/object:Gem::Dependency
252
+ name: faraday
246
253
  version_requirements: !ruby/object:Gem::Requirement
247
254
  requirements:
248
255
  - - '>='
249
256
  - !ruby/object:Gem::Version
250
257
  version: '0'
251
- - !ruby/object:Gem::Dependency
252
258
  requirement: !ruby/object:Gem::Requirement
253
259
  requirements:
254
260
  - - '>='
255
261
  - !ruby/object:Gem::Version
256
262
  version: '0'
257
- name: faraday
258
263
  prerelease: false
259
264
  type: :runtime
260
- version_requirements: !ruby/object:Gem::Requirement
261
- requirements:
262
- - - '>='
263
- - !ruby/object:Gem::Version
264
- version: '0'
265
265
  description: Brokers requests for alephant components
266
266
  email:
267
267
  - stevenmajack@gmail.com