alephant-publisher-queue 2.2.0 → 2.3.0

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: e4e4629b6edec4107606c37b56d4c20c041bc1e9
4
- data.tar.gz: 9f96470b7492db9645d08a24c4ccf73a7a74bab0
3
+ metadata.gz: d03deb00bb8ef2ad51901691fda1e96cbad33869
4
+ data.tar.gz: 56b2924d2f8ee1fc4fa20f5159e8a6dfd089bc32
5
5
  SHA512:
6
- metadata.gz: 20162a9089a2c093fa7e4636e7abee2927866b405218c0a23cfe013227419131982cd034c75b7e50e67fd378dc837dadff6efff5b374d20fb2c48bf1d2e88e39
7
- data.tar.gz: 988aca2dc1c876ecfe9315e44699fd5d69701f7a03bd9b079a031b03d6048962fc9f174fa40cab834379636265003bf86b5636e641a1c6d8c54af4f8c3230967
6
+ metadata.gz: 1dbce0e3685ff1cc57b5a175dea97c414cdd3d482d0841d5d5de77cbfdc97d3736e5f35bda44c6583e32ed1fd89dd14f2b7a27289fb74339ab1309a8cdf2581b
7
+ data.tar.gz: 9d9489398e6cf4cdda5d772e040e68a09e9a1d63de91db61c06d6b4c61af5ea37b07deb1e641f2c5cecef20541a3e10d3cb21cdd420660ecaa063c2cba3590e1
@@ -22,10 +22,12 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rspec-nc"
23
23
  spec.add_development_dependency "guard"
24
24
  spec.add_development_dependency "guard-rspec"
25
+ spec.add_development_dependency "listen", "~> 3.0.8"
25
26
  spec.add_development_dependency "pry"
26
27
  spec.add_development_dependency "pry-remote"
27
28
  spec.add_development_dependency "pry-nav"
28
29
  spec.add_development_dependency "rake-rspec"
30
+ spec.add_development_dependency "simplecov"
29
31
 
30
32
  spec.add_runtime_dependency "rake"
31
33
  spec.add_runtime_dependency "aws-sdk", "~> 1.0"
@@ -4,8 +4,9 @@ require "alephant/publisher/queue/version"
4
4
  require "alephant/publisher/queue/options"
5
5
  require "alephant/publisher/queue/sqs_helper/queue"
6
6
  require "alephant/publisher/queue/sqs_helper/archiver"
7
- require "alephant/logger"
8
7
  require "alephant/publisher/queue/processor"
8
+ require "alephant/logger"
9
+ require "alephant/cache"
9
10
  require "json"
10
11
 
11
12
  module Alephant
@@ -17,7 +18,7 @@ module Alephant
17
18
  end
18
19
 
19
20
  class Publisher
20
- include Logger
21
+ include Alephant::Logger
21
22
 
22
23
  VISIBILITY_TIMEOUT = 60
23
24
  RECEIVE_WAIT_TIME = 15
@@ -28,7 +29,7 @@ module Alephant
28
29
  @opts = opts
29
30
  @processor = processor
30
31
 
31
- @queue = SQSHelper::Queue.new(
32
+ @queue = Alephant::Publisher::Queue::SQSHelper::Queue.new(
32
33
  aws_queue,
33
34
  archiver,
34
35
  opts.queue[:visibility_timeout] || VISIBILITY_TIMEOUT,
@@ -43,7 +44,7 @@ module Alephant
43
44
  private
44
45
 
45
46
  def archiver
46
- SQSHelper::Archiver.new(archive_cache, archiver_opts)
47
+ Alephant::Publisher::Queue::SQSHelper::Archiver.new(archive_cache, archiver_opts)
47
48
  end
48
49
 
49
50
  def archiver_opts
@@ -62,14 +63,18 @@ module Alephant
62
63
  end
63
64
 
64
65
  def archive_cache
65
- Cache.new(
66
+ Alephant::Cache.new(
66
67
  opts.writer[:s3_bucket_id],
67
68
  opts.writer[:s3_object_path]
68
69
  )
69
70
  end
70
71
 
72
+ def get_region
73
+ opts.queue[:sqs_account_region] || AWS.config.region
74
+ end
75
+
71
76
  def sqs_client
72
- @sqs_client ||= AWS::SQS.new
77
+ @sqs_client ||= AWS::SQS.new(:region => get_region)
73
78
  end
74
79
 
75
80
  def sqs_queue_options
@@ -7,7 +7,7 @@ module Alephant
7
7
  class InvalidKeySpecifiedError < StandardError; end
8
8
 
9
9
  class Options
10
- include Logger
10
+ include Alephant::Logger
11
11
 
12
12
  attr_reader :queue, :writer
13
13
 
@@ -1,5 +1,5 @@
1
1
  require "alephant/publisher/queue/writer"
2
- require "alephant/publisher/queue/processor/base"
2
+ require "alephant/publisher/queue/base_processor"
3
3
 
4
4
  module Alephant
5
5
  module Publisher
@@ -7,7 +7,7 @@ module Alephant
7
7
  module Queue
8
8
  module SQSHelper
9
9
  class Archiver
10
- include Logger
10
+ include Alephant::Logger
11
11
 
12
12
  attr_reader :cache, :async, :log_message_body, :log_validator
13
13
 
@@ -9,7 +9,7 @@ module Alephant
9
9
  WAIT_TIME = 5
10
10
  VISABILITY_TIMEOUT = 300
11
11
 
12
- include Logger
12
+ include Alephant::Logger
13
13
 
14
14
  attr_reader :queue, :timeout, :wait_time, :archiver
15
15
 
@@ -1,7 +1,7 @@
1
1
  module Alephant
2
2
  module Publisher
3
3
  module Queue
4
- VERSION = "2.2.0"
4
+ VERSION = "2.3.0"
5
5
  end
6
6
  end
7
7
  end
@@ -11,7 +11,7 @@ module Alephant
11
11
  module Publisher
12
12
  module Queue
13
13
  class Writer
14
- include Logger
14
+ include Alephant::Logger
15
15
 
16
16
  attr_reader :config, :message, :cache, :parser, :renderer
17
17
 
@@ -22,14 +22,14 @@ module Alephant
22
22
  end
23
23
 
24
24
  def cache
25
- @cache ||= Cache.new(
25
+ @cache ||= Alephant::Cache.new(
26
26
  config[:s3_bucket_id],
27
27
  config[:s3_object_path]
28
28
  )
29
29
  end
30
30
 
31
31
  def parser
32
- @parser ||= Support::Parser.new(
32
+ @parser ||= Alephant::Support::Parser.new(
33
33
  config[:msg_vary_id_path]
34
34
  )
35
35
  end
@@ -95,7 +95,7 @@ module Alephant
95
95
  end
96
96
 
97
97
  def seq_for(id)
98
- Sequencer.create(
98
+ Alephant::Sequencer.create(
99
99
  config[:sequencer_table_name],
100
100
  :id => seq_key_from(id),
101
101
  :jsonpath => config[:sequence_id_path],
@@ -109,7 +109,7 @@ module Alephant
109
109
  end
110
110
 
111
111
  def seq_id
112
- @seq_id ||= Sequencer::Sequencer.sequence_id_from(
112
+ @seq_id ||= Alephant::Sequencer::Sequencer.sequence_id_from(
113
113
  message, config[:sequence_id_path]
114
114
  )
115
115
  end
@@ -131,7 +131,7 @@ module Alephant
131
131
  end
132
132
 
133
133
  def lookup
134
- Lookup.create(config[:lookup_table_name], config)
134
+ Alephant::Lookup.create(config[:lookup_table_name], config)
135
135
  end
136
136
  end
137
137
  end
@@ -13,7 +13,7 @@ describe Alephant::Publisher::Queue::Processor do
13
13
 
14
14
  describe "#consume(msg)" do
15
15
  it "Consume the message and deletes it" do
16
- msg = double("AWS::SQS::ReceivedMessage", :delete => nil)
16
+ msg = instance_double(AWS::SQS::ReceivedMessage, :delete => nil)
17
17
  expect(msg).to receive(:delete)
18
18
  subject.consume(msg)
19
19
  end
@@ -1,8 +1,8 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Alephant::Publisher::Queue::SQSHelper::Archiver do
4
- let(:cache) { instance_double("Alephant::Cache", :put => nil) }
5
- let(:queue) { instance_double("AWS::SQS::Queue", :url => nil) }
4
+ let(:cache) { instance_double(Alephant::Cache, :put => nil) }
5
+ let(:queue) { instance_double(AWS::SQS::Queue, :url => nil) }
6
6
  let(:msg_body) { { :Message => JSON.generate(msg_uri) } }
7
7
  let(:msg_uri) { { :uri => "/content/asset/newsbeat" } }
8
8
  let(:message) do
@@ -63,7 +63,7 @@ describe Alephant::Publisher::Queue::Writer do
63
63
  end
64
64
 
65
65
  let(:renderer) do
66
- instance_double "Alephant::Renderer::Renderer"
66
+ instance_double(Alephant::Renderer::Renderer)
67
67
  end
68
68
 
69
69
  subject do
@@ -2,8 +2,8 @@ require "spec_helper"
2
2
 
3
3
  describe Alephant::Publisher::Queue do
4
4
  let(:options) { Alephant::Publisher::Queue::Options.new }
5
- let(:queue) { double("AWS::SQS::Queue", :url => nil) }
6
- let(:client_double) { double("AWS::SQS", :queues => queue_double) }
5
+ let(:queue) { double(AWS::SQS::Queue, :url => nil) }
6
+ let(:client_double) { double(AWS::SQS, :queues => queue_double) }
7
7
  let(:queue_double) do
8
8
  double("AWS::SQS::QueueCollection", :[] => queue, :url_for => nil)
9
9
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,15 @@
1
- require "pry"
1
+ $LOAD_PATH << File.join(File.dirname(__FILE__), "..", "lib")
2
2
 
3
+ require "pry"
3
4
  require "aws-sdk"
5
+ require "simplecov"
6
+
7
+ SimpleCov.start do
8
+ add_filter "/spec/"
9
+ end
10
+
4
11
  require "alephant/publisher/queue"
12
+
13
+ RSpec.configure do |config|
14
+ config.order = "random"
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alephant-publisher-queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - BBC News
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-17 00:00:00.000000000 Z
11
+ date: 2016-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ version: 3.0.8
89
+ name: listen
90
+ prerelease: false
91
+ type: :development
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 3.0.8
83
97
  - !ruby/object:Gem::Dependency
84
98
  requirement: !ruby/object:Gem::Requirement
85
99
  requirements:
@@ -136,6 +150,20 @@ dependencies:
136
150
  - - '>='
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ requirement: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ name: simplecov
160
+ prerelease: false
161
+ type: :development
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
139
167
  - !ruby/object:Gem::Dependency
140
168
  requirement: !ruby/object:Gem::Requirement
141
169
  requirements:
@@ -280,19 +308,19 @@ files:
280
308
  - alephant-publisher-queue.gemspec
281
309
  - lib/alephant/publisher/env.rb
282
310
  - lib/alephant/publisher/queue.rb
311
+ - lib/alephant/publisher/queue/base_processor.rb
283
312
  - lib/alephant/publisher/queue/options.rb
284
313
  - lib/alephant/publisher/queue/processor.rb
285
- - lib/alephant/publisher/queue/processor/base.rb
286
314
  - lib/alephant/publisher/queue/sqs_helper/archiver.rb
287
315
  - lib/alephant/publisher/queue/sqs_helper/queue.rb
288
316
  - lib/alephant/publisher/queue/version.rb
289
317
  - lib/alephant/publisher/queue/writer.rb
290
- - spec/archiver_spec.rb
291
- - spec/processor_spec.rb
292
- - spec/publisher_spec.rb
293
- - spec/queue_spec.rb
318
+ - spec/alephant/publisher/queue/processor_spec.rb
319
+ - spec/alephant/publisher/queue/sqs_helper/archiver_spec.rb
320
+ - spec/alephant/publisher/queue/sqs_helper/queue_spec.rb
321
+ - spec/alephant/publisher/queue/writer_spec.rb
322
+ - spec/alephant/publisher/queue_spec.rb
294
323
  - spec/spec_helper.rb
295
- - spec/writer_spec.rb
296
324
  homepage: https://github.com/BBC-News/alephant-publisher-queue
297
325
  licenses:
298
326
  - MIT
@@ -318,9 +346,9 @@ signing_key:
318
346
  specification_version: 4
319
347
  summary: Static publishing to S3 based on SQS messages
320
348
  test_files:
321
- - spec/archiver_spec.rb
322
- - spec/processor_spec.rb
323
- - spec/publisher_spec.rb
324
- - spec/queue_spec.rb
349
+ - spec/alephant/publisher/queue/processor_spec.rb
350
+ - spec/alephant/publisher/queue/sqs_helper/archiver_spec.rb
351
+ - spec/alephant/publisher/queue/sqs_helper/queue_spec.rb
352
+ - spec/alephant/publisher/queue/writer_spec.rb
353
+ - spec/alephant/publisher/queue_spec.rb
325
354
  - spec/spec_helper.rb
326
- - spec/writer_spec.rb