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 +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +1 -1
- data/Rakefile +3 -3
- data/lib/update_values_all/adapters/postgres.rb +1 -1
- data/lib/update_values_all/batch_update.rb +12 -7
- data/lib/update_values_all/railtie.rb +2 -0
- data/lib/update_values_all/version.rb +1 -1
- data/lib/update_values_all.rb +0 -12
- data/update_values_all.gemspec +13 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85a13e35a594f137fea9231a1b0b38130c412487ae0b3c9934488de419022113
|
4
|
+
data.tar.gz: 00ff2728e7fd0505cb767d20d4a29357abfc596b88736475baf1e35bb06bbb2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53f2254a4a3eb2ecfa1ba86de54d5bd3c20efd6e02b4b752dda8f0bac8b5fc6f54b2894118ad8cd43bcbaed6963b9f272ad8dd0370c603c904ef4d8cb0006819
|
7
|
+
data.tar.gz: 16e08bb8ea4b8d73373c6a4013154b7b19aa7d1d27295e2ced90db2abe37d2534e5af4546e077a5585ed02af8906ca1e21e191ae5585bd1e9b80bfe466014eba
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
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
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
require
|
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
|
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(
|
7
|
-
|
8
|
-
|
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
|
-
|
11
|
-
|
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
|
|
data/lib/update_values_all.rb
CHANGED
@@ -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
|
data/update_values_all.gemspec
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'lib/update_values_all/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
6
|
+
spec.name = 'update_values_all'
|
7
7
|
spec.version = UpdateValuesAll::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
8
|
+
spec.authors = ['Sergei Malykh']
|
9
|
+
spec.email = ['xronos.i.am@gmail.com']
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.homepage =
|
13
|
-
spec.license =
|
14
|
-
spec.required_ruby_version =
|
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 =
|
25
|
-
|
26
|
-
|
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.
|
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-
|
11
|
+
date: 2023-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|