pheme 4.1.1 → 5.0.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: ff68537e797de06e1b5ee79eeaa3b6f64c4783c571febadbb19779511b0eb426
4
- data.tar.gz: 9e49021b2cc77aa556de089c21b23397d9a6b03b98f03a5838310db04fac8b43
3
+ metadata.gz: 77aa7f2b7491323470cd9f9703b253281144ef680a474bd41dbc0b502f4f34cb
4
+ data.tar.gz: fa195a4334ea0b05e9a366411ae404802783423b12997af34d31d1438b8785e8
5
5
  SHA512:
6
- metadata.gz: 3e31aa40b21e8aff4d26c2869baae883b14c62aff3c7dc9073ff3ab2020b80a74093b731056a552d4148e1bc463a49073b9d715193373f401eb34f7593241605
7
- data.tar.gz: bd46da56fef237e5f952c428fd80247f77d7df3470da501195aa4712d1597ac2eb021a999d10002f20e3a505d0d549519213eb9ae519e3a6fa194430fb52a9dd
6
+ metadata.gz: 417c01bd6811da7e393508c7b1fbb98dbdff0ab415854e3f08074dd63ae896a54c53d6c970b0f7b42eceb150e13eec4d099fc7688abb4c60136ef9155f765ae5
7
+ data.tar.gz: e7ad5f758ee7f699c45c2f7abd0fe4d18a1ff5bd4d6472d5fed4d6c8a25c92c5758720853f7191307ffd4a23c76eaad67820eba2363f547e4105000e015a7b7e
@@ -38,7 +38,8 @@ jobs:
38
38
  - uses: actions/checkout@v2
39
39
  with:
40
40
  fetch-depth: 0
41
- - uses: ruby/setup-ruby@v1
41
+ - name: Set up Ruby
42
+ uses: ruby/setup-ruby@v1
42
43
  with:
43
44
  bundler-cache: true
44
45
  - name: Release the gem
@@ -0,0 +1,20 @@
1
+ name: 'Close stale PRs'
2
+ on:
3
+ schedule:
4
+ - cron: '30 6 * * *' # 6:30 am UTC: 1:30 am EST
5
+
6
+ jobs:
7
+ stale:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/stale@v4
11
+ with:
12
+ days-before-stale: 30
13
+ days-before-close: 60
14
+ stale-pr-message: >
15
+ This issue has been automatically marked as stale because it has not had
16
+ recent activity. It will be closed if no further activity occurs.
17
+ close-pr-message: >
18
+ This issue has been automatically closed because it has had no activity
19
+ for over 90 days. Please re-open if you feel this was done in error.
20
+ exempt-pr-labels: 'dependabot,depfu,dependencies,security'
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
+ ## 5.0.0 - 2022-01-04
8
+ ### Changed
9
+ - Remove RecusiveOpenStruct in favor of ResourceStruct::FlexStruct
10
+
7
11
  ## 4.1.1 - 2022-01-04
8
12
  ### Changed
9
13
  - Updated dependencies
data/Gemfile.lock CHANGED
@@ -1,25 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pheme (4.1.1)
4
+ pheme (5.0.0)
5
5
  activesupport (>= 4)
6
6
  aws-sdk-sns (~> 1.1)
7
7
  aws-sdk-sqs (~> 1.3)
8
- recursive-open-struct (~> 1)
8
+ resource-struct (~> 0.4)
9
9
  smarter_csv (~> 1)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activesupport (7.0.0)
14
+ activesupport (7.0.1)
15
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
16
  i18n (>= 1.6, < 2)
17
17
  minitest (>= 5.1)
18
18
  tzinfo (~> 2.0)
19
19
  ast (2.4.2)
20
20
  aws-eventstream (1.2.0)
21
- aws-partitions (1.544.0)
22
- aws-sdk-core (3.125.0)
21
+ aws-partitions (1.547.0)
22
+ aws-sdk-core (3.125.1)
23
23
  aws-eventstream (~> 1, >= 1.0.2)
24
24
  aws-partitions (~> 1, >= 1.525.0)
25
25
  aws-sigv4 (~> 1.1)
@@ -38,7 +38,7 @@ GEM
38
38
  concurrent-ruby (1.1.9)
39
39
  diff-lcs (1.5.0)
40
40
  docile (1.4.0)
41
- git (1.10.1)
41
+ git (1.10.2)
42
42
  rchardet (~> 1.8)
43
43
  i18n (1.8.11)
44
44
  concurrent-ruby (~> 1.0)
@@ -51,8 +51,8 @@ GEM
51
51
  rainbow (3.0.0)
52
52
  rake (13.0.6)
53
53
  rchardet (1.8.0)
54
- recursive-open-struct (1.1.3)
55
54
  regexp_parser (2.2.0)
