dynamoid 2.2.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +53 -0
  3. data/.rubocop_todo.yml +55 -0
  4. data/.travis.yml +5 -27
  5. data/Appraisals +17 -15
  6. data/CHANGELOG.md +26 -3
  7. data/Gemfile +4 -2
  8. data/README.md +95 -77
  9. data/Rakefile +17 -17
  10. data/Vagrantfile +5 -3
  11. data/dynamoid.gemspec +39 -45
  12. data/gemfiles/rails_4_2.gemfile +7 -5
  13. data/gemfiles/rails_5_0.gemfile +6 -4
  14. data/gemfiles/rails_5_1.gemfile +6 -4
  15. data/gemfiles/rails_5_2.gemfile +6 -4
  16. data/lib/dynamoid.rb +11 -4
  17. data/lib/dynamoid/adapter.rb +21 -27
  18. data/lib/dynamoid/adapter_plugin/{aws_sdk_v2.rb → aws_sdk_v3.rb} +118 -113
  19. data/lib/dynamoid/application_time_zone.rb +27 -0
  20. data/lib/dynamoid/associations.rb +3 -6
  21. data/lib/dynamoid/associations/association.rb +3 -6
  22. data/lib/dynamoid/associations/belongs_to.rb +4 -5
  23. data/lib/dynamoid/associations/has_and_belongs_to_many.rb +2 -3
  24. data/lib/dynamoid/associations/has_many.rb +2 -3
  25. data/lib/dynamoid/associations/has_one.rb +2 -3
  26. data/lib/dynamoid/associations/many_association.rb +8 -9
  27. data/lib/dynamoid/associations/single_association.rb +3 -3
  28. data/lib/dynamoid/components.rb +2 -2
  29. data/lib/dynamoid/config.rb +9 -5
  30. data/lib/dynamoid/config/backoff_strategies/constant_backoff.rb +4 -2
  31. data/lib/dynamoid/config/backoff_strategies/exponential_backoff.rb +3 -1
  32. data/lib/dynamoid/config/options.rb +4 -4
  33. data/lib/dynamoid/criteria.rb +3 -5
  34. data/lib/dynamoid/criteria/chain.rb +42 -49
  35. data/lib/dynamoid/dirty.rb +5 -4
  36. data/lib/dynamoid/document.rb +142 -36
  37. data/lib/dynamoid/dumping.rb +167 -0
  38. data/lib/dynamoid/dynamodb_time_zone.rb +16 -0
  39. data/lib/dynamoid/errors.rb +7 -6
  40. data/lib/dynamoid/fields.rb +24 -23
  41. data/lib/dynamoid/finders.rb +101 -59
  42. data/lib/dynamoid/identity_map.rb +5 -11
  43. data/lib/dynamoid/indexes.rb +45 -46
  44. data/lib/dynamoid/middleware/identity_map.rb +2 -0
  45. data/lib/dynamoid/persistence.rb +67 -307
  46. data/lib/dynamoid/primary_key_type_mapping.rb +34 -0
  47. data/lib/dynamoid/railtie.rb +3 -1
  48. data/lib/dynamoid/tasks/database.rake +11 -11
  49. data/lib/dynamoid/tasks/database.rb +4 -3
  50. data/lib/dynamoid/type_casting.rb +193 -0
  51. data/lib/dynamoid/undumping.rb +188 -0
  52. data/lib/dynamoid/validations.rb +4 -7
  53. data/lib/dynamoid/version.rb +3 -1
  54. metadata +59 -53
  55. data/gemfiles/rails_4_0.gemfile +0 -9
  56. data/gemfiles/rails_4_1.gemfile +0 -9
@@ -1,6 +1,6 @@
1
- # encoding: utf-8
2
- module Dynamoid
1
+ # frozen_string_literal: true
3
2
 
3
+ module Dynamoid
4
4
  # Provide ActiveModel validations to Dynamoid documents.
5
5
  module Validations
6
6
  extend ActiveSupport::Concern
@@ -13,7 +13,7 @@ module Dynamoid
13
13
  # @since 0.2.0
14
14
  def save(options = {})
15
15
  options.reverse_merge!(validate: true)
16
- return false if options[:validate] and (not valid?)
16
+ return false if options[:validate] && !valid?
17
17
  super
18
18
  end
19
19
 
@@ -29,13 +29,12 @@ module Dynamoid
29
29
  #
30
30
  # @since 0.2.0
31
31
  def save!
32
- raise Dynamoid::Errors::DocumentNotValid.new(self) unless valid?
32
+ raise Dynamoid::Errors::DocumentNotValid, self unless valid?
33
33
  save(validate: false)
