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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d298df3c0ecc64c933b538cf9996c1075ca45be
4
- data.tar.gz: e23d34bff06c5add699e2cd0f9e6c297e825ca38
3
+ metadata.gz: 0eaf7f1fcaa9778c9c88112a3cffdcdc1de72115
4
+ data.tar.gz: 14f82c42772e0c91ae2edadfa07e00821bc6dae1
5
5
  SHA512:
6
- metadata.gz: 2d6f9d6f4e88b2a6a92c9b8fc4ec70d63046b7aea5fcac89c1541c75c65024ea16c8201868541628fd882181416747d6686c11b97fd4de790c43c2b34e05ac39
7
- data.tar.gz: f1014f49a9d43b23d41e2020b30c64bab6704749a461c9b27ef0d9fe9881eb98bfa55107f41a2a8b53a4fea945ddecd6564c55c248fb016551ea71f48f863930
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, options)
16
- component_meta = ComponentMeta.new(id, batch_id, options)
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, :options, :batch_id
4
+ attr_reader :id, :raw_options, :batch_id
5
5
  attr_accessor :cached
6
6
 
7
- def initialize(id, batch_id, options)
8
- @id = id
9
- @batch_id = batch_id
10
- @options = options
11
- @cached = true
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
@@ -56,7 +56,7 @@ module Alephant
56
56
  def url_for(component_meta)
57
57
  url_generator.generate(
58
58
  component_meta.id,
59
- component_meta.options
59
+ component_meta.raw_options
60
60
  )
61
61
  end
62
62
  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
- options = env.options
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, options)
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,5 +1,5 @@
1
1
  module Alephant
2
2
  module Broker
3
- VERSION = "2.0.1"
3
+ VERSION = "2.0.2"
4
4
  end
5
5
  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(:options).and_return Hash.new
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.1
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-23 00:00:00.000000000 Z
11
+ date: 2014-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec