From c2dbe6e5cb14aef67e9b9dd0c8ce0511b12116eb Mon Sep 17 00:00:00 2001 From: Sebastian Kreft Date: Wed, 24 Dec 2025 10:11:27 -0300 Subject: [PATCH 1/2] chore: use SPDX license identifier The [gemspec specification](https://guides.rubygems.org/specification-reference/#method-i-license-3D) , mentions that > The simplest way is to specify the standard SPDX ID spdx.org/licenses/ for the license. And in fact most gems adheres to this convention, including some others AWS gems, like [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby/blob/aa020cd8c3d09be074cc2b018691f0145be5802a/gems/aws-sdk-s3/aws-sdk-s3.gemspec#L18) and all the gems in that repo. Based on https://spdx.org/licenses/Apache-2.0.html the identifier is `Apache-2.0`. --- aws-record.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws-record.gemspec b/aws-record.gemspec index dfa16fa..0e54af2 100644 --- a/aws-record.gemspec +++ b/aws-record.gemspec @@ -8,7 +8,7 @@ Gem::Specification.new do |spec| spec.summary = 'AWS Record library for Amazon DynamoDB' spec.description = 'Provides an object mapping abstraction for Amazon DynamoDB.' spec.homepage = 'https://github.com/aws/aws-sdk-ruby-record' - spec.license = 'Apache 2.0' + spec.license = 'Apache-2.0' spec.require_paths = ['lib'] spec.files = Dir['lib/**/*.rb', 'LICENSE', 'CHANGELOG.md', 'VERSION'] From ecae6b461a2e6102113b6d4487f12fe180498db4 Mon Sep 17 00:00:00 2001 From: Juli Tera Date: Wed, 24 Dec 2025 09:48:52 -0800 Subject: [PATCH 2/2] Appease rubocop --- features/batch/step_definitions.rb | 2 -- lib/aws-record/record/batch_read.rb | 2 +- lib/aws-record/record/model_attributes.rb | 2 +- lib/aws-record/record/table_config.rb | 10 +++++----- lib/aws-record/record/table_migration.rb | 4 ++-- spec/aws-record/record/attributes_spec.rb | 5 +++++ spec/aws-record/record/batch_spec.rb | 4 ++++ spec/aws-record/record/dirty_tracking_spec.rb | 6 ++++++ spec/aws-record/record/item_collection_spec.rb | 3 +++ spec/aws-record/record/item_operations_spec.rb | 3 +++ spec/aws-record/record/query_spec.rb | 1 + spec/aws-record/record/secondary_indexes_spec.rb | 3 +++ spec/aws-record/record/table_migration_spec.rb | 2 ++ spec/aws-record/record/transactions_spec.rb | 2 ++ spec/aws-record/record_spec.rb | 9 +++++++++ 15 files changed, 47 insertions(+), 11 deletions(-) diff --git a/features/batch/step_definitions.rb b/features/batch/step_definitions.rb index 0a199e9..15c0724 100644 --- a/features/batch/step_definitions.rb +++ b/features/batch/step_definitions.rb @@ -54,8 +54,6 @@ expect(expected.all? { |e| actual.include?(e) }).to be_truthy end -private - def remove_model_key(item) item.delete(:model) item diff --git a/lib/aws-record/record/batch_read.rb b/lib/aws-record/record/batch_read.rb index 7aa544d..241b55d 100644 --- a/lib/aws-record/record/batch_read.rb +++ b/lib/aws-record/record/batch_read.rb @@ -37,7 +37,7 @@ def find(klass, key = {}) # See {Batch.read} for example usage. # @return [Array] an array of unordered new items def execute! - operation_keys = unprocessed_keys[0..BATCH_GET_ITEM_LIMIT - 1] + operation_keys = unprocessed_keys[0..(BATCH_GET_ITEM_LIMIT - 1)] @unprocessed_keys = unprocessed_keys[BATCH_GET_ITEM_LIMIT..] || [] operations = build_operations(operation_keys) diff --git a/lib/aws-record/record/model_attributes.rb b/lib/aws-record/record/model_attributes.rb index cddb7c0..8b2570b 100644 --- a/lib/aws-record/record/model_attributes.rb +++ b/lib/aws-record/record/model_attributes.rb @@ -59,7 +59,7 @@ def _validate_attr_name(name) end def _check_if_reserved(name) - return unless @model_class.instance_methods.include?(name) + return unless @model_class.method_defined?(name) raise Errors::ReservedName, "Cannot name an attribute #{name}, that would collide with an " \ 'existing instance method.' diff --git a/lib/aws-record/record/table_config.rb b/lib/aws-record/record/table_config.rb index 8b388fb..a3a4e7a 100644 --- a/lib/aws-record/record/table_config.rb +++ b/lib/aws-record/record/table_config.rb @@ -244,7 +244,7 @@ def migrate! # we will only alter TTL status if we have a TTL attribute defined. We # may someday support explicit TTL deletion, but we do not yet do this. return unless @ttl_attribute - return if _ttl_compatibility_check + return if ttl_compatibility_check? client.update_time_to_live( table_name: @model_class.table_name, @@ -268,7 +268,7 @@ def migrate! # @return [Boolean] true if remote is compatible, false otherwise. def compatible? resp = @client.describe_table(table_name: @model_class.table_name) - _compatible_check(resp) && _ttl_compatibility_check + _compatible_check(resp) && ttl_compatibility_check? rescue DynamoDB::Errors::ResourceNotFoundException false end @@ -285,14 +285,14 @@ def exact_match? _keys_equal(resp) && _ad_equal(resp) && _gsi_equal(resp) && - _ttl_match_check + ttl_match_check? rescue DynamoDB::Errors::ResourceNotFoundException false end private - def _ttl_compatibility_check + def ttl_compatibility_check? if @ttl_attribute ttl_status = @client.describe_time_to_live( table_name: @model_class.table_name @@ -305,7 +305,7 @@ def _ttl_compatibility_check end end - def _ttl_match_check + def ttl_match_check? ttl_status = @client.describe_time_to_live( table_name: @model_class.table_name ) diff --git a/lib/aws-record/record/table_migration.rb b/lib/aws-record/record/table_migration.rb index 727541a..a8a51b0 100644 --- a/lib/aws-record/record/table_migration.rb +++ b/lib/aws-record/record/table_migration.rb @@ -17,7 +17,7 @@ class TableMigration # class. If this option is not included, a client will be constructed for # you with default parameters. def initialize(model, opts = {}) - _assert_model_valid(model) + valid_model?(model) @model = model @client = opts[:client] || model.dynamodb_client || Aws::DynamoDB::Client.new @client.config.user_agent_frameworks << 'aws-record' @@ -130,7 +130,7 @@ def wait_until_available private - def _assert_model_valid(model) + def valid_model?(model) _assert_required_include(model) model.model_valid? end diff --git a/spec/aws-record/record/attributes_spec.rb b/spec/aws-record/record/attributes_spec.rb index bcdd4ed..9d85cec 100644 --- a/spec/aws-record/record/attributes_spec.rb +++ b/spec/aws-record/record/attributes_spec.rb @@ -15,6 +15,7 @@ module Record let(:model) do Class.new do include(Aws::Record) + string_attr(:id, hash_key: true) string_attr(:body) end @@ -171,6 +172,7 @@ module Record let(:klass) do Class.new do include(Aws::Record) + set_table_name('TestTable') integer_attr(:id, hash_key: true) atomic_counter(:counter) @@ -244,6 +246,7 @@ module Record let(:parent_model) do Class.new do include(Aws::Record) + integer_attr(:id, hash_key: true) date_attr(:date, range_key: true) list_attr(:list) @@ -253,6 +256,7 @@ module Record let(:child_model) do Class.new(parent_model) do include(Aws::Record) + string_attr(:body) end end @@ -260,6 +264,7 @@ module Record let(:child_model2) do Class.new(parent_model) do include(Aws::Record) + string_attr(:body2) end end diff --git a/spec/aws-record/record/batch_spec.rb b/spec/aws-record/record/batch_spec.rb index aaafa30..402e83c 100644 --- a/spec/aws-record/record/batch_spec.rb +++ b/spec/aws-record/record/batch_spec.rb @@ -10,6 +10,7 @@ describe '.write' do Planet = Class.new do include(Aws::Record) + integer_attr(:id, hash_key: true) string_attr(:name, range_key: true) end @@ -87,6 +88,7 @@ let(:food) do Class.new do include(Aws::Record) + set_table_name('FoodTable') integer_attr(:id, hash_key: true, database_attribute_name: 'Food ID') string_attr(:dish, range_key: true) @@ -97,6 +99,7 @@ let(:breakfast) do Class.new(food) do include(Aws::Record) + boolean_attr(:gluten_free) end end @@ -104,6 +107,7 @@ let(:drink) do Class.new do include(Aws::Record) + set_table_name('DrinkTable') integer_attr(:id, hash_key: true) string_attr(:drink) diff --git a/spec/aws-record/record/dirty_tracking_spec.rb b/spec/aws-record/record/dirty_tracking_spec.rb index 023a19b..8273518 100644 --- a/spec/aws-record/record/dirty_tracking_spec.rb +++ b/spec/aws-record/record/dirty_tracking_spec.rb @@ -194,6 +194,7 @@ Class.new do include(ActiveModel::Model) include(Aws::Record) + set_table_name(:test_table) string_attr(:mykey, hash_key: true) string_attr(:body) @@ -317,6 +318,7 @@ Class.new do include(Aws::Record) include(ActiveModel::Validations) + set_table_name('TestTable') integer_attr(:id, hash_key: true) string_attr(:body) @@ -335,6 +337,7 @@ model = Class.new do include(Aws::Record) include(ActiveModel::Validations) + set_table_name('TestTable') integer_attr(:id, hash_key: true) string_attr(:body) @@ -424,6 +427,7 @@ model = Class.new do include(Aws::Record) include(ActiveModel::Validations) + set_table_name('TestTable') integer_attr(:id, hash_key: true) string_attr(:body) @@ -480,6 +484,7 @@ let(:klass) do Class.new do include(Aws::Record) + set_table_name(:test_table) string_attr(:mykey, hash_key: true) string_attr(:body) @@ -493,6 +498,7 @@ let(:klass_with_defaults) do Class.new do include(Aws::Record) + set_table_name(:test_table) string_attr(:mykey, hash_key: true) map_attr(:dirty_map, default_value: {}) diff --git a/spec/aws-record/record/item_collection_spec.rb b/spec/aws-record/record/item_collection_spec.rb index 3269297..30f1bc8 100644 --- a/spec/aws-record/record/item_collection_spec.rb +++ b/spec/aws-record/record/item_collection_spec.rb @@ -8,6 +8,7 @@ module Record let(:model) do Class.new do include(Aws::Record) + set_table_name('TestTable') integer_attr(:id, hash_key: true) end @@ -206,6 +207,7 @@ module Record let(:model_a) do Class.new do include(Aws::Record) + set_table_name('TestTable') integer_attr(:id, hash_key: true) string_attr(:class_name) @@ -216,6 +218,7 @@ module Record let(:model_b) do Class.new do include(Aws::Record) + set_table_name('TestTable') integer_attr(:id, hash_key: true) string_attr(:class_name) diff --git a/spec/aws-record/record/item_operations_spec.rb b/spec/aws-record/record/item_operations_spec.rb index abaead6..5e7bd9c 100644 --- a/spec/aws-record/record/item_operations_spec.rb +++ b/spec/aws-record/record/item_operations_spec.rb @@ -8,6 +8,7 @@ module Record let(:klass) do Class.new do include(Aws::Record) + set_table_name('TestTable') integer_attr(:id, hash_key: true) date_attr(:date, range_key: true, database_attribute_name: 'MyDate') @@ -343,6 +344,7 @@ module Record let(:klass_with_defaults) do Class.new do include(Aws::Record) + set_table_name('TestTable') string_attr(:mykey, hash_key: true) map_attr(:dirty_map, default_value: {}) @@ -828,6 +830,7 @@ module Record ::TEST_TABLE = Class.new do include(Aws::Record) include(ActiveModel::Validations) + set_table_name('TestTable') integer_attr(:id, hash_key: true) date_attr(:date, range_key: true) diff --git a/spec/aws-record/record/query_spec.rb b/spec/aws-record/record/query_spec.rb index 4ccb2f6..d76e596 100644 --- a/spec/aws-record/record/query_spec.rb +++ b/spec/aws-record/record/query_spec.rb @@ -8,6 +8,7 @@ module Record let(:klass) do Class.new do include(Aws::Record) + set_table_name('TestTable') integer_attr(:id, hash_key: true) date_attr(:date, range_key: true) diff --git a/spec/aws-record/record/secondary_indexes_spec.rb b/spec/aws-record/record/secondary_indexes_spec.rb index 58d3927..8c1e32d 100644 --- a/spec/aws-record/record/secondary_indexes_spec.rb +++ b/spec/aws-record/record/secondary_indexes_spec.rb @@ -8,6 +8,7 @@ module Record let(:klass) do Class.new do include(Aws::Record) + set_table_name('TestTable') integer_attr(:forum_id, hash_key: true) integer_attr(:post_id, range_key: true) @@ -161,6 +162,7 @@ module Record let(:parent_model) do Class.new do include(Aws::Record) + integer_attr(:id, hash_key: true) string_attr(:name, range_key: true) string_attr(:message) @@ -170,6 +172,7 @@ module Record let(:child_model) do Class.new(parent_model) do include(Aws::Record) + string_attr(:foo) string_attr(:bar) end diff --git a/spec/aws-record/record/table_migration_spec.rb b/spec/aws-record/record/table_migration_spec.rb index 36e719b..cd359bc 100644 --- a/spec/aws-record/record/table_migration_spec.rb +++ b/spec/aws-record/record/table_migration_spec.rb @@ -37,6 +37,7 @@ module Record let(:model) do model = Class.new do include(Aws::Record) + set_table_name('TestTable') integer_attr(:id, hash_key: true) end @@ -57,6 +58,7 @@ module Record let(:klass) do Class.new do include(Aws::Record) + set_table_name('TestTable') integer_attr(:id, hash_key: true) date_attr(:date, range_key: true, database_attribute_name: 'datekey') diff --git a/spec/aws-record/record/transactions_spec.rb b/spec/aws-record/record/transactions_spec.rb index 35f0b58..6054c25 100644 --- a/spec/aws-record/record/transactions_spec.rb +++ b/spec/aws-record/record/transactions_spec.rb @@ -12,6 +12,7 @@ module Record let(:table_one) do Class.new do include(Aws::Record) + set_table_name('TableOne') integer_attr(:id, hash_key: true) string_attr(:range, range_key: true) @@ -23,6 +24,7 @@ module Record let(:table_two) do Class.new do include(Aws::Record) + set_table_name('TableTwo') string_attr(:uuid, hash_key: true) string_attr(:body) diff --git a/spec/aws-record/record_spec.rb b/spec/aws-record/record_spec.rb index 38ca566..6b86a47 100644 --- a/spec/aws-record/record_spec.rb +++ b/spec/aws-record/record_spec.rb @@ -28,6 +28,7 @@ module Aws expected = 'ExpectedTableName' ::UnitTestModelTwo = Class.new do include(Aws::Record) + set_table_name(expected) end expect(::UnitTestModelTwo.table_name).to eq(expected) @@ -48,6 +49,7 @@ module Aws let(:model) do Class.new do include(Aws::Record) + set_table_name('TestTable') end end @@ -84,6 +86,7 @@ module Aws let(:model) do Class.new do include(Aws::Record) + set_table_name('TestTable') end end @@ -111,6 +114,7 @@ module Aws let(:model) do Class.new do include(Aws::Record) + set_table_name('TestTable') string_attr(:uuid, hash_key: true) attr(:mt, Aws::Record::Marshalers::StringMarshaler.new) @@ -131,6 +135,7 @@ module Aws let(:model) do Class.new do include(Aws::Record) + set_table_name('TestTable') string_attr(:uuid, hash_key: true) map_attr(:things, default_value: {}) @@ -147,6 +152,7 @@ module Aws let(:model) do Class.new do include(Aws::Record) + set_table_name('TestTable') string_attr(:uuid, hash_key: true) string_attr(:other_attr) @@ -170,6 +176,7 @@ module Aws let(:parent_model) do Class.new do include(Aws::Record) + set_table_name('ParentTable') end end @@ -208,6 +215,7 @@ module Aws let(:parent_model) do Class.new do include(Aws::Record) + integer_attr(:id, hash_key: true) end end @@ -215,6 +223,7 @@ module Aws let(:child_model) do Class.new(parent_model) do include(Aws::Record) + string_attr(:foo) end end