dynamini 2.2.3 → 2.2.4

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: 7327a446583484fbedb633d9dcd247c9d93d563f
4
- data.tar.gz: 1a505662583dbfbb6a2a0f2975ce7f6c15d95806
3
+ metadata.gz: 2142757afc1e24fc1ba5e2b4a94ce6b2c78233d1
4
+ data.tar.gz: d4d7db8f6d7cca4b4ce9db53c9cb96b654d5e8e8
5
5
  SHA512:
6
- metadata.gz: 2103f9bfdb4277c7d6c7a2c01c19980cd8c52ac567dab5105a57fcb2af8a4b092f3377cdeb08d582d9bb15b574766c4d76ab07b8943be9bac96d1cd989e7e5bd
7
- data.tar.gz: 15b47f8a2fc609b6f312ea030ec44aec66ac11c70d937fb60d4898fef25580ade46a291246f92cbde1d1def20234a79e57f10760aa3ac7263c7a5b207f6b3ab8
6
+ metadata.gz: f0b6a462b83cf6fbedf57b9461609c93c0365ec464c7375efe52d771b344aa527b01e7987c175dcec1f211b25f99de8e97301270d99cae415d6da685afbc9ade
7
+ data.tar.gz: 554c023d9ff949d396087def3f109954a369de499fd4ed1fb7b4a2f4537ac4d034dda782342337b818e11ded424ae022710406464c8496d79728ebc5ff23323c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dynamini (2.2.3)
4
+ dynamini (2.2.4)
5
5
  activemodel (>= 3, < 5.0)
6
6
  aws-sdk (~> 2)
7
7
 
data/dynamini.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dynamini'
3
- s.version = '2.2.3'
3
+ s.version = '2.2.4'
4
4
  s.summary = 'DynamoDB interface'
5
5
  s.description = 'Lightweight DynamoDB interface gem designed as
6
6
  a drop-in replacement for ActiveRecord.
@@ -114,19 +114,9 @@ module Dynamini
114
114
  hash_key_name, range_key_name = determine_hash_and_range(args)
115
115
 
116
116
  inspect_for_correct_keys?(tokens, hash_key_name, range_key_name)
117
- start_val, end_val = range_key_limits(tokens)
118
117
 
119
- if args[:index_name]
120
- secondary_index_query(args, start_val, end_val)
121
- else
122
- hash_key = hash_key_value(args).is_a?(Integer) ? tokens[2].to_i : tokens[2]
118
+ args[:index_name] ? secondary_index_query(args, tokens) : range_key_query(args, tokens)
123
119
 
124
- parent = get_table(args[:table_name])[hash_key]
125
- return OpenStruct.new(items: []) unless parent
126
- selected = apply_filter_options(parent, args, start_val, end_val)
127
-
128
- OpenStruct.new(items: selected)
129
- end
130
120
  end
131
121
 
132
122
  def determine_hash_and_range(args)
@@ -156,7 +146,19 @@ module Dynamini
156
146
  records
157
147
  end
158
148
 
159
- def secondary_index_query(args = {}, start_val = nil, end_val = nil)
149
+ def range_key_query(args, tokens)
150
+ start_val, end_val = range_key_limits(tokens)
151
+ hash_key = hash_key_value(args).is_a?(Integer) ? tokens[2].to_i : tokens[2]
152
+ parent = get_table(args[:table_name])[hash_key]
153
+
154
+ return OpenStruct.new(items: []) unless parent
155
+
156
+ selected = apply_filter_options(parent, args, start_val, end_val)
157
+ OpenStruct.new(items: selected)
158
+ end
159
+
160
+ def secondary_index_query(args = {}, tokens)
161
+ start_val, end_val = range_key_limits(tokens)
160
162
  index = secondary_index[args[:index_name].to_s]
161
163
  table = get_table(args[:table_name])
162
164
 
@@ -204,25 +206,28 @@ module Dynamini
204
206
  hash_key_value = args[:key][hash_key_attr]
205
207
  range_key_value = args[:key][range_key_attr]
206
208
 
207
- if args[:attribute_updates]
208
- args[:attribute_updates].each do |k, v|
209
- table = get_table(args[:table_name])
209
+ handle_updates(args, hash_key_value, range_key_value, attribute_hash) if args[:attribute_updates]
210
+
211
+ attribute_hash
212
+ end
213
+
214
+ def handle_updates(args, hash_key_value, range_key_value, attribute_hash)
215
+ table = get_table(args[:table_name])
216
+ args[:attribute_updates].each do |k, v|
210
217
 
211
- if v[:action] == 'ADD' && table[hash_key_value]
212
- # if record has been saved
213
- data = table[hash_key_value]
214
- data = (data[range_key_value] ||= {}) if range_key_value
218
+ if v[:action] == 'ADD' && table[hash_key_value]
219
+ # if record has been saved
220
+ data = table[hash_key_value]
221
+ data = (data[range_key_value] ||= {}) if range_key_value
215
222
 
216
- attribute_hash[k] = (v[:value] + data[k].to_f)
217
- else
218
- attribute_hash[k] = v[:value]
219
- end
223
+ attribute_hash[k] = (v[:value] + data[k].to_f)
224
+ else
225
+ attribute_hash[k] = v[:value]
220
226
  end
221
227
  end
222
-
223
- attribute_hash
224
228
  end
225
229
 
230
+
226
231
  def inspect_for_correct_keys?(tokens, hash_key_name, range_key_name)
227
232
  missed_keys = []
228
233
  missed_keys << hash_key_name unless tokens[0] == hash_key_name
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamini
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Ward
@@ -15,110 +15,110 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2016-03-10 00:00:00.000000000 Z
18
+ date: 2016-03-11 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activemodel
22
22
  requirement: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3'
27
- - - <
27
+ - - "<"
28
28
  - !ruby/object:Gem::Version
29
29
  version: '5.0'
30
30
  type: :runtime
31
31
  prerelease: false
32
32
  version_requirements: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - '>='
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
36
  version: '3'
37
- - - <
37
+ - - "<"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '5.0'
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: aws-sdk
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ~>
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '2'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ~>
51
+ - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '2'
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: rspec
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ~>
58
+ - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '3'
61
61
  type: :development
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ~>
65
+ - - "~>"
66
66
  - !ruby/object:Gem::Version
67
67
  version: '3'
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: pry
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ~>
72
+ - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  type: :development
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ~>
79
+ - - "~>"
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: fuubar
84
84
  requirement: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - ~>
86
+ - - "~>"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '2'
89
89
  type: :development
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - ~>
93
+ - - "~>"
94
94
  - !ruby/object:Gem::Version
95
95
  version: '2'
96
96
  - !ruby/object:Gem::Dependency
97
97
  name: guard-rspec
98
98
  requirement: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - '>='
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  type: :development
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - '>='
107
+ - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: guard-shell
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - '>='
114
+ - - ">="
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  type: :development
118
118
  prerelease: false
119
119
  version_requirements: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - '>='
121
+ - - ">="
122
122
  - !ruby/object:Gem::Version
123
123
  version: '0'
124
124
  description: |-
@@ -130,9 +130,9 @@ executables: []
130
130
  extensions: []
131
131
  extra_rdoc_files: []
132
132
  files:
133
- - .gitignore
134
- - .rspec
135
- - .travis.yml
133
+ - ".gitignore"
134
+ - ".rspec"
135
+ - ".travis.yml"
136
136
  - Gemfile
137
137
  - Gemfile.lock
138
138
  - Guardfile
@@ -170,17 +170,17 @@ require_paths:
170
170
  - lib
171
171
  required_ruby_version: !ruby/object:Gem::Requirement
172
172
  requirements:
173
- - - '>='
173
+ - - ">="
174
174
  - !ruby/object:Gem::Version
175
175
  version: '0'
176
176
  required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - '>='
178
+ - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  requirements: []
182
182
  rubyforge_project:
183
- rubygems_version: 2.2.2
183
+ rubygems_version: 2.4.6
184
184
  signing_key:
185
185
  specification_version: 4
186
186
  summary: DynamoDB interface