dynamoid 3.2.0 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +111 -1
  3. data/README.md +580 -241
  4. data/lib/dynamoid.rb +2 -0
  5. data/lib/dynamoid/adapter.rb +15 -15
  6. data/lib/dynamoid/adapter_plugin/aws_sdk_v3.rb +82 -102
  7. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/batch_get_item.rb +108 -0
  8. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/create_table.rb +29 -16
  9. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/item_updater.rb +3 -2
  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 +15 -6
  14. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/scan.rb +15 -5
  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 +5 -3
  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 +4 -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 +65 -22
  25. data/lib/dynamoid/associations/single_association.rb +28 -1
  26. data/lib/dynamoid/components.rb +8 -3
  27. data/lib/dynamoid/config.rb +16 -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 +2 -1
  32. data/lib/dynamoid/criteria/chain.rb +418 -46
  33. data/lib/dynamoid/criteria/ignored_conditions_detector.rb +3 -3
  34. data/lib/dynamoid/criteria/key_fields_detector.rb +109 -32
  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 +239 -32
  38. data/lib/dynamoid/document.rb +130 -251
  39. data/lib/dynamoid/dumping.rb +9 -0
  40. data/lib/dynamoid/dynamodb_time_zone.rb +1 -0
  41. data/lib/dynamoid/fields.rb +246 -20
  42. data/lib/dynamoid/finders.rb +69 -32
  43. data/lib/dynamoid/identity_map.rb +6 -0
  44. data/lib/dynamoid/indexes.rb +76 -17
  45. data/lib/dynamoid/loadable.rb +31 -0
  46. data/lib/dynamoid/log/formatter.rb +26 -0
  47. data/lib/dynamoid/middleware/identity_map.rb +1 -0
  48. data/lib/dynamoid/persistence.rb +592 -122
  49. data/lib/dynamoid/persistence/import.rb +73 -0
  50. data/lib/dynamoid/persistence/save.rb +64 -0
  51. data/lib/dynamoid/persistence/update_fields.rb +63 -0
  52. data/lib/dynamoid/persistence/upsert.rb +60 -0
  53. data/lib/dynamoid/primary_key_type_mapping.rb +1 -0
  54. data/lib/dynamoid/railtie.rb +1 -0
  55. data/lib/dynamoid/tasks.rb +3 -1
  56. data/lib/dynamoid/tasks/database.rb +1 -0
  57. data/lib/dynamoid/type_casting.rb +12 -2
  58. data/lib/dynamoid/undumping.rb +8 -0
  59. data/lib/dynamoid/validations.rb +2 -0
  60. data/lib/dynamoid/version.rb +1 -1
  61. metadata +49 -71
  62. data/.coveralls.yml +0 -1
  63. data/.document +0 -5
  64. data/.gitignore +0 -74
  65. data/.rspec +0 -2
  66. data/.rubocop.yml +0 -71
  67. data/.rubocop_todo.yml +0 -55
  68. data/.travis.yml +0 -41
  69. data/Appraisals +0 -28
  70. data/Gemfile +0 -8
  71. data/Rakefile +0 -46
  72. data/Vagrantfile +0 -29
  73. data/docker-compose.yml +0 -7
  74. data/dynamoid.gemspec +0 -57
  75. data/gemfiles/rails_4_2.gemfile +0 -11
  76. data/gemfiles/rails_5_0.gemfile +0 -10
  77. data/gemfiles/rails_5_1.gemfile +0 -10
  78. data/gemfiles/rails_5_2.gemfile +0 -10
@@ -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
@@ -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
-
@@ -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'
@@ -1,41 +0,0 @@
1
- sudo: required
2
-
3
- language: ruby
4
- rvm:
5
- - ruby-2.3.8
6
- - ruby-2.4.5
7
- - ruby-2.5.3
8
- - ruby-2.6.1
9
- - jruby-9.1.17.0
10
- - jruby-9.2.6.0
11
- gemfile:
12
- gemfile:
13
- - gemfiles/rails_4_2.gemfile
14
- - gemfiles/rails_5_0.gemfile
15
- - gemfiles/rails_5_1.gemfile
16
- - gemfiles/rails_5_2.gemfile
17
-
18
- ### BUILD LIFECYCLE STEPS ###
19
-
20
- before_install:
21
- # Debugging: Print out the current docker-compose version.
22
- - docker-compose --version
23
-
24
- # If one of your containers does not build for
25
- # whatever reason it's best to report that now before your tests start
26
- # otherwise it can be really tricky to debug why tests are failing sometimes.
27
- - docker ps
28
-
29
- after_install:
30
- - gem install bundler -v 1.16.2
31
- - bundle install
32
-
33
- before_script:
34
- # Start Docker Compose as a daemon
35
- - docker-compose up -d
36
-
37
- script:
38
- - bundle exec rake spec
39
-
40
- after_script:
41
- - docker-compose down
data/Appraisals DELETED
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- appraise 'rails-4-0' do
4
- gem 'rails', '~> 4.0.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-4-1' do
9
- gem 'rails', '~> 4.1.0'
10
- gem 'nokogiri', '~> 1.6.8' # can be removed once we drop support for Ruby 2.0.0
11
- end
12
-
13
- appraise 'rails-4-2' do
14
- gem 'rails', '~> 4.2.0'
15
- gem 'nokogiri', '~> 1.6.8' # can be removed once we drop support for Ruby 2.0.0
16
- end
17
-
18
- appraise 'rails-5-0' do
19
- gem 'rails', '~> 5.0.0'
20
- end
21
-
22
- appraise 'rails-5-1' do
23
- gem 'rails', '~> 5.1.0'
24
- end
25
-
26
- appraise 'rails-5-2' do
27
- gem 'rails', '~> 5.2.0'
28
- 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
@@ -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
@@ -1,7 +0,0 @@
1
- version: '2'
2
-
3
- services:
4
- dynamodb:
5
- image: amazon/dynamodb-local
6
- ports:
7
- - 8000:8000
@@ -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,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file was generated by Appraisal
4
-
5
- source 'https://rubygems.org'
6
-
7
- gem 'activemodel', '~> 4.2.0'
8
- gem 'nokogiri', '~> 1.6.8'
9
- gem 'pry-byebug', platforms: :ruby
10
-
11
- gemspec path: '../'