dynamodb_framework 1.2.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43c68b4046339dcf1497fd9b227b2b28856c281e
4
- data.tar.gz: cd4cccc048de83ac5b7d3f793cedf90be72ad18c
3
+ metadata.gz: 318aa80e8817e3654c1b398b6ae5610c6306ed1f
4
+ data.tar.gz: 23223e4bdf089ff9257a0501c01ae8c1eaa39538
5
5
  SHA512:
6
- metadata.gz: 18566e0f81953f9f6956e813a15340cb15e8d937247773a91a0895e7106e2022587cf629d8b0d5ae13cd7b48e41bccf98aa90fde3f74972ac56666e11267ff1d
7
- data.tar.gz: 7ee89bb2e01f23de3ff65f3c6a157db3a3f1d5faf3384c92a22613c3bd2b5a20594fc08747ab6493a305948a1c976d632a4824786114efc488340011b54f333d
6
+ metadata.gz: c32e535abdaea1c5361947f781ef81e6db62061840be50f97048a7ea8d4e8ecafe4479a9a43edf04c5eb44847fdddcfdc864332e08f0791bb89be2fdaf7e02d5
7
+ data.tar.gz: 154e6bb5af6b03eb69d692a94bd5e67e6e10fa28b8caee2247baaa320e01a8744201e0f5ecba6b4a5c1f949972516faec7815defd50d31cf809af7c70243ff43
data/.idea/.rakeTasks CHANGED
@@ -4,4 +4,4 @@ You are allowed to:
4
4
  1. Remove rake task
5
5
  2. Add existing rake tasks
6
6
  To add existing rake tasks automatically delete this file and reload the project.
7
- --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build dynamodb_framework-0.1.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install dynamodb_framework-0.1.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install dynamodb_framework-0.1.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.1.0 and build and push dynamodb_framework-0.1.0.gem to Rubygems" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
7
+ --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build dynamodb_framework-1.2.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install dynamodb_framework-1.2.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install dynamodb_framework-1.2.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v1.2.0 and build and push dynamodb_framework-1.2.0.gem to Rubygems" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
data/Gemfile CHANGED
@@ -3,4 +3,10 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in dynamodb_framework.gemspec
4
4
  gemspec
5
5
 
6
+ group :test, :development do
7
+ gem 'yard'
8
+ end
6
9
 
10
+ group :test do
11
+ gem 'simplecov', :require => false
12
+ end
data/README.md CHANGED
@@ -250,6 +250,15 @@ Before calling any methods from the repository the **.table_name** attribute mus
250
250
  ### #put
251
251
  This method is called to insert an item into a DynamoDb table.
252
252
 
253
+ *Note*:
254
+
255
+ [DateTime] attributes will be stored as an ISO8601 string
256
+
257
+ [Time] attributes will be stored as an Epoch Int
258
+
259
+ The intent is that if you need to sort in dynamo by dates, then make sure you use a [Time] type. The Epoch int allows
260
+ you to compare properly as comparing date strings are not reliable.
261
+
253
262
  **Params**
254
263
 
255
264
  - **item** [Object] [Required] The document to store within the table.
@@ -11,8 +11,12 @@ module DynamoDbFramework
11
11
  @dynamodb = store
12
12
  end
13
13
 
14
+ # Store the hash of an object to the dynamodb table
15
+ # *Note* : [DateTime] attributes will be stored as an ISO8601 string
16
+ # [Time] attributes will be stored as an Epoch Int
17
+ # The intent is that if you need to sort in dynamo by dates, then make sure you use a [Time] type. The Epoch int allows
18
+ # you to compare properly as comparing date strings are not reliable.
14
19
  def put(item)
15
-
16
20
  hash = to_hash(item)
17
21
 
18
22
  clean_hash(hash)
@@ -196,14 +200,27 @@ module DynamoDbFramework
196
200
  @hash_helper ||= HashHelper.new
197
201
  end
198
202
 
203
+ # Convert empty string values to nil, as well as convert DateTime and Time to appropriate storage formats.
199
204
  def clean_hash(hash)
200
205
  hash.each do |key, value|
201
206
  if value == ''
202
207
  hash[key] = nil
208
+ elsif value.is_a?(Array)
209
+ value.each do |item|
210
+ clean_hash(item) if item.is_a?(Hash)
211
+ end
212
+ elsif [DateTime, Time].include?(value.class)
213
+ hash[key] = convert_date(value)
203
214
  elsif value.is_a?(Hash)
204
215
  clean_hash(value)
205
216
  end
206
217
  end
207
218
  end
219
+
220
+ def convert_date(value)
221
+ klass = value.class
222
+ return value.iso8601 if klass == DateTime
223
+ return value.to_i if klass == Time
224
+ end
208
225
  end
209
226
  end
@@ -1,3 +1,3 @@
1
1
  module DynamoDbFramework
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
data/yard.sh ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/bash
2
+
3
+ yard stats --list-undoc
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamodb_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaughanbrittonsage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-02 00:00:00.000000000 Z
11
+ date: 2017-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -135,6 +135,7 @@ files:
135
135
  - script/restart.sh
136
136
  - script/start.sh
137
137
  - script/stop.sh
138
+ - yard.sh
138
139
  homepage: https://github.com/vaughanbrittonsage/dynamodb_framework
139
140
  licenses:
140
141
  - MIT
@@ -161,4 +162,3 @@ specification_version: 4
161
162
  summary: A lightweight framework to provide managers for working with aws dynamodb
162
163
  (incuding local version).
163
164
  test_files: []
164
- has_rdoc: