dymos 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dymos.gemspec +1 -1
- data/lib/dymos/model.rb +3 -1
- data/lib/dymos/query/query.rb +5 -2
- data/lib/dymos/version.rb +1 -1
- data/spec/lib/dymos/model_spec.rb +28 -26
- data/spec/lib/dymos/query/query_spec.rb +16 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf372b964ae4ad9a7daf6fce92ec70b57350b50a
|
4
|
+
data.tar.gz: 1f5f8471eeb4e88db89fcb64a801249f8084377f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dfe884a6015ca023dfcba429f5cecbf9c1a3a95ff7afff42f177d561e50526ba81fd692b2aa700b8784d5152f32db9a86ef36f15a5dbd4f3a1c37ee207e4791
|
7
|
+
data.tar.gz: 0265d0d9a54599f0ce3158b47eea72cf54b8b3a1740935b64024d9cd1a3bbb1469d321e687a092454ad9d77dec34e5314a2a24b5af26deb68d065babb0ccef3c
|
data/dymos.gemspec
CHANGED
data/lib/dymos/model.rb
CHANGED
@@ -22,11 +22,13 @@ module Dymos
|
|
22
22
|
default: default
|
23
23
|
}
|
24
24
|
define_attribute_methods attr
|
25
|
-
define_method(attr) {|raw=false|
|
25
|
+
define_method(attr) { |raw=false|
|
26
26
|
val=read_attribute(attr) || default
|
27
27
|
return val if raw
|
28
28
|
if type == :time && val.present?
|
29
29
|
Time.parse val
|
30
|
+
elsif type == :integer && val.present?
|
31
|
+
val.to_i
|
30
32
|
else
|
31
33
|
val
|
32
34
|
end
|
data/lib/dymos/query/query.rb
CHANGED
@@ -26,12 +26,15 @@ module Dymos
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def query
|
29
|
-
{
|
29
|
+
data = {
|
30
30
|
table_name: @table_name.to_s,
|
31
|
-
index_name: @index_name.to_s,
|
32
31
|
key_conditions: @key,
|
33
32
|
consistent_read: false
|
34
33
|
}
|
34
|
+
if @index_name.present?
|
35
|
+
data[:index_name] = @index_name.to_s
|
36
|
+
end
|
37
|
+
data
|
35
38
|
end
|
36
39
|
end
|
37
40
|
end
|
data/lib/dymos/version.rb
CHANGED
@@ -5,6 +5,7 @@ describe Dymos::Model do
|
|
5
5
|
field :name, :string
|
6
6
|
field :email, :string
|
7
7
|
field :list, :string_set
|
8
|
+
field :count, :integer
|
8
9
|
|
9
10
|
field :created_at, :time
|
10
11
|
field :updated_at, :time
|
@@ -23,7 +24,7 @@ describe Dymos::Model do
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def sample_user_hash
|
26
|
-
{id: 'hoge', name: '太郎', email: 'hoge@example.net', list: Set['a', 'b', 'c']}
|
27
|
+
{id: 'hoge', name: '太郎', email: 'hoge@example.net', count: 10, list: Set['a', 'b', 'c']}
|
27
28
|
end
|
28
29
|
|
29
30
|
before :all do
|
@@ -35,17 +36,17 @@ describe Dymos::Model do
|
|
35
36
|
|
36
37
|
client.delete_table(table_name: 'dummy') if client.list_tables[:table_names].include?('dummy')
|
37
38
|
client.create_table(
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
39
|
+
table_name: 'dummy',
|
40
|
+
attribute_definitions: [
|
41
|
+
{attribute_name: 'id', attribute_type: 'S'}
|
42
|
+
],
|
43
|
+
key_schema: [
|
44
|
+
{attribute_name: 'id', key_type: 'HASH'}
|
45
|
+
],
|
46
|
+
provisioned_throughput: {
|
47
|
+
read_capacity_units: 1,
|
48
|
+
write_capacity_units: 1,
|
49
|
+
})
|
49
50
|
client.put_item(table_name: 'dummy', item: {id: 'hoge', name: '太郎', list: Set['a', 'b', 'c']})
|
50
51
|
client.put_item(table_name: 'dummy', item: {id: 'fuga', name: '次郎'})
|
51
52
|
client.put_item(table_name: 'dummy', item: {id: 'piyo', name: '三郎'})
|
@@ -53,26 +54,26 @@ describe Dymos::Model do
|
|
53
54
|
|
54
55
|
client.delete_table(table_name: 'post') if client.list_tables[:table_names].include?('post')
|
55
56
|
client.create_table(
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
57
|
+
table_name: 'post',
|
58
|
+
attribute_definitions: [
|
59
|
+
{attribute_name: 'id', attribute_type: 'S'},
|
60
|
+
{attribute_name: 'timestamp', attribute_type: 'N'},
|
61
|
+
],
|
62
|
+
key_schema: [
|
63
|
+
{attribute_name: 'id', key_type: 'HASH'},
|
64
|
+
{attribute_name: 'timestamp', key_type: 'RANGE'},
|
65
|
+
],
|
66
|
+
provisioned_throughput: {
|
67
|
+
read_capacity_units: 1,
|
68
|
+
write_capacity_units: 1,
|
69
|
+
})
|
69
70
|
end
|
70
71
|
|
71
72
|
# let(:model) { Dummy.new }
|
72
73
|
|
73
74
|
describe :fields do
|
74
75
|
it do
|
75
|
-
expect(DummyUser.fields.keys).to eq([:id, :name, :email, :list, :created_at, :updated_at])
|
76
|
+
expect(DummyUser.fields.keys).to eq([:id, :name, :email, :list, :count, :created_at, :updated_at])
|
76
77
|
end
|
77
78
|
end
|
78
79
|
describe "クラスマクロのデフォルト値" do
|
@@ -150,6 +151,7 @@ describe Dymos::Model do
|
|
150
151
|
expect(model.id).to eq('hoge')
|
151
152
|
expect(model.name).to eq('太郎')
|
152
153
|
expect(model.email).to eq('hoge@example.net')
|
154
|
+
expect(model.count).to eq(10)
|
153
155
|
expect(model.list).to eq(Set['a', 'b', 'c'])
|
154
156
|
end
|
155
157
|
end
|
@@ -48,12 +48,27 @@ describe Dymos::Query::Query do
|
|
48
48
|
class TestItem < Dymos::Model
|
49
49
|
table :test_query_item
|
50
50
|
field :id, :string
|
51
|
-
field :other_id, :
|
51
|
+
field :other_id, :integer
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
let(:client) { Aws::DynamoDB::Client.new }
|
56
56
|
describe :put_item do
|
57
|
+
it "ハッシュ+レンジ検索" do
|
58
|
+
items = TestItem.query.key_conditions(
|
59
|
+
id: "== hoge",
|
60
|
+
category_id:"== 0"
|
61
|
+
).execute
|
62
|
+
expect(items.first.id).to eq('hoge')
|
63
|
+
expect(items.first.other_id).to eq(1)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "ハッシュのみ検索" do
|
67
|
+
items = TestItem.query.key_conditions(
|
68
|
+
id: "== hoge"
|
69
|
+
).execute
|
70
|
+
expect(items.length).to eq(6)
|
71
|
+
end
|
57
72
|
describe "クエリ生成" do
|
58
73
|
describe "グローバルセカンダリインデックスを利用した検索" do
|
59
74
|
let(:query) {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dymos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hoshina85
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.0.0
|
117
|
+
version: 2.0.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 2.0.0
|
124
|
+
version: 2.0.0
|
125
125
|
description: aws-sdk-core-ruby dynamodb client wrapper
|
126
126
|
email:
|
127
127
|
- hoshina85@gmail.com
|