pheme 3.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -0
- data/.rubocop.yml +29 -0
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/pheme/configuration.rb +5 -2
- data/lib/pheme/queue_poller.rb +2 -2
- data/lib/pheme/rollbar.rb +1 -1
- data/lib/pheme/topic_publisher.rb +1 -1
- data/lib/pheme/version.rb +1 -1
- data/pheme.gemspec +2 -1
- data/spec/configuration_spec.rb +31 -0
- data/spec/queue_poller_spec.rb +1 -1
- data/spec/rollbar_spec.rb +22 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/version_spec.rb +5 -5
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6759a6fc2cc14d4547c6ebaac443eaf8f575348b942d16d8d45bb42dcd7661f
|
4
|
+
data.tar.gz: 27a6583b5aba5af59f26334e7ef9c474c119133829ac203bc5c4837142ffa9a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d027e95e34039911f18b14a2af5c75b70a7d22becb4b66ee200a00abd6ea1cfe767758783ecb70edff1959123a1b7abb1c26ec4801fadcd1db1e1324d36143bc
|
7
|
+
data.tar.gz: '0917063c837f62ad082aa5bb8f0f9e8f6a1496d6de08f3d35eee90f4e8c59d9a7e256b4d1d53495c4e18340e0ba9e08705f0f6699adcc775af03f817a9fd7144'
|
data/.circleci/config.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -10,3 +10,32 @@ AllCops:
|
|
10
10
|
- 'examples/**/*'
|
11
11
|
- 'tmp/**/*'
|
12
12
|
- 'vendor/**/*'
|
13
|
+
|
14
|
+
# This configuration was generated by
|
15
|
+
# `rubocop --auto-gen-config`
|
16
|
+
# on 2019-02-14 09:34:30 -0500 using RuboCop version 0.64.0.
|
17
|
+
# The point is for the user to remove these configuration records
|
18
|
+
# one by one as the offenses are removed from the code base.
|
19
|
+
# Note that changes in the inspected code, or installation of new
|
20
|
+
# versions of RuboCop, may require this file to be generated again.
|
21
|
+
|
22
|
+
# Offense count: 1
|
23
|
+
Metrics/AbcSize:
|
24
|
+
Max: 22
|
25
|
+
|
26
|
+
# Offense count: 8
|
27
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
28
|
+
# URISchemes: http, https
|
29
|
+
Metrics/LineLength:
|
30
|
+
Max: 147
|
31
|
+
|
32
|
+
# Offense count: 4
|
33
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
34
|
+
Metrics/MethodLength:
|
35
|
+
Max: 22
|
36
|
+
|
37
|
+
# Offense count: 1
|
38
|
+
# Configuration parameters: MinBodyLength.
|
39
|
+
Style/GuardClause:
|
40
|
+
Exclude:
|
41
|
+
- 'lib/pheme/queue_poller.rb'
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## 3.1.0 - 2019-02-14
|
8
|
+
### Added
|
9
|
+
- Code coverage tracker integration (coveralls.io).
|
10
|
+
|
7
11
|
## 3.0.1 - 2019-02-07
|
8
12
|
### Changed
|
9
13
|
- Minimum Ruby version required to be 2.4.
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# pheme [](https://circleci.com/gh/wealthsimple/pheme)
|
1
|
+
# pheme [](https://circleci.com/gh/wealthsimple/pheme) [](https://coveralls.io/github/wealthsimple/pheme?branch=3.1.0-rc)
|
2
2
|
|
3
3
|
Ruby SNS publisher + SQS poller & message handler
|
4
4
|
|
data/lib/pheme/configuration.rb
CHANGED
@@ -16,8 +16,11 @@ module Pheme
|
|
16
16
|
end
|
17
17
|
|
18
18
|
class Configuration
|
19
|
-
ATTRIBUTES = %i[sns_client sqs_client logger
|
19
|
+
ATTRIBUTES = %i[sns_client sqs_client logger].freeze
|
20
|
+
OPTIONAL_ATTRIBUTES = %i[rollbar].freeze
|
21
|
+
|
20
22
|
attr_accessor(*ATTRIBUTES)
|
23
|
+
attr_accessor(*OPTIONAL_ATTRIBUTES)
|
21
24
|
|
22
25
|
def initialize
|
23
26
|
@logger ||= Logger.new(STDOUT) # rubocop:disable Lint/DisjunctiveAssignmentInConstructor
|
@@ -26,7 +29,7 @@ module Pheme
|
|
26
29
|
|
27
30
|
def validate!
|
28
31
|
ATTRIBUTES.each do |attribute|
|
29
|
-
raise "Invalid or missing configuration for #{attribute}"
|
32
|
+
raise "Invalid or missing configuration for #{attribute}" if send(attribute).blank?
|
30
33
|
end
|
31
34
|
raise "sns_client must be a Aws::SNS::Client" unless sns_client.is_a?(Aws::SNS::Client)
|
32
35
|
raise "sns_client must be a Aws::SQS::Client" unless sqs_client.is_a?(Aws::SQS::Client)
|
data/lib/pheme/queue_poller.rb
CHANGED
@@ -7,7 +7,7 @@ module Pheme
|
|
7
7
|
attr_accessor :queue_url, :queue_poller, :connection_pool_block, :format, :max_messages, :poller_configuration
|
8
8
|
|
9
9
|
def initialize(queue_url:, connection_pool_block: false, max_messages: nil, format: :json, poller_configuration: {}, sqs_client: nil)
|
10
|
-
raise ArgumentError, "must specify non-nil queue_url"
|
10
|
+
raise ArgumentError, "must specify non-nil queue_url" if queue_url.blank?
|
11
11
|
|
12
12
|
@queue_url = queue_url
|
13
13
|
@queue_poller = Aws::SQS::QueuePoller.new(queue_url, client: sqs_client)
|
@@ -95,7 +95,7 @@ module Pheme
|
|
95
95
|
|
96
96
|
def parse_csv(message_contents)
|
97
97
|
parsed_body = SmarterCSV.process(StringIO.new(message_contents))
|
98
|
-
parsed_body.map{ |item| RecursiveOpenStruct.new(item, recurse_over_arrays: true) }
|
98
|
+
parsed_body.map { |item| RecursiveOpenStruct.new(item, recurse_over_arrays: true) }
|
99
99
|
end
|
100
100
|
|
101
101
|
def parse_json(message_contents)
|
data/lib/pheme/rollbar.rb
CHANGED
@@ -24,7 +24,7 @@ module Pheme
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def initialize(topic_arn: self.class._topic_arn)
|
27
|
-
raise ArgumentError, "must specify non-nil topic_arn"
|
27
|
+
raise ArgumentError, "must specify non-nil topic_arn" if topic_arn.blank?
|
28
28
|
|
29
29
|
@topic_arn = topic_arn
|
30
30
|
end
|
data/lib/pheme/version.rb
CHANGED
data/pheme.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.homepage = "https://github.com/wealthsimple/pheme"
|
16
16
|
|
17
17
|
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
18
|
-
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
19
19
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
s.license = "MIT"
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_dependency "smarter_csv", "~> 1"
|
30
30
|
|
31
31
|
s.add_development_dependency 'bundler'
|
32
|
+
s.add_development_dependency 'coveralls'
|
32
33
|
s.add_development_dependency 'git'
|
33
34
|
s.add_development_dependency 'rake'
|
34
35
|
s.add_development_dependency 'rspec'
|
data/spec/configuration_spec.rb
CHANGED
@@ -19,4 +19,35 @@ describe Pheme do
|
|
19
19
|
expect(described_class.configuration.logger).to eq(custom_logger)
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
describe Pheme::Configuration do
|
24
|
+
describe '.validate!' do
|
25
|
+
subject { configuration.validate! }
|
26
|
+
|
27
|
+
let(:configuration) { Pheme::Configuration.new }
|
28
|
+
|
29
|
+
context 'empty configuration' do
|
30
|
+
it 'is invalid when empty' do
|
31
|
+
expect { subject }.to raise_error(StandardError)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'all mandatory attributes provided' do
|
36
|
+
let(:sns_client) { instance_double('Aws::SNS::Client') }
|
37
|
+
let(:sqs_client) { instance_double('Aws::SQS::Client') }
|
38
|
+
|
39
|
+
before do
|
40
|
+
allow(sns_client).to receive(:is_a?).with(Aws::SNS::Client).and_return(true)
|
41
|
+
allow(sqs_client).to receive(:is_a?).with(Aws::SQS::Client).and_return(true)
|
42
|
+
|
43
|
+
configuration.sns_client = sns_client
|
44
|
+
configuration.sqs_client = sqs_client
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'is valid' do
|
48
|
+
expect { subject }.not_to raise_error
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
22
53
|
end
|
data/spec/queue_poller_spec.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
RSpec.describe Pheme do
|
2
|
+
let(:rollbar) { double }
|
3
|
+
|
4
|
+
describe '.rollbar' do
|
5
|
+
let(:exception) { StandardError }
|
6
|
+
let(:message) { 'Unable to poll for messages' }
|
7
|
+
let(:data) { { sqs_url: 'arn::foo::bar' } }
|
8
|
+
|
9
|
+
before do
|
10
|
+
Pheme.configure do |config|
|
11
|
+
config.rollbar = rollbar
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
subject { Pheme.rollbar(exception, message, data) }
|
16
|
+
|
17
|
+
it 'sends error message to rollbar' do
|
18
|
+
expect(rollbar).to receive(:error).with(exception, message, data)
|
19
|
+
subject
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/version_spec.rb
CHANGED
@@ -2,11 +2,11 @@ require 'git'
|
|
2
2
|
|
3
3
|
describe Pheme do
|
4
4
|
def get_version(git, branch = 'HEAD')
|
5
|
-
git.grep('VERSION = ', 'lib/*/version.rb', { object: branch })
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
git.grep('VERSION = ', 'lib/*/version.rb', { object: branch }).
|
6
|
+
map { |_sha, matches| matches.first[1] }.
|
7
|
+
map(&method(:parse_version)).
|
8
|
+
reject(&:nil?).
|
9
|
+
first
|
10
10
|
end
|
11
11
|
|
12
12
|
def parse_version(string)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pheme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Graham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: git
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -228,6 +242,7 @@ files:
|
|
228
242
|
- spec/message_type/aws_event_spec.rb
|
229
243
|
- spec/message_type/sns_message_spec.rb
|
230
244
|
- spec/queue_poller_spec.rb
|
245
|
+
- spec/rollbar_spec.rb
|
231
246
|
- spec/spec_helper.rb
|
232
247
|
- spec/support/example_aws_event_queue_poller.rb
|
233
248
|
- spec/support/example_message_handler.rb
|
@@ -265,6 +280,7 @@ test_files:
|
|
265
280
|
- spec/message_type/aws_event_spec.rb
|
266
281
|
- spec/message_type/sns_message_spec.rb
|
267
282
|
- spec/queue_poller_spec.rb
|
283
|
+
- spec/rollbar_spec.rb
|
268
284
|
- spec/spec_helper.rb
|
269
285
|
- spec/support/example_aws_event_queue_poller.rb
|
270
286
|
- spec/support/example_message_handler.rb
|