alephant-broker 0.1.1 → 0.1.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: 8b93740e5628e1841d3f296c5675304678cc0be7
4
- data.tar.gz: 9412546f75f2f95a77c3b2cbfa3b53e98a296f9d
3
+ metadata.gz: a1b76434c055f4c00da0b9c3f3d5e890cf214b17
4
+ data.tar.gz: 37cf91c81f2defc12f72bb7a294558aa7d132aa7
5
5
  SHA512:
6
- metadata.gz: 34c3356dc0bab54c046bf2d8c269a07ea08c60ebfa9077d9f3eadd46a3df6fb48e1dd01d0bab710022607228629f98b6a4b91448153ed125cc38340e7a6e3626
7
- data.tar.gz: 9414facbf42866a0eba6e903ec71ba365f0f342c183edb13a8710125c9fba411b08067a6493551bd1fb8223c64f3a5ef58722404fcf796c7faed88fae2ed56bd
6
+ metadata.gz: 1b04c27451fbe768abe05155821acbccb51b0ce85b2dc62aa994466d7e3422ac992542fef5a2cea6c9f0999e8331a500bc7650a81e159a577aa36cbbebb1574b
7
+ data.tar.gz: 586130904e241c497b9ce8e4dc01e4cd8a8830c64fdfdecef64ed5e99326d0e7f522bf68d408dc68a6e9daf55a5ee5427e1fb080f1d00a67317046e8412da64a
@@ -7,9 +7,9 @@ module Alephant
7
7
  attr_reader :type, :component_id, :extension, :options, :content_type
8
8
 
9
9
  def initialize
10
+ super(:asset)
10
11
  env = RequestStore.store[:env]
11
12
  parse requested_components(env.path, env.query)
12
- super(:asset)
13
13
  end
14
14
 
15
15
  def requested_components(path, query_string)
@@ -11,7 +11,7 @@ module Alephant
11
11
  case type
12
12
  when :component
13
13
  GetRequest.new
14
- when :component_batch
14
+ when :components_batch
15
15
  PostRequest.new
16
16
  when :status
17
17
  StatusRequest.new
@@ -32,7 +32,9 @@ module Alephant
32
32
  def request_type
33
33
  case env.request_type
34
34
  when 'components'
35
- component_type
35
+ :components_batch
36
+ when 'component'
37
+ :component
36
38
  when 'status'
37
39
  :status
38
40
  else
@@ -40,15 +42,6 @@ module Alephant
40
42
  end
41
43
  end
42
44
 
43
- def component_type
44
- case env.method
45
- when 'POST'
46
- :component_batch
47
- when 'GET'
48
- :component
49
- end
50
- end
51
-
52
45
  def env
53
46
  @env ||= RequestStore.store[:env]
54
47
  end
@@ -41,19 +41,17 @@ module Alephant
41
41
  end
42
42
 
43
43
  def s3_path
44
- lookup.read(id, request.options, version).tap { |cache_id| raise InvalidCacheKey if cache_id.nil? }
44
+ lookup.read(component_id, request.options, version).tap do |lookup_object|
45
+ raise InvalidCacheKey if lookup_object.location.nil?
46
+ end.location unless version.nil?
45
47
  end
46
48
 
47
49
  def lookup
48
50
  @lookup ||= Alephant::Lookup.create(config[:lookup_table_name])
49
51
  end
50
52
 
51
- def asset?
52
- request.type == :asset
53
- end
54
-
55
53
  def key
56
- asset? ? component_key : renderer_key
54
+ request.type == :batch ? renderer_key : component_key
57
55
  end
58
56
 
59
57
  def component_key
@@ -64,10 +62,6 @@ module Alephant
64
62
  "#{renderer_id}/#{opts_hash}"
65
63
  end
66
64
 
67
- def id
68
- asset? ? component_id : renderer_id
69
- end
70
-
71
65
  def component_id
72
66
  request.component_id
73
67
  end
@@ -25,16 +25,15 @@ module Alephant
25
25
  end
26
26
  end
27
27
 
28
+ def response(status)
29
+ Response.new(status)
30
+ end
31
+
28
32
  private
29
33
 
30
34
  def config
31
35
  @config
32
36
  end
33
-
34
- def response(status)
35
- Response.new(status)
36
- end
37
-
38
37
  end
39
38
  end
40
39
  end
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  module Broker
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
data/spec/rack_spec.rb CHANGED
@@ -48,14 +48,14 @@ describe 'Broker Rack Application' do
48
48
  end
49
49
 
50
50
  it "Test asset data is returned" do
51
- get '/components/test_component'
51
+ get '/component/test_component'
52
52
 
53
53
  expect(last_response).to be_ok
54
54
  expect(last_response.body).to eq('Test')
55
55
  end
56
56
 
57
57
  it "Tests query string parameters are passed correctly to lookup" do
58
- get '/components/test_component?variant=test_variant'
58
+ get '/component/test_component?variant=test_variant'
59
59
 
60
60
  expect(last_response).to be_ok
61
61
  expect(last_response.body).to eq('Test')
@@ -67,7 +67,7 @@ describe 'Broker Rack Application' do
67
67
  .stub(:status)
68
68
  .and_return(404)
69
69
 
70
- get '/components/test_component'
70
+ get '/component/test_component'
71
71
 
72
72
  expect(last_response.status).to eq(404)
73
73
  end
@@ -78,7 +78,7 @@ describe 'Broker Rack Application' do
78
78
  .stub(:status)
79
79
  .and_return(500)
80
80
 
81
- get '/components/test_component'
81
+ get '/component/test_component'
82
82
 
83
83
  expect(last_response.status).to eq(500)
84
84
  end
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: 0.1.1
4
+ version: 0.1.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-03-18 00:00:00.000000000 Z
11
+ date: 2014-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec