From 83d318272cec4482b79d4fe8b432c16e681c5d45 Mon Sep 17 00:00:00 2001 From: Quentin de Metz Date: Sat, 19 Oct 2024 09:06:47 +0200 Subject: [PATCH] rename to activerecord_batch_update --- Gemfile.lock | 10 +++++----- README.md | 4 ++-- ...update.gemspec => activerecord_batch_update.gemspec | 6 +++--- lib/{batch_update.rb => activerecord_batch_update.rb} | 4 ++-- ...pdate_spec.rb => activerecord_batch_update_spec.rb} | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) rename batch_update.gemspec => activerecord_batch_update.gemspec (80%) rename lib/{batch_update.rb => activerecord_batch_update.rb} (98%) rename spec/{batch_update_spec.rb => activerecord_batch_update_spec.rb} (98%) diff --git a/Gemfile.lock b/Gemfile.lock index fc51cde..27319e1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - batch_update (0.0.2) + activerecord_batch_update (0.0.2) activerecord (~> 7.0) activesupport (~> 7.0) @@ -28,15 +28,15 @@ GEM base64 (0.2.0) bigdecimal (3.1.8) byebug (11.1.3) - concurrent-ruby (1.3.3) + concurrent-ruby (1.3.4) connection_pool (2.4.1) diff-lcs (1.5.1) drb (2.2.1) - i18n (1.14.5) + i18n (1.14.6) concurrent-ruby (~> 1.0) json (2.7.2) language_server-protocol (3.17.0.3) - minitest (5.24.1) + minitest (5.25.1) mutex_m (0.2.0) parallel (1.26.3) parser (3.3.5.0) @@ -87,7 +87,7 @@ PLATFORMS x86_64-linux DEPENDENCIES - batch_update! + activerecord_batch_update! byebug rake-release rspec diff --git a/README.md b/README.md index 8d873da..51e97cf 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# Batch Update +# ActiveRecord Batch Update Update multiple records with different values in an optimized number of queries. This differs from [activerecord-import](https://github.com/zdennis/activerecord-import) because the latter issues a `INSERT ... ON DUPLICATE KEY UPDATE` statement which re-inserts the record if it happens to have been deleted in a other thread. ## Usage -Include in your Gemfile: `gem 'batch_update'` +Include in your Gemfile: `gem 'activerecord_batch_update'` ```ruby cat1 = Cat.create!(name: 'Felix', birthday: '1990-03-13') diff --git a/batch_update.gemspec b/activerecord_batch_update.gemspec similarity index 80% rename from batch_update.gemspec rename to activerecord_batch_update.gemspec index 60efe4c..3cbfc84 100644 --- a/batch_update.gemspec +++ b/activerecord_batch_update.gemspec @@ -1,15 +1,15 @@ # frozen_string_literal: true Gem::Specification.new do |s| - s.name = 'batch_update' + s.name = 'activerecord_batch_update' s.version = '0.0.2' s.summary = 'Update multiple records with different values in a small number of queries' - s.description = 'A simple hello world gem' + s.description = '' s.authors = ['Quentin de Metz'] s.email = 'quentin@pennylane.com' s.files = Dir['{lib}/**/*.rb'] s.homepage = - 'https://rubygems.org/gems/batch_update' + 'https://rubygems.org/gems/activerecord_batch_update' s.license = 'MIT' s.required_ruby_version = '>= 3.3.4' diff --git a/lib/batch_update.rb b/lib/activerecord_batch_update.rb similarity index 98% rename from lib/batch_update.rb rename to lib/activerecord_batch_update.rb index 6c06091..9f03a31 100644 --- a/lib/batch_update.rb +++ b/lib/activerecord_batch_update.rb @@ -2,7 +2,7 @@ require 'active_support' -module BatchUpdate +module ActiveRecordBatchUpdate extend ::ActiveSupport::Concern # Given an array of records with changes, @@ -114,5 +114,5 @@ def where_statement(primary_keys) end ActiveSupport.on_load(:active_record) do - include(BatchUpdate) + include(ActiveRecordBatchUpdate) end diff --git a/spec/batch_update_spec.rb b/spec/activerecord_batch_update_spec.rb similarity index 98% rename from spec/batch_update_spec.rb rename to spec/activerecord_batch_update_spec.rb index 25953c1..306ba84 100644 --- a/spec/batch_update_spec.rb +++ b/spec/activerecord_batch_update_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require 'batch_update' +require 'activerecord_batch_update' -describe BatchUpdate do +describe ActiveRecordBatchUpdate do # rubocop:disable RSpec/SpecFilePathFormat describe '#batch_update_statements' do subject(:sql_queries) { Cat.batch_update_statements(cats, **kwargs) }