55
+ resource-struct (0.4.0)
56
56
  rexml (3.2.5)
57
57
  rspec (3.10.0)
58
58
  rspec-core (~> 3.10.0)
@@ -72,7 +72,7 @@ GEM
72
72
  diff-lcs (>= 1.2.0, < 2.0)
73
73
  rspec-support (~> 3.10.0)
74
74
  rspec-support (3.10.3)
75
- rspec_junit_formatter (0.5.0)
75
+ rspec_junit_formatter (0.5.1)
76
76
  rspec-core (>= 2, < 4, != 2.12.0)
77
77
  rubocop (1.24.1)
78
78
  parallel (~> 1.10)
@@ -88,7 +88,7 @@ GEM
88
88
  rubocop-performance (1.13.1)
89
89
  rubocop (>= 1.7.0, < 2.0)
90
90
  rubocop-ast (>= 0.4.0)
91
- rubocop-rails (2.13.0)
91
+ rubocop-rails (2.13.1)
92
92
  activesupport (>= 4.2.0)
93
93
  rack (>= 1.1)
94
94
  rubocop (>= 1.7.0, < 2.0)
@@ -104,11 +104,11 @@ GEM
104
104
  simplecov-html (0.12.3)
105
105
  simplecov_json_formatter (0.1.3)
106
106
  smarter_csv (1.2.9)
107
- thor (1.1.0)
107
+ thor (1.2.1)
108
108
  tzinfo (2.0.4)
109
109
  concurrent-ruby (~> 1.0)
110
110
  unicode-display_width (2.1.0)
111
- ws-style (6.12.3)
111
+ ws-style (6.13.1)
112
112
  rubocop (>= 1.23)
113
113
  rubocop-performance (>= 1.10.2)
114
114
  rubocop-rails (>= 2.9.1)
@@ -132,4 +132,4 @@ DEPENDENCIES
132
132
  ws-style
133
133
 
134
134
  BUNDLED WITH
135
- 2.2.32
135
+ 2.2.33
data/Rakefile CHANGED
@@ -6,7 +6,9 @@ end
6
6
 
7
7
  require 'bundler/gem_tasks'
8
8
  require 'rspec/core/rake_task'
9
+ require 'rubocop/rake_task'
9
10
 
10
11
  RSpec::Core::RakeTask.new(:spec)
12
+ RuboCop::RakeTask.new
11
13
 
12
- task default: :spec
14
+ task default: %i[spec rubocop]
@@ -19,9 +19,7 @@ module Pheme
19
19
  end
20
20
 
21
21
  def parse_aws_event(message_contents)
22
- # rubocop:disable Vendor/RecursiveOpenStructUse
23
- RecursiveOpenStruct.new({ wrapper: message_contents }, recurse_over_arrays: true).wrapper
24
- # rubocop:enable Vendor/RecursiveOpenStructUse
22
+ ResourceStruct::FlexStruct.new({ wrapper: message_contents }).wrapper
25
23
  end
26
24
  end
27
25
  end
@@ -127,16 +127,12 @@ module Pheme
127
127
 
128
128
  def parse_csv(message_contents)
129
129
  parsed_body = SmarterCSV.process(StringIO.new(message_contents))
130
- # rubocop:disable Vendor/RecursiveOpenStructUse
131
- parsed_body.map { |item| RecursiveOpenStruct.new(item, recurse_over_arrays: true) }
132
- # rubocop:enable Vendor/RecursiveOpenStructUse
130
+ parsed_body.map { |item| ResourceStruct::FlexStruct.new(item) }
133
131
  end
134
132
 
135
133
  def parse_json(message_contents)
136
134
  parsed_body = JSON.parse(message_contents)
137
- # rubocop:disable Vendor/RecursiveOpenStructUse
138
- RecursiveOpenStruct.new({ wrapper: parsed_body }, recurse_over_arrays: true).wrapper
139
- # rubocop:enable Vendor/RecursiveOpenStructUse
135
+ ResourceStruct::FlexStruct.new({ wrapper: parsed_body }).wrapper
140
136
  end
141
137
 
142
138
  def handle(message, metadata, message_attributes)
data/lib/pheme/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pheme
2
- VERSION = '4.1.1'.freeze
2
+ VERSION = '5.0.0'.freeze
3
3
  end
data/lib/pheme.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'active_support/all'
2
- require 'recursive-open-struct'
2
+ require 'resource-struct'
3
3
  require 'aws-sdk-sns'
4
4
  require 'aws-sdk-sqs'
5
5
  require 'securerandom'
data/pheme.gemspec CHANGED
@@ -1,32 +1,32 @@
1
1
  lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
- require "pheme/version"
4
+ require 'pheme/version'
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless s.respond_to?(:metadata)
8
8
 
9
- s.name = "pheme"
9
+ s.name = 'pheme'
10
10
  s.version = Pheme::VERSION
11
- s.authors = ["Peter Graham"]
12
- s.email = ["peter@wealthsimple.com"]
11
+ s.authors = ['Peter Graham']
12
+ s.email = ['peter@wealthsimple.com']
13
13
  s.description = 'Ruby AWS SNS publisher + SQS poller & message handler'
14
14
  s.summary = 'Ruby SNS publisher + SQS poller & message handler'
15
- s.homepage = "https://github.com/wealthsimple/pheme"
15
+ s.homepage = 'https://github.com/wealthsimple/pheme'
16
16
 
17
17
  s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
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
- s.require_paths = ["lib"]
21
- s.license = "MIT"
20
+ s.require_paths = ['lib']
21
+ s.license = 'MIT'
22
22
 
23
23
  s.required_ruby_version = '>= 2.7.3'
24
24
 
25
- s.add_dependency "activesupport", ">= 4"
26
- s.add_dependency "aws-sdk-sns", "~> 1.1"
27
- s.add_dependency "aws-sdk-sqs", "~> 1.3"
28
- s.add_dependency "recursive-open-struct", "~> 1"
29
- s.add_dependency "smarter_csv", "~> 1"
25
+ s.add_dependency 'activesupport', '>= 4'
26
+ s.add_dependency 'aws-sdk-sns', '~> 1.1'
27
+ s.add_dependency 'aws-sdk-sqs', '~> 1.3'
28
+ s.add_dependency 'resource-struct', '~> 0.4'
29
+ s.add_dependency 'smarter_csv', '~> 1'
30
30
 
31
31
  s.add_development_dependency 'bundler'
32
32
  s.add_development_dependency 'git'
@@ -3,9 +3,7 @@ describe Pheme::MessageHandler do
3
3
 
4
4
  before { use_default_configuration! }
5
5
 
6
- # rubocop:disable RSpec/VerifiedDoubles
7
- let(:message) { double(status: status) }
8
- # rubocop:enable RSpec/VerifiedDoubles
6
+ let(:message) { ResourceStruct::FlexStruct.new(status: status) }
9
7
  let(:timestamp) { '2018-04-17T21:45:05.915Z' }
10
8
 
11
9
  describe "#handle" do
@@ -3,7 +3,8 @@ describe Pheme::MessageType::AwsEvent do
3
3
  let(:message_id) { SecureRandom.uuid }
4
4
  let(:queue_url) { 'http://queue_url' }
5
5
  let(:queue_message) do
