dymos 0.0.8 → 0.0.9

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: bcc2ca53b227af59529709c865fbec440d59b561
4
- data.tar.gz: ae44901535497e1e3c0d771aa89167c82659d9fb
3
+ metadata.gz: bf372b964ae4ad9a7daf6fce92ec70b57350b50a
4
+ data.tar.gz: 1f5f8471eeb4e88db89fcb64a801249f8084377f
5
5
  SHA512:
6
- metadata.gz: 163fafcafb4f7d3b9501a85a39f209aa5bf003af6cb7eb9d262178fca672d4b2a6d953dd0cd1b162678bde892f7eb73ce8f182928fa0fd2722f989b01f1a436d
7
- data.tar.gz: c2e1d1b19404ec4fc4d94575393eea33841c32b67b19d8e5913df4c2253ac1c2a2b6b76ced15cca79459ff49207ff3c0e78fac002f3953c0dbb500deadc01b60
6
+ metadata.gz: 8dfe884a6015ca023dfcba429f5cecbf9c1a3a95ff7afff42f177d561e50526ba81fd692b2aa700b8784d5152f32db9a86ef36f15a5dbd4f3a1c37ee207e4791
7
+ data.tar.gz: 0265d0d9a54599f0ce3158b47eea72cf54b8b3a1740935b64024d9cd1a3bbb1469d321e687a092454ad9d77dec34e5314a2a24b5af26deb68d065babb0ccef3c
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "timecop"
27
27
  spec.add_development_dependency "activemodel", '~> 4.1.5'
28
28
 
29
- spec.add_dependency "aws-sdk-core", "2.0.0.rc15"
29
+ spec.add_dependency "aws-sdk-core", "2.0.0"
30
30
  end
@@ -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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Dymos
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -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
- table_name: 'dummy',
39
- attribute_definitions: [
40
- {attribute_name: 'id', attribute_type: 'S'}
41
- ],
42
- key_schema: [
43
- {attribute_name: 'id', key_type: 'HASH'}
44
- ],
45
- provisioned_throughput: {
46
- read_capacity_units: 1,
47
- write_capacity_units: 1,
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
- table_name: 'post',
57
- attribute_definitions: [
58
- {attribute_name: 'id', attribute_type: 'S'},
59
- {attribute_name: 'timestamp', attribute_type: 'N'},
60
- ],
61
- key_schema: [
62
- {attribute_name: 'id', key_type: 'HASH'},
63
- {attribute_name: 'timestamp', key_type: 'RANGE'},
64
- ],
65
- provisioned_throughput: {
66
- read_capacity_units: 1,
67
- write_capacity_units: 1,
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, :number
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.8
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-09-24 00:00:00.000000000 Z
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.rc15
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.rc15
124
+ version: 2.0.0
125
125
  description: aws-sdk-core-ruby dynamodb client wrapper
126
126
  email:
127
127
  - hoshina85@gmail.com