dinamo 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9236c52dc01154fdf5f115443a79d207c9f3777
4
- data.tar.gz: 3f14b1b5ab4d34b35a1f7ffefd6702cf2f113d04
3
+ metadata.gz: 168e2619c68ffd62c9aa90d7bf8ca088ad5dfb8b
4
+ data.tar.gz: 557bf6d283cf1e051b32661b613627a071bede89
5
5
  SHA512:
6
- metadata.gz: 857e718c30243a71349767f0d72255d0a73dfc4eeef4c4259c76de7d2b9bc62a1777cf4f937b1881f5dbd735a216d79465f4782a012bf117d7b7602621ddf317
7
- data.tar.gz: ecde0c36408095d0874c6e3e3399331b6eb3f413f262947cd25460a8055bc8ec5de760604e0b586bdb6406a2fb6113443f41b4218ce0775a338317129df0d2bc
6
+ metadata.gz: 8f2506cb2a7677a2f7fb91344be03a23a144ce0325f0993e893b169167bfa3499ff5f0c10c250702598278e3219883c563cfc6d0f09209a25d4d5276b820804a
7
+ data.tar.gz: 4a36b578ef4574baaa37aae8506bb0253a5347cf6ba94aaf703bc5ae8e93562068602f1b2ce5b73f3f0bf31a4dfb3bbf282e68ef99ce2c9f144c4cffef6b059d
data/.travis.yml CHANGED
@@ -2,3 +2,11 @@ language: ruby
2
2
  rvm:
3
3
  - 2.2.3
4
4
  before_install: gem install bundler -v 1.10.6
5
+ install:
6
+ - mkdir /tmp/dynamodb
7
+ - wget -O - http://dynamodb-local.s3-website-us-west-2.amazonaws.com/dynamodb_local_latest | tar xz --directory /tmp/dynamodb
8
+ before_script:
9
+ - java -Djava.library.path=/tmp/dynamodb/DynamoDBLocal_lib -jar /tmp/dynamodb/DynamoDBLocal.jar -sharedDb -inMemory &
10
+ - sleep 2
11
+ - bundle update
12
+ cache: bundler
@@ -26,6 +26,15 @@ module Dinamo
26
26
  handle_error! $!
27
27
  end
28
28
 
29
+ def partition(conditions)
30
+ @database.query(
31
+ table_name: @table_name,
32
+ key_conditions: make_key_conditions(**conditions)
33
+ )
34
+ rescue
35
+ handle_error! $!
36
+ end
37
+
29
38
  def insert(**keys)
30
39
  @database.put_item(
31
40
  table_name: @table_name,
@@ -85,5 +94,14 @@ module Dinamo
85
94
  fail evar, evar.message
86
95
  end
87
96
  end
97
+
98
+ def make_key_conditions(**conditions)
99
+ conditions.each_with_object({}) do |(key, val), serialized|
100
+ serialized[key.to_s] = {
101
+ attribute_value_list: val === Array ? val : Array(val),
102
+ comparison_operator: "EQ"
103
+ }
104
+ end
105
+ end
88
106
  end
89
107
  end
@@ -22,6 +22,21 @@ module Dinamo
22
22
  object
23
23
  end
24
24
 
25
+ def partition(**conditions)
26
+ partition!(**conditions) rescue nil
27
+ end
28
+
29
+ def partition!(**conditions)
30
+ items = adapter.partition(**conditions).items
31
+ fail Exceptions::RecordNotFoundError,
32
+ "Corresponding record (%p) can not be found" % conditions if items.empty?
33
+ items.map do |item|
34
+ object = new(**symbolize(item))
35
+ object.new_record = false
36
+ object
37
+ end
38
+ end
39
+
25
40
  def exist?(**keys)
26
41
  adapter.exist?(**keys)
27
42
  end
@@ -72,7 +87,7 @@ module Dinamo
72
87
  end
73
88
 
74
89
  def destroyed?
75
- @destroyed
90
+ !!@destroyed
76
91
  end
77
92
 
78
93
  def persisted?
@@ -1,3 +1,3 @@
1
1
  module Dinamo
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dinamo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - namusyaka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-08 00:00:00.000000000 Z
11
+ date: 2016-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.2.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.2.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: aws-sdk
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.1.26
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.1.26
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.10'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.10'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '10.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '10.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: test-unit
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: test-unit-rr
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: test-unit-power_assert
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: DynamoDB ORM for Ruby
@@ -115,9 +115,9 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
- - ".gitignore"
119
- - ".rspec"
120
- - ".travis.yml"
118
+ - .gitignore
119
+ - .rspec
120
+ - .travis.yml
121
121
  - CODE_OF_CONDUCT.md
122
122
  - Gemfile
123
123
  - LICENSE.txt
@@ -150,17 +150,17 @@ require_paths:
150
150
  - lib
151
151
  required_ruby_version: !ruby/object:Gem::Requirement
152
152
  requirements:
153
- - - ">="
153
+ - - '>='
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
156
  required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - ">="
158
+ - - '>='
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  requirements: []
162
162
  rubyforge_project:
163
- rubygems_version: 2.5.1
163
+ rubygems_version: 2.0.14.1
164
164
  signing_key:
165
165
  specification_version: 4
166
166
  summary: DynamoDB ORM for Ruby