unity-dynamodb-attribute-deserializer 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: e82494da405322393751ff5867f5217ecc45ac3153e633eaffcb73c08decb184
4
+ data.tar.gz: 9a6b1ce2e6dc9e98536723b6a1fd6c5106332ef9cac638c3207c275de4ede8a2
5
+ SHA512:
6
+ metadata.gz: 70131af4f4cd81f45c7c66f167adba74fcaa377ae9de324a35df4f06920d9d5713330cebd931c5a297d7edba2202c182b29fa1a4532cfcf6fcccccc5cf20fe5f
7
+ data.tar.gz: b6fd49a230cb45445c0615c86c92da2c8c9fc139fc2e18ca7cba209f14601056c8eb92d316e277bf7cb0d6574293d1129a1d384e41f994e9397604993eb0e43b
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-dynamodb-attribute_deserializer.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ unity-dynamodb-attribute-deserializer (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.4.4)
10
+ rake (13.0.6)
11
+ rspec (3.10.0)
12
+ rspec-core (~> 3.10.0)
13
+ rspec-expectations (~> 3.10.0)
14
+ rspec-mocks (~> 3.10.0)
15
+ rspec-core (3.10.1)
16
+ rspec-support (~> 3.10.0)
17
+ rspec-expectations (3.10.1)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.10.0)
20
+ rspec-mocks (3.10.2)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.10.0)
23
+ rspec-support (3.10.2)
24
+
25
+ PLATFORMS
26
+ x86_64-darwin-20
27
+
28
+ DEPENDENCIES
29
+ rake (~> 13.0)
30
+ rspec (~> 3.2)
31
+ unity-dynamodb-attribute-deserializer!
32
+
33
+ BUNDLED WITH
34
+ 2.2.3
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Unity::DynamoDB::AttributeDeserializer
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/dynamodb/attribute_deserializer`. 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-dynamodb-attribute-deserializer'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install unity-dynamodb-attribute_deserializer
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-dynamodb-attribute_deserializer.
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/dynamodb/attribute_deserializer"
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
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unity
4
+ module DynamoDB
5
+ class AttributeDeserializer
6
+ VERSION = '1.0.0'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bigdecimal'
4
+ require 'base64'
5
+ require_relative "attribute_deserializer/version"
6
+
7
+ module Unity
8
+ module DynamoDB
9
+ class AttributeDeserializer
10
+ def self.call(hash)
11
+ new.call(hash)
12
+ end
13
+
14
+ def call(hash)
15
+ return unless hash.is_a?(Hash)
16
+
17
+ hash.transform_values { |v| translate(v) }
18
+ end
19
+
20
+ def translate(arg)
21
+ type = arg.keys[0]
22
+ value = arg[type]
23
+ case type
24
+ when 'N' then BigDecimal(value)
25
+ when 'L'
26
+ value.map { |item| translate(item) }
27
+ when 'SS'
28
+ Set.new(value)
29
+ when 'NS'
30
+ Set.new(value.map(&:to_s))
31
+ when 'M'
32
+ value.transform_values { |item| translate(item) }
33
+ when 'S' then value.to_s
34
+ when 'B' then StringIO.new(Base64.decode64(value))
35
+ when 'BS'
36
+ Set.new(value.map { |item| StringIO.new(Base64.decode64(item)) })
37
+ when 'NULL' then nil
38
+ when 'BOOL' then value
39
+ else value
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1 @@
1
+ require 'unity/dynamodb/attribute_deserializer'
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/unity/dynamodb/attribute_deserializer/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "unity-dynamodb-attribute-deserializer"
7
+ spec.version = Unity::DynamoDB::AttributeDeserializer::VERSION
8
+ spec.authors = ["Julien D."]
9
+ spec.email = ["julien@pocketsizesun.com"]
10
+
11
+ spec.summary = 'AWS DynamoDB - Attribute Deserializer'
12
+ spec.description = 'AWS DynamoDB - Attribute Deserializer'
13
+ spec.homepage = 'https://github.com/pocketsizesun/unity-dynamodb-attribute-deserializer-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-dynamodb-attribute-deserializer-ruby'
20
+ spec.metadata["changelog_uri"] = 'https://github.com/pocketsizesun/unity-dynamodb-attribute-deserializer-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_development_dependency "rspec", "~> 3.2"
32
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unity-dynamodb-attribute-deserializer
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: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ description: AWS DynamoDB - Attribute Deserializer
28
+ email:
29
+ - julien@pocketsizesun.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - Gemfile.lock
37
+ - README.md
38
+ - Rakefile
39
+ - bin/console
40
+ - bin/setup
41
+ - lib/unity-dynamodb-attribute-deserializer.rb
42
+ - lib/unity/dynamodb/attribute_deserializer.rb
43
+ - lib/unity/dynamodb/attribute_deserializer/version.rb
44
+ - unity-dynamodb-attribute-deserializer.gemspec
45
+ homepage: https://github.com/pocketsizesun/unity-dynamodb-attribute-deserializer-ruby
46
+ licenses: []
47
+ metadata:
48
+ allowed_push_host: https://rubygems.org
49
+ homepage_uri: https://github.com/pocketsizesun/unity-dynamodb-attribute-deserializer-ruby
50
+ source_code_uri: https://github.com/pocketsizesun/unity-dynamodb-attribute-deserializer-ruby
51
+ changelog_uri: https://github.com/pocketsizesun/unity-dynamodb-attribute-deserializer-ruby
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.3.0
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubygems_version: 3.2.3
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: AWS DynamoDB - Attribute Deserializer
71
+ test_files: []