6
- OpenStruct.new(
6
+ instance_double(
7
+ Aws::SQS::Message,
7
8
  message_id: message_id,
8
9
  body: { 'Records' => records }.to_json,
9
10
  queue_url: queue_url,
@@ -22,7 +22,7 @@ describe Pheme::MessageType::SnsMessage do
22
22
 
23
23
  describe "#parse_message" do
24
24
  context "with JSON message" do
25
- let!(:message) { OpenStruct.new({ body: '{"Message":"{\"test\":\"test\"}"}' }) }
25
+ let!(:message) { ResourceStruct::FlexStruct.new({ body: '{"Message":"{\"test\":\"test\"}"}' }) }
26
26
 
27
27
  it 'parses the message correctly' do
28
28
  expect(subject.parse_body(message).test).to eq("test")
@@ -5,7 +5,7 @@ describe Pheme::QueuePoller do
5
5
  let(:topic_arn) { 'arn:topic:test' }
6
6
 
7
7
  let!(:queue_message) do
8
- OpenStruct.new(
8
+ ResourceStruct::FlexStruct.new(
9
9
  body: { Message: message }.to_json,
10
10
  message_id: message_id,
11
11
  )
@@ -57,7 +57,7 @@ describe Pheme::QueuePoller do
57
57
 
58
58
  before do
59
59
  allow(Aws::SQS::QueuePoller).to receive(:new).and_return(aws_poller)
60
- allow(aws_poller).to receive(:before_request).and_yield(OpenStruct.new(received_message_count: max_messages))
60
+ allow(aws_poller).to receive(:before_request).and_yield(ResourceStruct::FlexStruct.new(received_message_count: max_messages))
61
61
  end
62
62
 
63
63
  it 'throws error' do
@@ -145,7 +145,7 @@ describe Pheme::QueuePoller do
145
145
 
146
146
  context 'when message attributes' do
147
147
  let(:queue_message) do
148
- OpenStruct.new(
148
+ ResourceStruct::FlexStruct.new(
149
149
  body: {
150
150
  Message: message,
151
151
  MessageAttributes: {
@@ -222,9 +222,7 @@ describe Pheme::QueuePoller do
222
222
  end
223
223
 
224
224
  it { is_expected.to have(2).items }
225
- # rubocop:disable Vendor/RecursiveOpenStructUse
226
- it { is_expected.to eq(RecursiveOpenStruct.new({ wrapper: expected_message }, recurse_over_arrays: true).wrapper) }
227
- # rubocop:enable Vendor/RecursiveOpenStructUse
225
+ it { is_expected.to eq(ResourceStruct::FlexStruct.new({ wrapper: expected_message }).wrapper) }
228
226
  end
229
227
 
230
228
  context "with unknown message format" do
@@ -242,9 +240,7 @@ describe Pheme::QueuePoller do
242
240
 
243
241
  it { is_expected.to be_a(Array) }
244
242
  its(:first) { is_expected.to be_a(Array) }
245
- # rubocop:disable Vendor/RecursiveOpenStructUse
246
- its('first.first') { is_expected.to be_a(RecursiveOpenStruct) }
247
- # rubocop:enable Vendor/RecursiveOpenStructUse
243
+ its('first.first') { is_expected.to be_a(ResourceStruct::FlexStruct) }
248
244
 
249
245
  it "parses the nested object" do
250
246
  expect(subject.first.first.test).to eq('test')
@@ -288,7 +284,7 @@ describe Pheme::QueuePoller do
288
284
  }
289
285
  }
290
286
  let!(:queue_message) do
291
- OpenStruct.new(
287
+ ResourceStruct::FlexStruct.new(
292
288
  body: notification.to_json,
293
289
  message_id: message_id,
294
290
  )
@@ -321,7 +317,7 @@ describe Pheme::QueuePoller do
321
317
  }
322
318
  }
323
319
  let!(:queue_message) do
324
- OpenStruct.new(
320
+ ResourceStruct::FlexStruct.new(
325
321
  body: notification.to_json,
326
322
  message_id: message_id,
327
323
  )
@@ -352,7 +348,7 @@ describe Pheme::QueuePoller do
352
348
  }
353
349
  end
354
350
  let!(:queue_message) do
355
- OpenStruct.new(
351
+ ResourceStruct::FlexStruct.new(
356
352
  body: notification.to_json,
357
353
  message_id: message_id,
358
354
  )
@@ -365,9 +361,7 @@ describe Pheme::QueuePoller do
365
361
 
366
362
  it "handles the message" do
367
363
  expect(ExampleMessageHandler).to receive(:new).with(
368
- # rubocop:disable Vendor/RecursiveOpenStructUse
369
- message: RecursiveOpenStruct.new(message),
370
- # rubocop:enable Vendor/RecursiveOpenStructUse
364
+ message: ResourceStruct::FlexStruct.new(message),
371
365
  metadata: { timestamp: timestamp, topic_arn: topic_arn },
372
366
  message_attributes: {},
373
367
  )
@@ -393,7 +387,7 @@ describe Pheme::QueuePoller do
393
387
  }
394
388
  end
395
389
  let!(:queue_message) do
396
- OpenStruct.new(
390
+ ResourceStruct::FlexStruct.new(
397
391
  body: notification.to_json,
398
392
  message_id: message_id,
399
393
  )
@@ -422,7 +416,7 @@ describe Pheme::QueuePoller do
422
416
  context "AWS-event message" do
423
417
  subject { ExampleAwsEventQueuePoller.new(queue_url: queue_url) }
424
418
 
425
- let(:queue_message) { OpenStruct.new(body: { 'Records' => records }.to_json) }
419
+ let(:queue_message) { ResourceStruct::FlexStruct.new(body: { 'Records' => records }.to_json) }
426
420
  let(:records) do
427
421
  [{ 'eventVersion' => '2.0', eventSource: 'aws:s3' }]
428
422
  end
@@ -443,7 +437,7 @@ describe Pheme::QueuePoller do
443
437
  let(:message) { { status: 'complete' } }
444
438
  let(:notification) { { 'MessageId' => SecureRandom.uuid, 'Message' => message.to_json, 'Type' => 'Notification', 'Timestamp' => timestamp } }
445
439
  let!(:queue_message) do
446
- OpenStruct.new(
440
+ ResourceStruct::FlexStruct.new(
447
441
  body: notification.to_json,
448
442
  message_id: message_id,
449
443
  )
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: 4.1.1
4
+ version: 5.0.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: 2022-01-04 00:00:00.000000000 Z
11
+ date: 2022-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -53,19 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
- name: recursive-open-struct
56
+ name: resource-struct
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1'
61
+ version: '0.4'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1'
68
+ version: '0.4'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: smarter_csv
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -216,6 +216,7 @@ files:
216
216
  - ".github/CODEOWNERS"
217
217
  - ".github/PULL_REQUEST_TEMPLATE.md"
218
218
  - ".github/workflows/main.yml"
219
+ - ".github/workflows/stale.yml"
219
220
  - ".gitignore"
220
221
  - ".rspec"
221
222
  - ".rubocop.yml"