update_values_all 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a330d34e5e9fe0ebdc3a414b50f21a6ebfa2bb90f49f8fd5bdb144427da7dcb6
4
- data.tar.gz: 82f95dfcb04cfa99e11a5fbe34312373e4c6d38461c4d7dac5f19e30d098137a
3
+ metadata.gz: 85a13e35a594f137fea9231a1b0b38130c412487ae0b3c9934488de419022113
4
+ data.tar.gz: 00ff2728e7fd0505cb767d20d4a29357abfc596b88736475baf1e35bb06bbb2d
5
5
  SHA512:
6
- metadata.gz: ef94276838c219aa6f44dc142e0f009dcfa03e4f4c91118a4efce8863d24550ded1d9a546acfa84b9ec1f9b018fe402db739808e3a1fb8333f59882846a95c80
7
- data.tar.gz: 0a0e9a6ffc8d4aa34cb328e1f134e8b51a0728f02c2d81be8513073c98cab8e1ce19190f3656315389c045f79f478385376b6d03ee53d683d33351935bcf7074
6
+ metadata.gz: 53f2254a4a3eb2ecfa1ba86de54d5bd3c20efd6e02b4b752dda8f0bac8b5fc6f54b2894118ad8cd43bcbaed6963b9f272ad8dd0370c603c904ef4d8cb0006819
7
+ data.tar.gz: 16e08bb8ea4b8d73373c6a4013154b7b19aa7d1d27295e2ced90db2abe37d2534e5af4546e077a5585ed02af8906ca1e21e191ae5585bd1e9b80bfe466014eba
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.0.2] - 2023-03-29
2
+
3
+ - skips update if empty data
4
+
5
+ ## [1.0.1] - 2023-03-29
6
+
7
+ - refactor adapter to fix loading in CI environment
8
+
1
9
  ## [1.0.0] - 2023-03-27
2
10
 
3
11
  - Initial release
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in update_values_all.gemspec
6
6
  gemspec
@@ -11,4 +11,4 @@ gem 'lefthook', require: false
11
11
  gem 'pg'
12
12
  gem 'rspec'
13
13
  gem 'rspec-rails'
14
- gem 'rubocop-gp', github: 'corp-gp/rubocop-gp', require: false
14
+ gem 'rubocop-gp', github: 'corp-gp/rubocop-gp', require: false
data/Gemfile.lock CHANGED
@@ -11,7 +11,7 @@ GIT
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- update_values_all (1.0.0)
14
+ update_values_all (1.0.2)
15
15
  activerecord (>= 4.2)
16
16
 
17
17
  GEM
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- require "rubocop/rake_task"
8
+ require 'rubocop/rake_task'
9
9
 
10
10
  RuboCop::RakeTask.new
11
11
 
@@ -4,7 +4,7 @@ module UpdateValuesAll
4
4
  module Adapters
5
5
  module Postgres
6
6
 
7
- def update_values_all(data, key_to_match:, touch: false, sql_update_expression: 'updated_at = CURRENT_TIMESTAMP')
7
+ def pg_update_values_all(data, key_to_match:, touch: false, sql_update_expression: 'updated_at = CURRENT_TIMESTAMP')
8
8
  keys = data.first.keys
9
9
 
10
10
  sql_values = +''
@@ -1,16 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'update_values_all/adapters/postgres'
4
+
3
5
  module UpdateValuesAll
4
6
  module BatchUpdate
5
7
 
6
- def self.extended(active_record_base)
7
- active_record_base.define_singleton_method(:inherited) do |subclass|
8
- super(subclass)
8
+ def self.extended(klass)
9
+ if defined?(::PG::Connection)
10
+ klass.extend(UpdateValuesAll::Adapters::Postgres)
11
+ end
12
+ end
13
+
14
+ def update_values_all(data, **keyword_args)
15
+ return [] if data.empty?
9
16
 
10
- case subclass.connection.raw_connection
11
- when ::PG::Connection
12
- subclass.extend UpdateValuesAll::Adapters::Postgres
13
- end
17
+ if defined?(::PG::Connection) && connection.raw_connection.is_a?(::PG::Connection)
18
+ pg_update_values_all(data, **keyword_args)
14
19
  end
15
20
  end
16
21
 
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'update_values_all/batch_update'
4
+
3
5
  module UpdateValuesAll
4
6
  class Railtie < ::Rails::Railtie
5
7
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module UpdateValuesAll
4
4
 
5
- VERSION = '1.0.0'
5
+ VERSION = '1.0.2'
6
6
 
7
7
  end
@@ -2,15 +2,3 @@
2
2
 
3
3
  require_relative 'update_values_all/version'
4
4
  require_relative 'update_values_all/railtie'
5
-
6
- module UpdateValuesAll
7
-
8
- autoload :BatchUpdate, 'update_values_all/batch_update'
9
-
10
- module Adapters
11
-
12
- autoload :Postgres, 'update_values_all/adapters/postgres'
13
-
14
- end
15
-
16
- end
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "lib/update_values_all/version"
3
+ require_relative 'lib/update_values_all/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "update_values_all"
6
+ spec.name = 'update_values_all'
7
7
  spec.version = UpdateValuesAll::VERSION
8
- spec.authors = ["Sergei Malykh"]
9
- spec.email = ["xronos.i.am@gmail.com"]
8
+ spec.authors = ['Sergei Malykh']
9
+ spec.email = ['xronos.i.am@gmail.com']
10
10
 
11
- spec.summary = "The gem allows to update AR-records in batch"
12
- spec.homepage = "https://github.com/corp-gp/update_values_all"
13
- spec.license = "MIT"
14
- spec.required_ruby_version = ">= 2.7.0"
11
+ spec.summary = 'The gem allows to update AR-records in batch'
12
+ spec.homepage = 'https://github.com/corp-gp/update_values_all'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = '>= 2.7.0'
15
15
 
16
16
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
17
17
 
@@ -21,11 +21,12 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  # Specify which files should be added to the gem when it is released.
23
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
- spec.files = Dir.chdir(__dir__) do
25
- `git ls-files -z`.split("\x0").reject do |f|
26
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
24
+ spec.files =
25
+ Dir.chdir(__dir__) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
28
+ end
27
29
  end
28
- end
29
30
  spec.require_paths = ['lib']
30
31
 
31
32
  spec.add_dependency 'activerecord', '>= 4.2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: update_values_all
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergei Malykh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-28 00:00:00.000000000 Z
11
+ date: 2023-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord