unity-dynamodbstreams-event-parser 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 03fe62cfbda7904411dcb8b6c1ca1514a052336b69bc2276efac7ff32ca3c24b
4
+ data.tar.gz: e3481dd57f786df82833008ed2fdb4f4e39347b24db326a71751409d764cab77
5
+ SHA512:
6
+ metadata.gz: 7a447e1d5866dd1ea603e2930bfb4421a3c86dbf090f98fcb21401be7c6112b147190624129d36e204928f1492bd001c1b48aaff1ec857d525d6b62cc31a710f
7
+ data.tar.gz: 431b1e7268f271db923f22cc396a96a7b7f98faaaa0d5500d61b88829f99f041166fde386efc863455029081949a771d0fab7308778c5875af93c843f63668dc
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /*.gem
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in unity-dynamodbstreams-event_parser.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ unity-dynamodbstreams-event-parser (1.0.0)
5
+ unity-dynamodb-attribute-deserializer (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.4.4)
11
+ rake (13.0.6)
12
+ rspec (3.10.0)
13
+ rspec-core (~> 3.10.0)
14
+ rspec-expectations (~> 3.10.0)
15
+ rspec-mocks (~> 3.10.0)
16
+ rspec-core (3.10.1)
17
+ rspec-support (~> 3.10.0)
18
+ rspec-expectations (3.10.1)
19
+ diff-lcs (>= 1.2.0, < 2.0)
20
+ rspec-support (~> 3.10.0)
21
+ rspec-mocks (3.10.2)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.10.0)
24
+ rspec-support (3.10.2)
25
+ unity-dynamodb-attribute-deserializer (1.0.0)
26
+
27
+ PLATFORMS
28
+ x86_64-darwin-20
29
+
30
+ DEPENDENCIES
31
+ rake (~> 13.0)
32
+ rspec (~> 3.2)
33
+ unity-dynamodbstreams-event-parser!
34
+
35
+ BUNDLED WITH
36
+ 2.2.3
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Unity::DynamoDBStreams::EventParser
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/unity/dynamodbstreams/event_parser`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'unity-dynamodbstreams-event_parser'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install unity-dynamodbstreams-event_parser
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/unity-dynamodbstreams-event_parser.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "unity/dynamodbstreams/event_parser"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/example.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'bundler/setup'
2
+ require 'unity-dynamodbstreams-event-parser'
3
+
4
+ event = {
5
+ 'eventID' => '1',
6
+ 'eventName' => 'INSERT',
7
+ 'eventVersion' => '1.0',
8
+ 'eventSource' => 'aws:dynamodb',
9
+ 'awsRegion' => 'us-east-1',
10
+ 'dynamodb' => {
11
+ 'Keys' => { 'id' => { 'N' => '101' } },
12
+ 'NewImage' => {
13
+ 'id' => { 'N' => '101' },
14
+ 'message' => { 'S' => 'Hello world!' }
15
+ },
16
+ 'SequenceNumber' => '111',
17
+ 'SizeBytes' => 26,
18
+ 'StreamViewType' => 'NEW_AND_OLD_IMAGES',
19
+ 'ApproximateCreationDateTime' => 1633768788
20
+ },
21
+ 'eventSourceARN' => 'arn:aws:dynamodb:us-east-1:111122223333:table/TestTable/stream/2015–05–11T21:21:33.291'
22
+ }
23
+
24
+ event_parser = Unity::DynamoDBStreams::EventParser.new
25
+ parsed_event = event_parser.call(event)
26
+ pp parsed_event
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unity
4
+ module DynamoDBStreams
5
+ class EventParser
6
+ VERSION = '1.0.0'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "event_parser/version"
4
+ require 'unity-dynamodb-attribute-deserializer'
5
+
6
+ module Unity
7
+ module DynamoDBStreams
8
+ class EventParser
9
+ EventStruct = Struct.new(
10
+ :event_id, :event_name, :event_version, :event_source, :event_source_arn,
11
+ :aws_region, :dynamodb, :user_identity
12
+ )
13
+
14
+ StreamRecordStruct = Struct.new(
15
+ :approximate_creation_date_time,
16
+ :keys,
17
+ :new_image,
18
+ :old_image,
19
+ :sequence_number,
20
+ :size_bytes,
21
+ :stream_view_type
22
+ )
23
+
24
+ def initialize
25
+ @deserializer = Unity::DynamoDB::AttributeDeserializer.new
26
+ end
27
+
28
+ def call(hash)
29
+ EventStruct.new(
30
+ hash['eventID'],
31
+ hash['eventName'],
32
+ hash['eventVersion'],
33
+ hash['eventSource'],
34
+ hash['eventSourceARN'],
35
+ hash['awsRegion'],
36
+ StreamRecordStruct.new(
37
+ hash['dynamodb']['ApproximateCreationDateTime'],
38
+ @deserializer.call(hash['dynamodb']['Keys']),
39
+ @deserializer.call(hash['dynamodb']['NewImage']),
40
+ @deserializer.call(hash['dynamodb']['OldImage']),
41
+ hash['dynamodb']['SequenceNumber'],
42
+ hash['dynamodb']['SizeBytes'],
43
+ hash['dynamodb']['StreamViewType']
44
+ ),
45
+ hash['userIdentity']
46
+ )
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1 @@
1
+ require "unity/dynamodbstreams/event_parser"
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/unity/dynamodbstreams/event_parser/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "unity-dynamodbstreams-event-parser"
7
+ spec.version = Unity::DynamoDBStreams::EventParser::VERSION
8
+ spec.authors = ["Julien D."]
9
+ spec.email = ["julien@pocketsizesun.com"]
10
+
11
+ spec.summary = "DynamoDB Streams - Event Parser"
12
+ spec.description = "DynamoDB Streams - Event Parser"
13
+ spec.homepage = 'https://github.com/pocketsizesun/unity-dynamodbstreams-event-parser-ruby'
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
15
+
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = 'https://github.com/pocketsizesun/unity-dynamodbstreams-event-parser-ruby'
20
+ spec.metadata["changelog_uri"] = 'https://github.com/pocketsizesun/unity-dynamodbstreams-event-parser-ruby'
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency 'unity-dynamodb-attribute-deserializer', '~> 1.0'
32
+ spec.add_development_dependency "rspec", "~> 3.2"
33
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unity-dynamodbstreams-event-parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Julien D.
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-10-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: unity-dynamodb-attribute-deserializer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.2'
41
+ description: DynamoDB Streams - Event Parser
42
+ email:
43
+ - julien@pocketsizesun.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - README.md
52
+ - Rakefile
53
+ - bin/console
54
+ - bin/setup
55
+ - example.rb
56
+ - lib/unity-dynamodbstreams-event-parser.rb
57
+ - lib/unity/dynamodbstreams/event_parser.rb
58
+ - lib/unity/dynamodbstreams/event_parser/version.rb
59
+ - unity-dynamodbstreams-event-parser.gemspec
60
+ homepage: https://github.com/pocketsizesun/unity-dynamodbstreams-event-parser-ruby
61
+ licenses: []
62
+ metadata:
63
+ allowed_push_host: https://rubygems.org
64
+ homepage_uri: https://github.com/pocketsizesun/unity-dynamodbstreams-event-parser-ruby
65
+ source_code_uri: https://github.com/pocketsizesun/unity-dynamodbstreams-event-parser-ruby
66
+ changelog_uri: https://github.com/pocketsizesun/unity-dynamodbstreams-event-parser-ruby
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 2.3.0
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubygems_version: 3.2.3
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: DynamoDB Streams - Event Parser
86
+ test_files: []