pheme 3.0.1 → 3.1.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
  SHA256:
3
- metadata.gz: 621deceb5241868a873295d67e9e45bf76b5af4a526fdd25eb9cb039eea9cbdc
4
- data.tar.gz: d34dec58d517aa4b8a45c804653869bc101f09d794b427d2f9f3443ebcc4d513
3
+ metadata.gz: a6759a6fc2cc14d4547c6ebaac443eaf8f575348b942d16d8d45bb42dcd7661f
4
+ data.tar.gz: 27a6583b5aba5af59f26334e7ef9c474c119133829ac203bc5c4837142ffa9a8
5
5
  SHA512:
6
- metadata.gz: f9427136ba54d55649638d7038e34c5d756a186c6122a43ab1161db3b8e4a48eec2cdcc9f042387d38e88219b946e3520e6e8111e242923722a333b4052b65a3
7
- data.tar.gz: db937f03dc966f977fce8e2a589fffd7aa93213c42e0b94f615f73b0325552c90945fb8ba1932a7452d83ccd3a09d6f78cf5cabb826e30a0f9608113aaa14d85
6
+ metadata.gz: d027e95e34039911f18b14a2af5c75b70a7d22becb4b66ee200a00abd6ea1cfe767758783ecb70edff1959123a1b7abb1c26ec4801fadcd1db1e1324d36143bc
7
+ data.tar.gz: '0917063c837f62ad082aa5bb8f0f9e8f6a1496d6de08f3d35eee90f4e8c59d9a7e256b4d1d53495c4e18340e0ba9e08705f0f6699adcc775af03f817a9fd7144'
@@ -39,6 +39,7 @@ references:
39
39
  run:
40
40
  name: Run rspec
41
41
  command: |
42
+ COVERALLS_REPO_TOKEN=${COVERALLS_REPO_TOKEN} \
42
43
  bundle exec rspec --require spec_helper \
43
44
  --format RspecJunitFormatter \
44
45
  --out test_results/rspec.xml \
@@ -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'
@@ -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 [![CircleCI](https://circleci.com/gh/wealthsimple/pheme.svg?style=svg&circle-token=76942be0b1712ac066627be264886ee18039ad11)](https://circleci.com/gh/wealthsimple/pheme)
1
+ # pheme [![CircleCI](https://circleci.com/gh/wealthsimple/pheme.svg?style=svg&circle-token=76942be0b1712ac066627be264886ee18039ad11)](https://circleci.com/gh/wealthsimple/pheme) [![Coverage Status](https://coveralls.io/repos/github/wealthsimple/pheme/badge.svg?branch=3.1.0-rc)](https://coveralls.io/github/wealthsimple/pheme?branch=3.1.0-rc)
2
2
 
3
3
  Ruby SNS publisher + SQS poller & message handler
4
4
 
@@ -16,8 +16,11 @@ module Pheme
16
16
  end
17
17
 
18
18
  class Configuration
19
- ATTRIBUTES = %i[sns_client sqs_client logger rollbar].freeze
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}" unless send(attribute).present?
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)
@@ -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" unless queue_url.present?
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)
@@ -1,6 +1,6 @@
1
1
  module Pheme
2
2
  def self.rollbar(exception, message, data = {})
3
- return if configuration.rollbar.nil?
3
+ return if configuration.rollbar.nil?
4
4
 
5
5
  configuration.rollbar.error(exception, message, data)
6
6
  end
@@ -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" unless topic_arn.present?
27
+ raise ArgumentError, "must specify non-nil topic_arn" if topic_arn.blank?
28
28
 
29
29
  @topic_arn = topic_arn
30
30
  end
@@ -1,3 +1,3 @@
1
1
  module Pheme
2
- VERSION = '3.0.1'.freeze
2
+ VERSION = '3.1.0'.freeze
3
3
  end
@@ -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'
@@ -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
@@ -75,7 +75,7 @@ describe Pheme::QueuePoller do
75
75
  let(:message) { 'unkonwn' }
76
76
 
77
77
  it "should raise error" do
78
- expect{ subject }.to raise_error(ArgumentError)
78
+ expect { subject }.to raise_error(ArgumentError)
79
79
  end
80
80
  end
81
81
 
@@ -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
@@ -1,3 +1,6 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
1
4
  require 'rspec'
2
5
  require 'rspec/its'
3
6
  require 'rspec/collection_matchers'
@@ -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
- .map { |_sha, matches| matches.first[1] }
7
- .map(&method(:parse_version))
8
- .reject(&:nil?)
9
- .first
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.1
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-07 00:00:00.000000000 Z
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