alephant-publisher 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -7
- data/lib/alephant/publisher/models/writer.rb +13 -11
- data/lib/alephant/publisher/version.rb +1 -1
- data/spec/spec_helper.rb +0 -3
- data/spec/writer_spec.rb +27 -8
- 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: cd6fe36891405dfb2be2c30591db6e4e14c269c4
|
4
|
+
data.tar.gz: 8ad4c2b7d371f67e9eb4b19680b4bff2342d8a1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 732114e16a6d671da86c8276988d1b3a7c33f6d27845f533620d2db58a2168860c5487845e9ffc545ac525f672c22408004a8813e4789444933f811e7f2b0291
|
7
|
+
data.tar.gz: 19f0a955d849329e4bde369606a878031b5a751dd758563dff7c0df13760c9e2355e057d07f3980f60818eaad04fd65182e090ffb046ba43ec205f2e2c91f62c
|
data/README.md
CHANGED
@@ -51,13 +51,14 @@ set_last_seen_proc = Proc.new do |data|
|
|
51
51
|
end
|
52
52
|
|
53
53
|
opts = {
|
54
|
-
:s3_bucket_id
|
55
|
-
:s3_object_path
|
56
|
-
:s3_object_id
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:sequential_proc
|
60
|
-
:set_last_seen_proc
|
54
|
+
:s3_bucket_id => 'bucket-id',
|
55
|
+
:s3_object_path => 'path/to/object',
|
56
|
+
:s3_object_id => 'object_id',
|
57
|
+
:sequencer_table_name => 'your_dynamo_db_table',
|
58
|
+
:sqs_queue_url => 'https://your_amazon_sqs_queue_url',
|
59
|
+
:sequential_proc => sequential_proc,
|
60
|
+
:set_last_seen_proc => set_last_seen_proc,
|
61
|
+
:lookup_table_name => 'your_lookup_table'
|
61
62
|
}
|
62
63
|
|
63
64
|
logger = Logger.new
|
@@ -6,28 +6,34 @@ module Alephant
|
|
6
6
|
attr_reader :mapper, :cache
|
7
7
|
|
8
8
|
def initialize(opts)
|
9
|
-
@renderer_id =
|
10
|
-
|
9
|
+
@renderer_id = opts[:renderer_id]
|
10
|
+
|
11
11
|
@cache = Cache.new(
|
12
12
|
opts[:s3_bucket_id],
|
13
13
|
opts[:s3_object_path]
|
14
14
|
)
|
15
|
+
|
15
16
|
@mapper = RenderMapper.new(
|
16
17
|
opts[:renderer_id],
|
17
18
|
opts[:view_path]
|
18
19
|
)
|
19
|
-
|
20
|
-
|
20
|
+
|
21
|
+
@lookup_table_name = opts[:lookup_table_name]
|
21
22
|
end
|
22
23
|
|
23
24
|
def write(data, version = nil)
|
25
|
+
lookup = Lookup.create(@lookup_table_name)
|
26
|
+
|
24
27
|
mapper.generate(data).each do |id, r|
|
25
|
-
store(id, r.render, data[:options], version)
|
28
|
+
store(id, r.render, data[:options], version, lookup)
|
26
29
|
end
|
30
|
+
|
31
|
+
lookup.process!
|
27
32
|
end
|
28
33
|
|
29
34
|
private
|
30
|
-
|
35
|
+
|
36
|
+
def store(id, content, options, version, lookup)
|
31
37
|
location = location_for(
|
32
38
|
id,
|
33
39
|
Crimp.signature(options),
|
@@ -35,11 +41,7 @@ module Alephant
|
|
35
41
|
)
|
36
42
|
|
37
43
|
cache.put(location, content)
|
38
|
-
lookup(id
|
39
|
-
end
|
40
|
-
|
41
|
-
def lookup(component_id)
|
42
|
-
Lookup.create(@lookup_table_name, component_id)
|
44
|
+
lookup.batch_write(id, options, location)
|
43
45
|
end
|
44
46
|
|
45
47
|
def location_for(component_id, options_hash, version = nil)
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
|
-
# $: << File.join(File.dirname(__FILE__),"..", "lib")
|
2
|
-
|
3
1
|
require 'pry'
|
4
2
|
require 'alephant/publisher'
|
5
3
|
require 'alephant/publisher/models/writer'
|
6
4
|
require 'alephant/publisher/models/queue'
|
7
5
|
require 'alephant/publisher/models/render_mapper'
|
8
|
-
# require 'logger'
|
9
6
|
require 'alephant/renderer'
|
10
7
|
require 'alephant/support/parser'
|
11
8
|
|
data/spec/writer_spec.rb
CHANGED
@@ -38,27 +38,46 @@ describe Alephant::Publisher::Writer do
|
|
38
38
|
|
39
39
|
Alephant::Lookup
|
40
40
|
.should_receive(:create)
|
41
|
-
.with('lookup_table_name'
|
41
|
+
.with('lookup_table_name')
|
42
42
|
.and_call_original
|
43
43
|
|
44
|
-
Alephant::Lookup::
|
44
|
+
Alephant::Lookup::LookupHelper.any_instance
|
45
45
|
.stub(:initialize)
|
46
46
|
|
47
|
-
Alephant::Lookup::
|
48
|
-
.
|
49
|
-
.
|
47
|
+
Alephant::Lookup::LookupTable
|
48
|
+
.any_instance
|
49
|
+
.stub(:table_name)
|
50
|
+
|
51
|
+
Alephant::Lookup::LookupHelper.any_instance
|
52
|
+
.should_receive(:batch_write)
|
53
|
+
.with(
|
54
|
+
'component_id',
|
55
|
+
options,
|
56
|
+
'renderer_id/component_id/42de5e5c6f74b9fe4d956704a6d9e1c7/0'
|
57
|
+
)
|
58
|
+
|
59
|
+
Alephant::Lookup::LookupHelper.any_instance
|
60
|
+
.should_receive(:process!)
|
50
61
|
|
51
62
|
subject.write(data, 0)
|
52
63
|
end
|
53
64
|
|
54
65
|
it "should put the correct location, content to cache" do
|
55
|
-
Alephant::Lookup::
|
66
|
+
Alephant::Lookup::LookupHelper
|
56
67
|
.any_instance
|
57
68
|
.stub(:initialize)
|
58
69
|
|
59
|
-
Alephant::Lookup::
|
70
|
+
Alephant::Lookup::LookupHelper
|
71
|
+
.any_instance
|
72
|
+
.stub(:batch_write)
|
73
|
+
|
74
|
+
Alephant::Lookup::LookupHelper
|
75
|
+
.any_instance
|
76
|
+
.stub(:process!)
|
77
|
+
|
78
|
+
Alephant::Lookup::LookupTable
|
60
79
|
.any_instance
|
61
|
-
.stub(:
|
80
|
+
.stub(:table_name)
|
62
81
|
|
63
82
|
Alephant::Cache.any_instance
|
64
83
|
.should_receive(:put)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alephant-publisher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Integralist
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|