dynamodb_framework 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/.rakeTasks +1 -1
- data/Gemfile +6 -0
- data/README.md +9 -0
- data/lib/dynamodb_framework/dynamodb_repository.rb +18 -1
- data/lib/dynamodb_framework/version.rb +1 -1
- data/yard.sh +3 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 318aa80e8817e3654c1b398b6ae5610c6306ed1f
|
4
|
+
data.tar.gz: 23223e4bdf089ff9257a0501c01ae8c1eaa39538
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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-
|
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
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
|
data/yard.sh
ADDED
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.
|
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:
|
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:
|