dynamoid 3.3.0 → 3.7.0

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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +104 -1
  3. data/README.md +146 -52
  4. data/lib/dynamoid.rb +1 -0
  5. data/lib/dynamoid/adapter.rb +20 -7
  6. data/lib/dynamoid/adapter_plugin/aws_sdk_v3.rb +70 -37
  7. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/batch_get_item.rb +3 -0
  8. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/create_table.rb +20 -12
  9. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/item_updater.rb +5 -4
  10. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/middleware/backoff.rb +2 -2
  11. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/middleware/limit.rb +2 -3
  12. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/middleware/start_key.rb +2 -2
  13. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/query.rb +4 -2
  14. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/scan.rb +4 -2
  15. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb +1 -0
  16. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/until_past_table_status.rb +2 -1
  17. data/lib/dynamoid/application_time_zone.rb +1 -0
  18. data/lib/dynamoid/associations.rb +182 -19
  19. data/lib/dynamoid/associations/association.rb +10 -2
  20. data/lib/dynamoid/associations/belongs_to.rb +2 -1
  21. data/lib/dynamoid/associations/has_and_belongs_to_many.rb +2 -1
  22. data/lib/dynamoid/associations/has_many.rb +2 -1
  23. data/lib/dynamoid/associations/has_one.rb +2 -1
  24. data/lib/dynamoid/associations/many_association.rb +68 -23
  25. data/lib/dynamoid/associations/single_association.rb +31 -4
  26. data/lib/dynamoid/components.rb +2 -0
  27. data/lib/dynamoid/config.rb +15 -3
  28. data/lib/dynamoid/config/backoff_strategies/constant_backoff.rb +1 -0
  29. data/lib/dynamoid/config/backoff_strategies/exponential_backoff.rb +1 -0
  30. data/lib/dynamoid/config/options.rb +1 -0
  31. data/lib/dynamoid/criteria.rb +9 -1
  32. data/lib/dynamoid/criteria/chain.rb +421 -46
  33. data/lib/dynamoid/criteria/ignored_conditions_detector.rb +3 -3
  34. data/lib/dynamoid/criteria/key_fields_detector.rb +31 -10
  35. data/lib/dynamoid/criteria/nonexistent_fields_detector.rb +3 -2
  36. data/lib/dynamoid/criteria/overwritten_conditions_detector.rb +1 -1
  37. data/lib/dynamoid/dirty.rb +119 -64
  38. data/lib/dynamoid/document.rb +133 -46
  39. data/lib/dynamoid/dumping.rb +9 -0
  40. data/lib/dynamoid/dynamodb_time_zone.rb +1 -0
  41. data/lib/dynamoid/errors.rb +2 -0
  42. data/lib/dynamoid/fields.rb +251 -39
  43. data/lib/dynamoid/fields/declare.rb +86 -0
  44. data/lib/dynamoid/finders.rb +69 -32
  45. data/lib/dynamoid/identity_map.rb +6 -0
  46. data/lib/dynamoid/indexes.rb +86 -17
  47. data/lib/dynamoid/loadable.rb +2 -2
  48. data/lib/dynamoid/log/formatter.rb +26 -0
  49. data/lib/dynamoid/middleware/identity_map.rb +1 -0
  50. data/lib/dynamoid/persistence.rb +502 -104
  51. data/lib/dynamoid/persistence/import.rb +2 -1
  52. data/lib/dynamoid/persistence/save.rb +1 -0
  53. data/lib/dynamoid/persistence/update_fields.rb +5 -2
  54. data/lib/dynamoid/persistence/update_validations.rb +18 -0
  55. data/lib/dynamoid/persistence/upsert.rb +5 -3
  56. data/lib/dynamoid/primary_key_type_mapping.rb +1 -0
  57. data/lib/dynamoid/railtie.rb +1 -0
  58. data/lib/dynamoid/tasks.rb +3 -1
  59. data/lib/dynamoid/tasks/database.rb +1 -0
  60. data/lib/dynamoid/type_casting.rb +12 -2
  61. data/lib/dynamoid/undumping.rb +8 -0
  62. data/lib/dynamoid/validations.rb +6 -1
  63. data/lib/dynamoid/version.rb +1 -1
  64. metadata +48 -75
  65. data/.coveralls.yml +0 -1
  66. data/.document +0 -5
  67. data/.gitignore +0 -74
  68. data/.rspec +0 -2
  69. data/.rubocop.yml +0 -71
  70. data/.rubocop_todo.yml +0 -55
  71. data/.travis.yml +0 -44
  72. data/Appraisals +0 -22
  73. data/Gemfile +0 -8
  74. data/Rakefile +0 -46
  75. data/Vagrantfile +0 -29
  76. data/docker-compose.yml +0 -7
  77. data/dynamoid.gemspec +0 -57
  78. data/gemfiles/rails_4_2.gemfile +0 -9
  79. data/gemfiles/rails_5_0.gemfile +0 -8
  80. data/gemfiles/rails_5_1.gemfile +0 -8
  81. data/gemfiles/rails_5_2.gemfile +0 -8
  82. data/gemfiles/rails_6_0.gemfile +0 -8