34
34
  self
35
35
  end
36
36
 
37
37
  module ClassMethods
38
-
39
38
  # Override validates_presence_of to handle false values as present.
40
39
  #
41
40
  # @since 1.1.1
@@ -43,8 +42,6 @@ module Dynamoid
43
42
  validates_with PresenceValidator, _merge_attributes(attr_names)
44
43
  end
45
44
 
46
- private
47
-
48
45
  # Validates that the specified attributes are present (false or not blank).
49
46
  class PresenceValidator < ActiveModel::EachValidator
50
47
  # Validate the record for the record and value.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dynamoid
2
- VERSION = '2.2.0'
4
+ VERSION = '3.0.0'
3
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Symonds
@@ -21,7 +21,7 @@ authors:
21
21
  autorequire:
22
22
  bindir: exe
23
23
  cert_chain: []
24
- date: 2018-05-02 00:00:00.000000000 Z
24
+ date: 2018-09-23 00:00:00.000000000 Z
25
25
  dependencies:
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: activemodel
@@ -38,49 +38,49 @@ dependencies:
38
38
  - !ruby/object:Gem::Version
39
39
  version: '4'
40
40
  - !ruby/object:Gem::Dependency
41
- name: activesupport
41
+ name: aws-sdk-dynamodb
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '4'
47
- type: :development
46
+ version: '1'
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
- version: '4'
53
+ version: '1'
54
54
  - !ruby/object:Gem::Dependency
55
- name: aws-sdk-resources
55
+ name: concurrent-ruby
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: '2'
60
+ version: '1.0'
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: '2'
67
+ version: '1.0'
68
68
  - !ruby/object:Gem::Dependency
69
- name: concurrent-ruby
69
+ name: appraisal
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: '1.0'
75
- type: :runtime
74
+ version: '0'
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
- version: '1.0'
81
+ version: '0'
82
82
  - !ruby/object:Gem::Dependency
83
- name: pry
83
+ name: bundler
84
84
  requirement: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="
@@ -94,77 +94,77 @@ dependencies:
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
96
  - !ruby/object:Gem::Dependency
97
- name: bundler
97
+ name: coveralls
98
98
  requirement: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - "~>"
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: '1.14'
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
- version: '1.14'
109
+ version: '0'
110
110
  - !ruby/object:Gem::Dependency
111
- name: rake
111
+ name: pry
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - "~>"
114
+ - - ">="
115
115
  - !ruby/object:Gem::Version
116
- version: '12.0'
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
- version: '12.0'
123
+ version: '0'
124
124
  - !ruby/object:Gem::Dependency
125
- name: rspec
125
+ name: rake
126
126
  requirement: !ruby/object:Gem::Requirement
127
127
  requirements:
128
- - - "~>"
128
+ - - ">="
129
129
  - !ruby/object:Gem::Version
130
- version: '3.0'
130
+ version: '0'
131
131
  type: :development
132
132
  prerelease: false
133
133
  version_requirements: !ruby/object:Gem::Requirement
134
134
  requirements:
135
- - - "~>"
135
+ - - ">="
136
136
  - !ruby/object:Gem::Version
137
- version: '3.0'
137
+ version: '0'
138
138
  - !ruby/object:Gem::Dependency
139
- name: appraisal
139
+ name: rspec
140
140
  requirement: !ruby/object:Gem::Requirement
141
141
  requirements:
142
- - - "~>"
142
+ - - ">="
143
143
  - !ruby/object:Gem::Version
144
- version: '2.1'
144
+ version: '0'
145
145
  type: :development
146
146
  prerelease: false
147
147
  version_requirements: !ruby/object:Gem::Requirement
148
148
  requirements:
149
- - - "~>"
149
+ - - ">="
150
150
  - !ruby/object:Gem::Version
151
- version: '2.1'
151
+ version: '0'
152
152
  - !ruby/object:Gem::Dependency
153
- name: wwtd
153
+ name: rubocop
154
154
  requirement: !ruby/object:Gem::Requirement
155
155
  requirements:
156
- - - "~>"
156
+ - - ">="
157
157
  - !ruby/object:Gem::Version
158
- version: '1.3'
158
+ version: '0'
159
159
  type: :development
160
160
  prerelease: false
161
161
  version_requirements: !ruby/object:Gem::Requirement
162
162
  requirements:
163
- - - "~>"
163
+ - - ">="
164
164
  - !ruby/object:Gem::Version
165
- version: '1.3'
165
+ version: '0'
166
166
  - !ruby/object:Gem::Dependency
167
- name: yard
167
+ name: wwtd
168
168
  requirement: !ruby/object:Gem::Requirement
169
169
  requirements:
170
170
  - - ">="
@@ -178,19 +178,19 @@ dependencies:
178
178
  - !ruby/object:Gem::Version
179
179
  version: '0'
180
180
  - !ruby/object:Gem::Dependency
181
- name: coveralls
181
+ name: yard
182
182
  requirement: !ruby/object:Gem::Requirement
183
183
  requirements:
184
- - - "~>"
184
+ - - ">="
185
185
  - !ruby/object:Gem::Version
186
- version: '0.8'
186
+ version: '0'
187
187
  type: :development
188
188
  prerelease: false
189
189
  version_requirements: !ruby/object:Gem::Requirement
190
190
  requirements:
191
- - - "~>"
191
+ - - ">="
192
192
  - !ruby/object:Gem::Version
193
- version: '0.8'
193
+ version: '0'
194
194
  description: Dynamoid is an ORM for Amazon's DynamoDB that supports offline development,
195
195
  associations, querying, and everything else you'd expect from an ActiveRecord-style
196
196
  replacement.
@@ -207,6 +207,8 @@ files:
207
207
  - ".document"
208
208
  - ".gitignore"
209
209
  - ".rspec"
210
+ - ".rubocop.yml"
211
+ - ".rubocop_todo.yml"
210
212
  - ".travis.yml"
211
213
  - Appraisals
212
214
  - CHANGELOG.md
@@ -217,15 +219,14 @@ files:
217
219
  - Vagrantfile
218
220
  - docker-compose.yml
219
221
  - dynamoid.gemspec
220
- - gemfiles/rails_4_0.gemfile
221
- - gemfiles/rails_4_1.gemfile
222
222
  - gemfiles/rails_4_2.gemfile
223
223
  - gemfiles/rails_5_0.gemfile
224
224
  - gemfiles/rails_5_1.gemfile
225
225
  - gemfiles/rails_5_2.gemfile
226
226
  - lib/dynamoid.rb
227
227
  - lib/dynamoid/adapter.rb
228
- - lib/dynamoid/adapter_plugin/aws_sdk_v2.rb
228
+ - lib/dynamoid/adapter_plugin/aws_sdk_v3.rb
229
+ - lib/dynamoid/application_time_zone.rb
229
230
  - lib/dynamoid/associations.rb
230
231
  - lib/dynamoid/associations/association.rb
231
232
  - lib/dynamoid/associations/belongs_to.rb
@@ -243,6 +244,8 @@ files:
243
244
  - lib/dynamoid/criteria/chain.rb
244
245
  - lib/dynamoid/dirty.rb
245
246
  - lib/dynamoid/document.rb
247
+ - lib/dynamoid/dumping.rb
248
+ - lib/dynamoid/dynamodb_time_zone.rb
246
249
  - lib/dynamoid/errors.rb
247
250
  - lib/dynamoid/fields.rb
248
251
  - lib/dynamoid/finders.rb
@@ -250,9 +253,12 @@ files:
250
253
  - lib/dynamoid/indexes.rb
251
254
  - lib/dynamoid/middleware/identity_map.rb
252
255
  - lib/dynamoid/persistence.rb
256
+ - lib/dynamoid/primary_key_type_mapping.rb
253
257
  - lib/dynamoid/railtie.rb
254
258
  - lib/dynamoid/tasks/database.rake
255
259
  - lib/dynamoid/tasks/database.rb
260
+ - lib/dynamoid/type_casting.rb
261
+ - lib/dynamoid/undumping.rb
256
262
  - lib/dynamoid/validations.rb
257
263
  - lib/dynamoid/version.rb
258
264
  homepage: http://github.com/Dynamoid/Dynamoid
@@ -275,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
275
281
  version: '0'
276
282
  requirements: []
277
283
  rubyforge_project:
278
- rubygems_version: 2.4.5
284
+ rubygems_version: 2.6.14
279
285
  signing_key:
280
286
  specification_version: 4
281
287
  summary: Dynamoid is an ORM for Amazon's DynamoDB
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "pry-byebug", platforms: :ruby
6
- gem "rails", "~> 4.0.0"
7
- gem "nokogiri", "~> 1.6.8"
8
-
9
- gemspec path: "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "pry-byebug", platforms: :ruby
6
- gem "rails", "~> 4.1.0"
7
- gem "nokogiri", "~> 1.6.8"
8
-
9
- gemspec path: "../"