alephant-broker 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/alephant/broker/component_factory.rb +2 -2
- data/lib/alephant/broker/component_meta.rb +13 -6
- data/lib/alephant/broker/environment.rb +0 -7
- data/lib/alephant/broker/load_strategy/http.rb +1 -1
- data/lib/alephant/broker/request/asset.rb +2 -2
- data/lib/alephant/broker/request/batch.rb +5 -1
- data/lib/alephant/broker/version.rb +1 -1
- data/spec/fixtures/json/batch.json +1 -1
- data/spec/fixtures/json/batch_compiled.json +1 -1
- data/spec/http_spec.rb +2 -2
- 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: 0eaf7f1fcaa9778c9c88112a3cffdcdc1de72115
|
4
|
+
data.tar.gz: 14f82c42772e0c91ae2edadfa07e00821bc6dae1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc5ff5fe4db92a920b1f4cab1cb53856561e7e6787b8142e44791c1498d178186788194f0fb7e52e3e046123cbbefc7a76b69691225a0b01d7125ad9ec58912a
|
7
|
+
data.tar.gz: 761ebd1fd85cdbf61c1dbfaeb5168ffc36aeedf6f9a26b9dacc670453233cdb3c55703dfa346b790c749352293fca971605c7a36873fde97d61ebd192cca3b83
|
@@ -12,8 +12,8 @@ module Alephant
|
|
12
12
|
@load_strategy = load_strategy
|
13
13
|
end
|
14
14
|
|
15
|
-
def create(id, batch_id,
|
16
|
-
component_meta = ComponentMeta.new(id, batch_id,
|
15
|
+
def create(id, batch_id, raw_options)
|
16
|
+
component_meta = ComponentMeta.new(id, batch_id, raw_options)
|
17
17
|
Component.new(
|
18
18
|
component_meta,
|
19
19
|
@load_strategy.load(component_meta)
|
@@ -1,20 +1,27 @@
|
|
1
1
|
module Alephant
|
2
2
|
module Broker
|
3
3
|
class ComponentMeta
|
4
|
-
attr_reader :id, :
|
4
|
+
attr_reader :id, :raw_options, :batch_id
|
5
5
|
attr_accessor :cached
|
6
6
|
|
7
|
-
def initialize(id, batch_id,
|
8
|
-
@id
|
9
|
-
@batch_id
|
10
|
-
@
|
11
|
-
@cached
|
7
|
+
def initialize(id, batch_id, raw_options)
|
8
|
+
@id = id
|
9
|
+
@batch_id = batch_id
|
10
|
+
@raw_options = raw_options
|
11
|
+
@cached = true
|
12
12
|
end
|
13
13
|
|
14
14
|
def cache_key
|
15
15
|
"#{id}/#{opts_hash}/#{version}"
|
16
16
|
end
|
17
17
|
|
18
|
+
def options
|
19
|
+
@options ||= raw_options.split('&').reduce({}) do |object, key_pair|
|
20
|
+
key, value = key_pair.split('=')
|
21
|
+
object.tap { |o| o.store(key.to_sym, value) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
18
25
|
def version
|
19
26
|
Broker.config.fetch(
|
20
27
|
'elasticache_cache_version', 'not available'
|
@@ -27,13 +27,6 @@ module Alephant
|
|
27
27
|
settings['QUERY_STRING'] || ""
|
28
28
|
end
|
29
29
|
|
30
|
-
def options
|
31
|
-
query.split('&').reduce({}) do |object, key_pair|
|
32
|
-
key, value = key_pair.split('=')
|
33
|
-
object.tap { |o| o.store(key.to_sym, value) }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
30
|
def path
|
38
31
|
settings['PATH_INFO']
|
39
32
|
end
|
@@ -14,11 +14,11 @@ module Alephant
|
|
14
14
|
return if env.nil?
|
15
15
|
|
16
16
|
component_id = env.path.split('/')[2] || nil
|
17
|
-
|
17
|
+
raw_options = env.query
|
18
18
|
|
19
19
|
raise InvalidAssetId.new("No Asset ID specified") if component_id.nil?
|
20
20
|
|
21
|
-
@component = component_factory.create(component_id, nil,
|
21
|
+
@component = component_factory.create(component_id, nil, raw_options)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -21,12 +21,16 @@ module Alephant
|
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
|
+
def build_query(hash)
|
25
|
+
hash.nil? ? '' : Rack::Utils.build_query(hash)
|
26
|
+
end
|
27
|
+
|
24
28
|
def components_for(env)
|
25
29
|
env.data['components'].map do |c|
|
26
30
|
@component_factory.create(
|
27
31
|
c['component'],
|
28
32
|
batch_id,
|
29
|
-
c['options']
|
33
|
+
build_query(c['options'])
|
30
34
|
)
|
31
35
|
end
|
32
36
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"batch_id":"baz","components":[{"component":"ni_council_results_table"},{"component":"ni_council_results_table"}]}
|
1
|
+
{"batch_id":"baz","components":[{"component":"ni_council_results_table", "options":{"foo" : "bar"}},{"component":"ni_council_results_table"}]}
|
@@ -1 +1 @@
|
|
1
|
-
{"batch_id":"baz","components":[{"component":"ni_council_results_table","options":{},"status":200,"content_type":"foo/bar","body":"Test"},{"component":"ni_council_results_table","options":{},"status":200,"content_type":"foo/bar","body":"Test"}]}
|
1
|
+
{"batch_id":"baz","components":[{"component":"ni_council_results_table","options":{"foo" : "bar"},"status":200,"content_type":"foo/bar","body":"Test"},{"component":"ni_council_results_table","options":{},"status":200,"content_type":"foo/bar","body":"Test"}]}
|
data/spec/http_spec.rb
CHANGED
@@ -35,7 +35,7 @@ describe Alephant::Broker::LoadStrategy::HTTP do
|
|
35
35
|
before :each do
|
36
36
|
allow(cache).to receive(:get).and_yield
|
37
37
|
allow(component_meta).to receive(:'cached=').with(false) { false }
|
38
|
-
allow(component_meta).to receive(:
|
38
|
+
allow(component_meta).to receive(:raw_options).and_return Hash.new
|
39
39
|
end
|
40
40
|
|
41
41
|
context "and available over HTTP" do
|
@@ -59,7 +59,7 @@ describe Alephant::Broker::LoadStrategy::HTTP do
|
|
59
59
|
|
60
60
|
context "and HTTP request fails" do
|
61
61
|
before :each do
|
62
|
-
allow(Faraday).to receive(:get).and_raise
|
62
|
+
allow(Faraday).to receive(:get).and_raise
|
63
63
|
end
|
64
64
|
|
65
65
|
specify do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alephant-broker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
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-
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|