data/.coveralls.yml DELETED
@@ -1 +0,0 @@
1
- service_name: travis-ci
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/.gitignore DELETED
@@ -1,74 +0,0 @@
1
- .project
2
-
3
- # rcov generated
4
- coverage
5
-
6
- # rdoc generated
7
- rdoc
8
-
9
- # yardoc generated
10
- .yardoc
11
- /_yardoc/
12
-
13
- # bundler
14
- /.bundle/
15
-
16
- # jeweler generated
17
- /pkg/
18
-
19
- # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
20
- #
21
- # * Create a file at ~/.gitignore
22
- # * Include files you want ignored
23
- # * Run: git config --global core.excludesfile ~/.gitignore
24
- #
25
- # After doing this, these files will be ignored in all your git projects,
26
- # saving you from having to 'pollute' every project you touch with them
27
- #
28
- # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
29
- #
30
- # For MacOS:
31
- #
32
- #.DS_Store
33
-
34
- # For TextMate
35
- #*.tmproj
36
- #tmtags
37
-
38
- # For emacs:
39
- #*~
40
- #\#*
41
- #.\#*
42
-
43
- # For vim:
44
- #*.swp
45
-
46
- # For redcar:
47
- #.redcar
48
-
49
- # For rubinius:
50
- #*.rbc
51
-
52
- # for RVM
53
- .rvmrc
54
-
55
- # For RubyMine:
56
- /.idea/
57
-
58
- # For Ctags
59
- .gemtags
60
- .tags
61
- .tags_sorted_by_file
62
-
63
- Gemfile.lock
64
- /doc/
65
- /spec/reports/
66
- /tmp/
67
- /spec/DynamoDBLocal-latest/
68
- /vendor/
69
-
70
- # For vagrant
71
- .vagrant
72
-
73
- # For Appraisals
74
- gemfiles/*.gemfile.lock
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
data/.rubocop.yml DELETED
@@ -1,71 +0,0 @@
1
- # We chose not to make these changes
2
- inherit_from: .rubocop_todo.yml
3
-
4
- # It's the lowest supported Ruby version
5
- AllCops:
6
- TargetRubyVersion: 2.3
7
-
8
- # It's a matter of taste
9
- Layout/AlignParameters:
10
- EnforcedStyle: with_fixed_indentation
11
- Layout/AlignHash:
12
- Enabled: false
13
- Style/GuardClause:
14
- Enabled: false
15
- Style/FormatStringToken:
16
- Enabled: false
17
- Style/DoubleNegation:
18
- Enabled: false
19
- Style/IfUnlessModifier:
20
- Enabled: false
21
- Style/EachWithObject:
22
- Enabled: false
23
- Style/SafeNavigation:
24
- Enabled: false
25
- Style/BlockDelimiters:
26
- Enabled: false
27
- Layout/MultilineMethodCallIndentation:
28
- EnforcedStyle: indented
29
- Naming/VariableNumber:
30
- Enabled: false
31
- Style/MultilineBlockChain:
32
- Enabled: false
33
-
34
- # We aren't so brave to tackle all these issues right now
35
- Metrics/LineLength:
36
- Enabled: false
37
- Metrics/BlockLength:
38
- Enabled: false
39
- Metrics/MethodLength:
40
- Enabled: false
41
- Metrics/CyclomaticComplexity:
42
- Enabled: false
43
- Metrics/AbcSize:
44
- Enabled: false
45
- Metrics/ModuleLength:
46
- Enabled: false
47
- Metrics/BlockNesting:
48
- Enabled: false
49
- Metrics/PerceivedComplexity:
50
- Enabled: false
51
- Metrics/ClassLength:
52
- Enabled: false
53
-
54
- # Minor annoying issues
55
- Lint/UselessAssignment:
56
- Enabled: false
57
- Lint/AmbiguousBlockAssociation:
58
- Enabled: false
59
- Lint/AssignmentInCondition:
60
- Enabled: false
61
- Style/Documentation:
62
- Enabled: false
63
- Style/DateTime:
64
- Enabled: false
65
- Style/MissingRespondToMissing:
66
- Enabled: false
67
- Naming/PredicateName:
68
- Enabled: false
69
- Security/YAMLLoad:
70
- Enabled: false
71
-
data/.rubocop_todo.yml DELETED
@@ -1,55 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2018-06-18 22:26:49 +0300 using RuboCop version 0.57.2.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 2
10
- Lint/HandleExceptions:
11
- Exclude:
12
- - 'lib/dynamoid/document.rb'
13
-
14
- # Offense count: 1
15
- # Cop supports --auto-correct.
16
- Security/YAMLLoad:
17
- Exclude:
18
- - 'lib/dynamoid/persistence.rb'
19
-
20
- # Offense count: 1
21
- # Cop supports --auto-correct.
22
- # Configuration parameters: EnforcedStyle.
23
- # SupportedStyles: braces, no_braces, context_dependent
24
- Style/BracesAroundHashParameters:
25
- Exclude:
26
- - 'spec/dynamoid/adapter_plugin/aws_sdk_v3_spec.rb'
27
-
28
- # Offense count: 2
29
- # Cop supports --auto-correct.
30
- # Configuration parameters: EnforcedStyle.
31
- # SupportedStyles: module_function, extend_self
32
- Style/ModuleFunction:
33
- Exclude:
34
- - 'lib/dynamoid.rb'
35
- - 'lib/dynamoid/config.rb'
36
-
37
- # Offense count: 1
38
- Style/OptionalArguments:
39
- Exclude:
40
- - 'lib/dynamoid/document.rb'
41
-
42
- # Offense count: 1
43
- # Cop supports --auto-correct.
44
- # Configuration parameters: AllowAsExpressionSeparator.
45
- Style/Semicolon:
46
- Exclude:
47
- - 'spec/dynamoid/adapter_plugin/aws_sdk_v3_spec.rb'
48
-
49
- # Offense count: 1
50
- # Cop supports --auto-correct.
51
- # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
52
- # Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym
53
- Style/TrivialAccessors:
54
- Exclude:
55
- - 'lib/dynamoid/adapter_plugin/aws_sdk_v3.rb'
data/.travis.yml DELETED
@@ -1,44 +0,0 @@
1
- sudo: required
2
-
3
- language: ruby
4
- rvm:
5
- - ruby-2.3.8
6
- - ruby-2.4.6
7
- - ruby-2.5.5
8
- - ruby-2.6.3
9
- - jruby-9.2.8.0
10
- gemfile:
11
- - gemfiles/rails_4_2.gemfile
12
- - gemfiles/rails_5_0.gemfile
13
- - gemfiles/rails_5_1.gemfile
14
- - gemfiles/rails_5_2.gemfile
15
-
16
- matrix:
17
- include:
18
- - rvm: ruby-2.6.3
19
- gemfile: gemfiles/rails_6_0.gemfile
20
-
21
- ### BUILD LIFECYCLE STEPS ###
22
-
23
- before_install:
24
- # Debugging: Print out the current docker-compose version.
25
- - docker-compose --version
26
-
27
- # If one of your containers does not build for
28
- # whatever reason it's best to report that now before your tests start
29
- # otherwise it can be really tricky to debug why tests are failing sometimes.
30
- - docker ps
31
-
32
- after_install:
33
- - gem install bundler -v 1.16.2
34
- - bundle install
35
-
36
- before_script:
37
- # Start Docker Compose as a daemon
38
- - docker-compose up -d
39
-
40
- script:
41
- - bundle exec rake spec
42
-
43
- after_script:
44
- - docker-compose down
data/Appraisals DELETED
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- appraise 'rails-4-2' do
4
- gem 'activemodel', '~> 4.2.0'
5
- gem 'nokogiri', '~> 1.6.8' # can be removed once we drop support for Ruby 2.0.0
6
- end
7
-
8
- appraise 'rails-5-0' do
9
- gem 'activemodel', '~> 5.0.0'
10
- end
11
-
12
- appraise 'rails-5-1' do
13
- gem 'activemodel', '~> 5.1.0'
14
- end
15
-
16
- appraise 'rails-5-2' do
17
- gem 'activemodel', '~> 5.2.0'
18
- end
19
-
20
- appraise 'rails-6-0' do
21
- gem 'activemodel', '6.0.0.rc1'
22
- end
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in dynamoid.gemspec
6
- gemspec
7
-
8
- gem 'pry-byebug', platforms: :ruby
data/Rakefile DELETED
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
-
5
- require 'bundler/setup'
6
- begin
7
- Bundler.setup(:default, :development)
8
- rescue Bundler::BundlerError => e
9
- warn e.message
10
- warn 'Run `bundle install` to install missing gems'
11
- exit e.status_code
12
- end
13
- load './lib/dynamoid/tasks/database.rake' if defined?(Rails)
14
-
15
- require 'rake'
16
- require 'rspec/core/rake_task'
17
- RSpec::Core::RakeTask.new(:spec) do |spec|
18
- spec.pattern = FileList['spec/**/*_spec.rb']
19
- end
20
-
21
- require 'yard'
22
- YARD::Rake::YardocTask.new do |t|
23
- t.files = ['lib/**/*.rb', 'README', 'LICENSE'] # optional
24
- t.options = ['-m', 'markdown'] # optional
25
- end
26
-
27
- desc 'Publish documentation to gh-pages'
28
- task :publish do
29
- Rake::Task['yard'].invoke
30
- `git add .`
31
- `git commit -m 'Regenerated documentation'`
32
- `git checkout gh-pages`
33
- `git clean -fdx`
34
- `git checkout master -- doc`
35
- `cp -R doc/* .`
36
- `git rm -rf doc/`
37
- `git add .`
38
- `git commit -m 'Regenerated documentation'`
39
- `git pull`
40
- `git push`
41
- `git checkout master`
42
- end
43
-
44
- require 'wwtd/tasks'
45
-
46
- task default: :spec
data/Vagrantfile DELETED
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Vagrant.configure('2') do |config|
4
- # Choose base box
5
- config.vm.box = 'bento/ubuntu-18.04'
6
-
7
- config.vm.provider 'virtualbox' do |vb|
8
- # Prevent clock skew when host goes to sleep while VM is running
9
- vb.customize ['guestproperty', 'set', :id, '/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold', 10_000]
10
-
11
- vb.cpus = 2
12
- vb.memory = 2048
13
- end
14
-
15
- # Defaults
16
- config.vm.provision :salt do |salt|
17
- salt.masterless = true
18
- salt.minion_config = '.dev/vagrant/minion'
19
-
20
- # Pillars
21
- salt.pillar(
22
- 'ruby' => {
23
- 'version' => '2.6.2'
24
- }
25
- )
26
-
27
- salt.run_highstate = true
28
- end
29
- end
data/docker-compose.yml DELETED
@@ -1,7 +0,0 @@
1
- version: '2'
2
-
3
- services:
4
- dynamodb:
5
- image: amazon/dynamodb-local
6
- ports:
7
- - 8000:8000
data/dynamoid.gemspec DELETED
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'dynamoid/version'
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = 'dynamoid'
9
- spec.version = Dynamoid::VERSION
10
-
11
- # Keep in sync with README
12
- spec.authors = [
13
- 'Josh Symonds',
14
- 'Logan Bowers',
15
- 'Craig Heneveld',
16
- 'Anatha Kumaran',
17
- 'Jason Dew',
18
- 'Luis Arias',
19
- 'Stefan Neculai',
20
- 'Philip White',
21
- 'Peeyush Kumar',
22
- 'Sumanth Ravipati',
23
- 'Pascal Corpet',
24
- 'Brian Glusman',
25
- 'Peter Boling',
26
- 'Andrew Konchin'
27
- ]
28
- spec.email = ['peter.boling@gmail.com', 'brian@stellaservice.com']
29
-
30
- spec.description = "Dynamoid is an ORM for Amazon's DynamoDB that supports offline development, associations, querying, and everything else you'd expect from an ActiveRecord-style replacement."
31
- spec.summary = "Dynamoid is an ORM for Amazon's DynamoDB"
32
- spec.extra_rdoc_files = [
33
- 'LICENSE.txt',
34
- 'README.md'
35
- ]
36
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(bin|test|spec|features|.dev|Vagrantfile)/}) }
37
- spec.homepage = 'http://github.com/Dynamoid/Dynamoid'
38
- spec.licenses = ['MIT']
39
- spec.bindir = 'exe'
40
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
41
- spec.require_paths = ['lib']
42
-
43
- spec.add_runtime_dependency 'activemodel', '>=4'
44
- spec.add_runtime_dependency 'aws-sdk-dynamodb', '~> 1'
45
- spec.add_runtime_dependency 'concurrent-ruby', '>= 1.0'
46
- spec.add_runtime_dependency 'null-logger'
47
-
48
- spec.add_development_dependency 'appraisal'
49
- spec.add_development_dependency 'bundler'
50
- spec.add_development_dependency 'coveralls'
51
- spec.add_development_dependency 'pry'
52
- spec.add_development_dependency 'rake'
53
- spec.add_development_dependency 'rspec'
54
- spec.add_development_dependency 'rubocop'
55
- spec.add_development_dependency 'wwtd'
56
- spec.add_development_dependency 'yard'
57
- end
@@ -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 "activemodel", "~> 4.2.0"
7
- gem "nokogiri", "~> 1.6.8"
8
-
9
- gemspec path: "../"