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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e81e590f83bc8e851d2f00f30b65929119499ef0
4
- data.tar.gz: 86d65100146300d2a89334c6715f5f0ffbbba5ec
3
+ metadata.gz: e2e21432dbacae4075129580826237c03f84aeab
4
+ data.tar.gz: 8766968d2d59d607e8e1f94da100ccb65d49d479
5
5
  SHA512:
6
- metadata.gz: b061ce9dd7f87f1dffd49a35dbef571088397ed573e3fde419183fe732f01d8a449e56cbf8aac2989218b5d9174f159174e73475376393fdd5376a36dc21bdcf
7
- data.tar.gz: c017a40360ae6d47fe64e1e383d4bdc0dada2ad191eb718946df5395512f4e012109f8f7c190fb476bf14692c874cd61319f42712e14b90ac5199470da2db38c
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
 
@@ -7,4 +7,12 @@ module Dynamosaurus
7
7
  class << self
8
8
  attr_accessor :logger
9
9
  end
10
+
11
+ class BlackHole < BasicObject
12
+ def method_missing(method_name, *args)
13
+ nil
14
+ end
15
+ end
10
16
  end
17
+
18
+ Dynamosaurus.logger = Dynamosaurus::BlackHole.new
@@ -9,18 +9,22 @@ module Dynamosaurus
9
9
  subclasses
10
10
  end
11
11
 
12
- def create_table
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
- table = dynamo_db.create_table(
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
- unless ENV['DYNAMODB_SUFFIX']
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.to_s unless value.nil?
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?
@@ -1,3 +1,3 @@
1
1
  module Dynamosaurus
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -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.create_table
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
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-18 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler