dynamosaurus 0.0.4 → 0.0.5
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 +4 -4
- data/README.md +12 -0
- data/lib/dynamosaurus.rb +8 -0
- data/lib/dynamosaurus/dynamo_class.rb +10 -6
- data/lib/dynamosaurus/version.rb +1 -1
- data/spec/dynamosaurus_spec.rb +1 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2e21432dbacae4075129580826237c03f84aeab
|
4
|
+
data.tar.gz: 8766968d2d59d607e8e1f94da100ccb65d49d479
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dee6865e7b9465eb51891e990c11a8922478260a483771b5c6e98d08ee808c0f2af6aa229deeb97bfdd0e067b657d6ec8f0d42fa4b77da61fc4d722d8e2510a7
|
7
|
+
data.tar.gz: 46f993eaf9d8418687d66617b3ce9db934a287c3671780088556ab34d8b21204541b203f7157f8349440c09d5c232a8b15747ebac8511530e5f6a4019ae12757
|
data/README.md
CHANGED
@@ -31,6 +31,18 @@ Or install it yourself as:
|
|
31
31
|
}
|
32
32
|
Aws.config = aws_config
|
33
33
|
|
34
|
+
# create table
|
35
|
+
SimpleKVS.create_table
|
36
|
+
|
37
|
+
# create table using this schema
|
38
|
+
# { :table_name=>"simplekvs_local",
|
39
|
+
# :key_schema=>[{:key_type=>"HASH", :attribute_name=>"simple_key"}
|
40
|
+
# :attribute_definitions=>[{:attribute_name=>"simple_key", :attribute_type=>"S"}],
|
41
|
+
# :provisioned_throughput=>{:read_capacity_units=>10, :write_capacity_units=>10}}
|
42
|
+
|
43
|
+
# if add some options,
|
44
|
+
# SimpleKVS.create_table({:provisioned_throughput => {:read_capacity_units=>100, :write_capacity_units=>10}})
|
45
|
+
|
34
46
|
# create
|
35
47
|
SimpleKVS.put({:simple_key => "key"}, {:num => 1})
|
36
48
|
|
data/lib/dynamosaurus.rb
CHANGED
@@ -9,18 +9,22 @@ module Dynamosaurus
|
|
9
9
|
subclasses
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def create_tables
|
13
13
|
tables = dynamo_db.list_tables.table_names
|
14
14
|
|
15
15
|
Dynamosaurus::DynamoBase.all_models.each do |model_class|
|
16
16
|
if tables.index(model_class.table_name).nil?
|
17
|
-
|
18
|
-
model_class.schema
|
19
|
-
)
|
17
|
+
model_class.create_table
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
22
|
+
def create_table option={}
|
23
|
+
schem = schema.merge(option)
|
24
|
+
Dynamosaurus.logger << "create table #{schem}"
|
25
|
+
dynamo_db.create_table(schem)
|
26
|
+
end
|
27
|
+
|
24
28
|
def tables
|
25
29
|
Dynamosaurus::DynamoBase.all_models.map do |model_class|
|
26
30
|
model_class.table_name
|
@@ -33,7 +37,7 @@ module Dynamosaurus
|
|
33
37
|
|
34
38
|
def dynamo_db
|
35
39
|
return @dynamo_db if @dynamo_db
|
36
|
-
|
40
|
+
if Aws::config.empty?
|
37
41
|
@dynamo_db = Aws::DynamoDB::Client.new(
|
38
42
|
:endpoint => "http://localhost:8000",
|
39
43
|
:region => "us-west-1"
|
@@ -370,7 +374,7 @@ module Dynamosaurus
|
|
370
374
|
|
371
375
|
new_hash = {}
|
372
376
|
hash.each{|key, value|
|
373
|
-
new_hash[key] = value
|
377
|
+
new_hash[key] = value unless value.nil?
|
374
378
|
}
|
375
379
|
num_hash.merge({:updated_at => Time.now.to_i}).each{|key, value|
|
376
380
|
new_hash[key] = value.to_i unless value.nil?
|
data/lib/dynamosaurus/version.rb
CHANGED
data/spec/dynamosaurus_spec.rb
CHANGED
@@ -4,13 +4,12 @@ describe Dynamosaurus do
|
|
4
4
|
before(:all) do
|
5
5
|
ENV['DYNAMODB_SUFFIX'] = "_local"
|
6
6
|
|
7
|
-
Dynamosaurus::Logger.new('log/vm.log', :debug)
|
8
7
|
Aws.config = {
|
9
8
|
:endpoint => "http://localhost:8000",
|
10
9
|
:region => 'local_test',
|
11
10
|
}
|
12
11
|
|
13
|
-
Dynamosaurus::DynamoBase.
|
12
|
+
Dynamosaurus::DynamoBase.create_tables
|
14
13
|
end
|
15
14
|
|
16
15
|
after(:all) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamosaurus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isamu Arimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|