From a216dfb95cc4ff2ca504f417064fc5c797a64789 Mon Sep 17 00:00:00 2001 From: Jeff Dutil Date: Tue, 19 Dec 2017 16:30:54 -0700 Subject: [PATCH 01/12] Bump to rom v4 --- rom-dynamodb.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rom-dynamodb.gemspec b/rom-dynamodb.gemspec index df3644f..46c3479 100644 --- a/rom-dynamodb.gemspec +++ b/rom-dynamodb.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_runtime_dependency "rom", "~> 3.0.0.beta1" + spec.add_runtime_dependency "rom", "~> 4.0.0" spec.add_runtime_dependency "aws-sdk-core", ">= 2.1" spec.add_runtime_dependency "deep_merge", ">= 1.1.1" From 35b5ac176b401a0a793f4ed2b9b41536c3cfbb2b Mon Sep 17 00:00:00 2001 From: Jeff Dutil Date: Wed, 20 Dec 2017 09:06:05 -0700 Subject: [PATCH 02/12] Rom v4 errors w/auto_struct==true since dataset requires map method. See https://github.com/rom-rb/rom/blob/master/core/lib/rom/relation.rb#L221 --- lib/rom/dynamodb/dataset.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rom/dynamodb/dataset.rb b/lib/rom/dynamodb/dataset.rb index b46939a..a6e1c35 100644 --- a/lib/rom/dynamodb/dataset.rb +++ b/lib/rom/dynamodb/dataset.rb @@ -290,6 +290,7 @@ def information def each(&block) each_item(build, &block) end + alias map each def connection @connection ||= Aws::DynamoDB::Client.new(config) From 892ca12522aeb327c457d16a1927a06488824924 Mon Sep 17 00:00:00 2001 From: Jeff Dutil Date: Fri, 22 Dec 2017 09:32:25 -0700 Subject: [PATCH 03/12] Update comment namespacing. --- README.md | 2 +- examples/composite_table.rb | 2 +- examples/simple_table.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dc597f3..8a9c272 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ require 'rom/dynamodb' TABLE = "my-dynamodb-users-table" -# any other AWS::DynamoDB::Client options +# any other Aws::DynamoDB::Client options credentials = { region: 'us-east-1' } container = ROM.container(:dynamodb, credentials) do |rom| diff --git a/examples/composite_table.rb b/examples/composite_table.rb index 3d424e4..4dbd498 100644 --- a/examples/composite_table.rb +++ b/examples/composite_table.rb @@ -2,7 +2,7 @@ TABLE = "my-dynamodb-users-table" -# any other AWS::DynamoDB::Client options +# any other Aws::DynamoDB::Client options credentials = { region: 'us-east-1' } container = ROM.container(:dynamodb, credentials) do |rom| diff --git a/examples/simple_table.rb b/examples/simple_table.rb index 24ff857..57c7069 100644 --- a/examples/simple_table.rb +++ b/examples/simple_table.rb @@ -2,7 +2,7 @@ TABLE = "my-dynamodb-users-table" -# any other AWS::DynamoDB::Client options +# any other Aws::DynamoDB::Client options credentials = { region: 'us-east-1' } container = ROM.container(:dynamodb, credentials) do |rom| From aeeb9aa53249d0cd1ae2aa68f4821d5191a3f0bd Mon Sep 17 00:00:00 2001 From: Jeff Dutil Date: Fri, 22 Dec 2017 09:44:10 -0700 Subject: [PATCH 04/12] Restrict aws-sdk-core to v2 for now. --- rom-dynamodb.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rom-dynamodb.gemspec b/rom-dynamodb.gemspec index 46c3479..00c35ad 100644 --- a/rom-dynamodb.gemspec +++ b/rom-dynamodb.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_runtime_dependency "rom", "~> 4.0.0" - spec.add_runtime_dependency "aws-sdk-core", ">= 2.1" + spec.add_runtime_dependency "aws-sdk-core", "~> 2.10" spec.add_runtime_dependency "deep_merge", ">= 1.1.1" spec.add_development_dependency "json", "~> 2.0" From 92f2d02f1de64c953c9109e433547497b386dd91 Mon Sep 17 00:00:00 2001 From: Jeff Dutil Date: Fri, 22 Dec 2017 09:59:57 -0700 Subject: [PATCH 05/12] Update relation => relations. --- README.md | 4 ++-- examples/composite_table.rb | 2 +- examples/simple_table.rb | 2 +- spec/rom/dynamodb/command_spec.rb | 2 +- spec/rom/dynamodb/relation_spec.rb | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8a9c272..cfc60ee 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ TABLE = "my-dynamodb-users-table" credentials = { region: 'us-east-1' } container = ROM.container(:dynamodb, credentials) do |rom| - rom.relation(:users) do + rom.relations[:users] do # Key Schema: id dataset TABLE @@ -97,7 +97,7 @@ delete.by_id(user[:id]).call ```ruby container = ROM.container(:dynamodb, credentials) do |rom| - rom.relation(:logs) do + rom.relations[:logs] do # Key Schema: host, timestamp dataset "my-logs-table" diff --git a/examples/composite_table.rb b/examples/composite_table.rb index 4dbd498..930e2a4 100644 --- a/examples/composite_table.rb +++ b/examples/composite_table.rb @@ -6,7 +6,7 @@ credentials = { region: 'us-east-1' } container = ROM.container(:dynamodb, credentials) do |rom| - rom.relation(:logs) do + rom.relations[:logs] do # Key Schema: host, timestamp dataset "my-logs-table" diff --git a/examples/simple_table.rb b/examples/simple_table.rb index 57c7069..e11f9f6 100644 --- a/examples/simple_table.rb +++ b/examples/simple_table.rb @@ -6,7 +6,7 @@ credentials = { region: 'us-east-1' } container = ROM.container(:dynamodb, credentials) do |rom| - rom.relation(:users) do + rom.relations[:users] do # Key Schema: id dataset TABLE diff --git a/spec/rom/dynamodb/command_spec.rb b/spec/rom/dynamodb/command_spec.rb index 0b34463..e1a45d2 100644 --- a/spec/rom/dynamodb/command_spec.rb +++ b/spec/rom/dynamodb/command_spec.rb @@ -10,7 +10,7 @@ module ROM let(:container) { ROM.container(:dynamodb, credentials) do |rom| - rom.relation(descriptor) do + rom.relations[descriptor] do def by_id(id) retrieve(key: { id: id }) end diff --git a/spec/rom/dynamodb/relation_spec.rb b/spec/rom/dynamodb/relation_spec.rb index c55e9a6..fd3fdcd 100644 --- a/spec/rom/dynamodb/relation_spec.rb +++ b/spec/rom/dynamodb/relation_spec.rb @@ -22,7 +22,7 @@ module ROM let(:container) { ROM.container(:dynamodb, credentials) do |rom| - rom.relation(descriptor) do + rom.relations[descriptor] do def by_host(host) equal(:host, host) end @@ -220,7 +220,7 @@ def logged_at_between(after, before) let(:container) { ROM.container(:dynamodb, credentials) do |rom| - rom.relation(descriptor) do + rom.relations[descriptor] do def by_id(id) retrieve(key: { id: id }) end From b57234f42e1340c2e1b9b4033a93119131544c30 Mon Sep 17 00:00:00 2001 From: Jeff Dutil Date: Fri, 22 Dec 2017 10:07:23 -0700 Subject: [PATCH 06/12] Revert back to rom.relation and fix single rom.relations reference. --- README.md | 4 ++-- examples/composite_table.rb | 2 +- examples/simple_table.rb | 2 +- spec/rom/dynamodb/command_spec.rb | 4 ++-- spec/rom/dynamodb/relation_spec.rb | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index cfc60ee..8a9c272 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ TABLE = "my-dynamodb-users-table" credentials = { region: 'us-east-1' } container = ROM.container(:dynamodb, credentials) do |rom| - rom.relations[:users] do + rom.relation(:users) do # Key Schema: id dataset TABLE @@ -97,7 +97,7 @@ delete.by_id(user[:id]).call ```ruby container = ROM.container(:dynamodb, credentials) do |rom| - rom.relations[:logs] do + rom.relation(:logs) do # Key Schema: host, timestamp dataset "my-logs-table" diff --git a/examples/composite_table.rb b/examples/composite_table.rb index 930e2a4..4dbd498 100644 --- a/examples/composite_table.rb +++ b/examples/composite_table.rb @@ -6,7 +6,7 @@ credentials = { region: 'us-east-1' } container = ROM.container(:dynamodb, credentials) do |rom| - rom.relations[:logs] do + rom.relation(:logs) do # Key Schema: host, timestamp dataset "my-logs-table" diff --git a/examples/simple_table.rb b/examples/simple_table.rb index e11f9f6..57c7069 100644 --- a/examples/simple_table.rb +++ b/examples/simple_table.rb @@ -6,7 +6,7 @@ credentials = { region: 'us-east-1' } container = ROM.container(:dynamodb, credentials) do |rom| - rom.relations[:users] do + rom.relation(:users) do # Key Schema: id dataset TABLE diff --git a/spec/rom/dynamodb/command_spec.rb b/spec/rom/dynamodb/command_spec.rb index e1a45d2..63d1a72 100644 --- a/spec/rom/dynamodb/command_spec.rb +++ b/spec/rom/dynamodb/command_spec.rb @@ -10,7 +10,7 @@ module ROM let(:container) { ROM.container(:dynamodb, credentials) do |rom| - rom.relations[descriptor] do + rom.relation(descriptor) do def by_id(id) retrieve(key: { id: id }) end @@ -38,7 +38,7 @@ def alter_by_id(val) end } - let(:relation) { container.relation(descriptor) } + let(:relation) { container.relations[descriptor] } describe 'create' do subject(:command) { container.commands[descriptor][:create] } diff --git a/spec/rom/dynamodb/relation_spec.rb b/spec/rom/dynamodb/relation_spec.rb index fd3fdcd..c55e9a6 100644 --- a/spec/rom/dynamodb/relation_spec.rb +++ b/spec/rom/dynamodb/relation_spec.rb @@ -22,7 +22,7 @@ module ROM let(:container) { ROM.container(:dynamodb, credentials) do |rom| - rom.relations[descriptor] do + rom.relation(descriptor) do def by_host(host) equal(:host, host) end @@ -220,7 +220,7 @@ def logged_at_between(after, before) let(:container) { ROM.container(:dynamodb, credentials) do |rom| - rom.relations[descriptor] do + rom.relation(descriptor) do def by_id(id) retrieve(key: { id: id }) end From 133ad6c5b504d5f14a278036b41e50ab9162bf74 Mon Sep 17 00:00:00 2001 From: Jeff Dutil Date: Fri, 22 Dec 2017 10:18:34 -0700 Subject: [PATCH 07/12] Fix container.relations references. --- spec/rom/dynamodb/relation_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/rom/dynamodb/relation_spec.rb b/spec/rom/dynamodb/relation_spec.rb index c55e9a6..aba207d 100644 --- a/spec/rom/dynamodb/relation_spec.rb +++ b/spec/rom/dynamodb/relation_spec.rb @@ -50,7 +50,7 @@ def logged_at_between(after, before) end } - subject(:relation) { container.relation(descriptor) } + subject(:relation) { container.relations(descriptor) } before { container.commands[descriptor][:create].call(logs) } @@ -236,7 +236,7 @@ def by(val) end } - subject(:relation) { container.relation(descriptor) } + subject(:relation) { container.relations(descriptor) } before { container.commands[descriptor][:create].call(users) } From 89bb109b49e6880939970acbd2b1dd2fd25ad3b4 Mon Sep 17 00:00:00 2001 From: Jeff Dutil Date: Fri, 22 Dec 2017 10:22:58 -0700 Subject: [PATCH 08/12] Access hash with [] not () duh. --- spec/rom/dynamodb/relation_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/rom/dynamodb/relation_spec.rb b/spec/rom/dynamodb/relation_spec.rb index aba207d..b6f98c1 100644 --- a/spec/rom/dynamodb/relation_spec.rb +++ b/spec/rom/dynamodb/relation_spec.rb @@ -50,7 +50,7 @@ def logged_at_between(after, before) end } - subject(:relation) { container.relations(descriptor) } + subject(:relation) { container.relations[descriptor] } before { container.commands[descriptor][:create].call(logs) } @@ -236,7 +236,7 @@ def by(val) end } - subject(:relation) { container.relations(descriptor) } + subject(:relation) { container.relations[descriptor] } before { container.commands[descriptor][:create].call(users) } From 6bb7541c08487e2f9320aeeb4d94294289f0cf50 Mon Sep 17 00:00:00 2001 From: Jeff Dutil Date: Fri, 22 Dec 2017 10:43:38 -0700 Subject: [PATCH 09/12] Add coverage directory to fix permission error. --- coverage/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 coverage/.gitkeep diff --git a/coverage/.gitkeep b/coverage/.gitkeep new file mode 100644 index 0000000..e69de29 From 84cf356454546e2945a4f5ed07940c1a56b6fe46 Mon Sep 17 00:00:00 2001 From: Jeff Dutil Date: Fri, 22 Dec 2017 10:52:29 -0700 Subject: [PATCH 10/12] Disable simplecov in travis env for now. --- coverage/.gitkeep | 0 spec/spec_helper.rb | 6 ++++-- 2 files changed, 4 insertions(+), 2 deletions(-) delete mode 100644 coverage/.gitkeep diff --git a/coverage/.gitkeep b/coverage/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e121803..f9c41da 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,7 @@ -require 'simplecov' -SimpleCov.start +unless ENV['TRAVIS'] + require 'simplecov' + SimpleCov.start +end $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) From 7772c23d350a89726099f70e480e4f123e6b2b4f Mon Sep 17 00:00:00 2001 From: Jeff Dutil Date: Fri, 22 Dec 2017 10:54:02 -0700 Subject: [PATCH 11/12] Update to factory_bot --- rom-dynamodb.gemspec | 2 +- spec/factories/log.rb | 2 +- spec/factories/table.rb | 4 ++-- spec/factories/user.rb | 2 +- spec/spec_helper.rb | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rom-dynamodb.gemspec b/rom-dynamodb.gemspec index 00c35ad..acceae0 100644 --- a/rom-dynamodb.gemspec +++ b/rom-dynamodb.gemspec @@ -31,5 +31,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "yard", "~> 0.9" spec.add_development_dependency "redcarpet", "~> 3.4" spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0" - spec.add_development_dependency "factory_girl", "~> 4.5" + spec.add_development_dependency "factory_bot", "~> 4.8" end diff --git a/spec/factories/log.rb b/spec/factories/log.rb index 6c3e6b6..82964cc 100644 --- a/spec/factories/log.rb +++ b/spec/factories/log.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :log, class: Hash do transient do sequence_step 100 diff --git a/spec/factories/table.rb b/spec/factories/table.rb index cecc8cf..e1d1bd5 100644 --- a/spec/factories/table.rb +++ b/spec/factories/table.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :table, class: Hash do table_name { SecureRandom.uuid } @@ -8,7 +8,7 @@ schema({ id: :HASH }) global([]) - + local([]) end diff --git a/spec/factories/user.rb b/spec/factories/user.rb index 9b1d18a..9788f45 100644 --- a/spec/factories/user.rb +++ b/spec/factories/user.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :user, class: Hash do id { SecureRandom.uuid } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f9c41da..2d3b97f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,7 +7,7 @@ require "securerandom" require "transproc/all" -require "factory_girl" +require "factory_bot" require "faker" require "rom/dynamodb" @@ -17,5 +17,5 @@ Dir[Pathname(__FILE__).dirname.join('factories/*.rb').to_s].each { |f| require f } RSpec.configure do |config| - config.include FactoryGirl::Syntax::Methods + config.include FactoryBot::Syntax::Methods end From c60090023bf0f9debe1fe765af2920c294e703a0 Mon Sep 17 00:00:00 2001 From: Jeff Dutil Date: Fri, 22 Dec 2017 11:00:10 -0700 Subject: [PATCH 12/12] Fix example documentation for container.relations references. --- README.md | 4 ++-- examples/composite_table.rb | 2 +- examples/simple_table.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8a9c272..0bce7e9 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ container = ROM.container(:dynamodb, credentials) do |rom| end end -relation = container.relation(:users) +relation = container.relations[:users] relation.count # => 1234 @@ -134,7 +134,7 @@ end # create fake logs container.commands[:logs][:create].call(logs) -relation = container.relation(:logs) +relation = container.relations[:logs] relation.count == num_of_logs # => true diff --git a/examples/composite_table.rb b/examples/composite_table.rb index 4dbd498..48cc2e4 100644 --- a/examples/composite_table.rb +++ b/examples/composite_table.rb @@ -43,7 +43,7 @@ def before_timestamp(time) # create fake logs container.commands[:logs][:create].call(logs) -relation = container.relation(:logs) +relation = container.relations[:logs] relation.count == num_of_logs # => true diff --git a/examples/simple_table.rb b/examples/simple_table.rb index 57c7069..089c3ca 100644 --- a/examples/simple_table.rb +++ b/examples/simple_table.rb @@ -36,7 +36,7 @@ def by_id(val) end end -relation = container.relation(:users) +relation = container.relations[:users] relation.count # => 1234