update_values_all 1.0.0 → 1.1.0

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: 407100066be1214e75c13c733db1fcb66ab8eae08a73d5edaf28b9fe805a54af
4
+ data.tar.gz: 4a0cb4a3f0aa7e4b9c6154ad760fe53a486b96ab96e46502f9ac4daeed6d3150
5
5
  SHA512:
6
- metadata.gz: ef94276838c219aa6f44dc142e0f009dcfa03e4f4c91118a4efce8863d24550ded1d9a546acfa84b9ec1f9b018fe402db739808e3a1fb8333f59882846a95c80
7
- data.tar.gz: 0a0e9a6ffc8d4aa34cb328e1f134e8b51a0728f02c2d81be8513073c98cab8e1ce19190f3656315389c045f79f478385376b6d03ee53d683d33351935bcf7074
6
+ metadata.gz: b31196412dcf1f69187a979c0bde27e60262d0683ba0967be698a7768f187452720099fda52253a954539d71668879d9c7d712735af7731aa8f414ab8dbdd07a
7
+ data.tar.gz: 97f917b319a95a738fcf7d2e510a86e7b1a6e1b92fcbfbba210498e90391cb0992ba8479add5302302c52c3c10d341b5824018326a31617418c729006a25d49f
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
@@ -1,17 +1,20 @@
1
1
  GIT
2
2
  remote: https://github.com/corp-gp/rubocop-gp.git
3
- revision: 8002f0236b97e26586218f6cc677761d13affbdb
3
+ revision: e5bd900ce4b10077cf8f4ae88a5a6e32e7861b65
4
4
  specs:
5
- rubocop-gp (0.0.3)
5
+ rubocop-gp (0.0.4)
6
6
  rubocop
7
+ rubocop-capybara
8
+ rubocop-factory_bot
7
9
  rubocop-performance
8
10
  rubocop-rails
9
11
  rubocop-rspec
12
+ rubocop-rspec_rails
10
13
 
11
14
  PATH
12
15
  remote: .
13
16
  specs:
14
- update_values_all (1.0.0)
17
+ update_values_all (1.0.2)
15
18
  activerecord (>= 4.2)
16
19
 
17
20
  GEM
@@ -46,7 +49,7 @@ GEM
46
49
  activesupport (>= 3.0.0)
47
50
  railties (>= 3.0.0)
48
51
  thor (>= 0.14.6)
49
- concurrent-ruby (1.2.2)
52
+ concurrent-ruby (1.3.4)
50
53
  crass (1.0.6)
51
54
  diff-lcs (1.5.0)
52
55
  dotenv (2.8.1)
@@ -54,23 +57,27 @@ GEM
54
57
  dotenv (= 2.8.1)
55
58
  railties (>= 3.2)
56
59
  erubi (1.12.0)
57
- i18n (1.12.0)
60
+ i18n (1.14.5)
58
61
  concurrent-ruby (~> 1.0)
59
- json (2.6.3)
62
+ json (2.7.2)
63
+ language_server-protocol (3.17.0.3)
60
64
  lefthook (1.3.8)
61
65
  loofah (2.19.1)
62
66
  crass (~> 1.0.2)
63
67
  nokogiri (>= 1.5.9)
64
68
  method_source (1.0.0)
65
- minitest (5.18.0)
66
- nokogiri (1.14.2-x86_64-linux)
69
+ minitest (5.25.1)
70
+ nokogiri (1.16.7-arm64-darwin)
67
71
  racc (~> 1.4)
68
- parallel (1.22.1)
69
- parser (3.2.1.1)
72
+ nokogiri (1.16.7-x86_64-linux)
73
+ racc (~> 1.4)
74
+ parallel (1.26.3)
75
+ parser (3.3.4.2)
70
76
  ast (~> 2.4.1)
77
+ racc
71
78
  pg (1.4.6)
72
- racc (1.6.2)
73
- rack (2.2.6.4)
79
+ racc (1.8.1)
80
+ rack (2.2.9)
74
81
  rack-test (2.1.0)
75
82
  rack (>= 1.3)
76
83
  rails-dom-testing (2.0.3)
@@ -87,8 +94,9 @@ GEM
87
94
  zeitwerk (~> 2.5)
88
95
  rainbow (3.1.1)
89
96
  rake (13.0.6)
90
- regexp_parser (2.7.0)
91
- rexml (3.2.5)
97
+ regexp_parser (2.9.2)
98
+ rexml (3.3.6)
99
+ strscan
92
100
  rspec (3.11.0)
93
101
  rspec-core (~> 3.11.0)
94
102
  rspec-expectations (~> 3.11.0)
@@ -110,38 +118,46 @@ GEM
110
118
  rspec-mocks (~> 3.11)
111
119
  rspec-support (~> 3.11)
112
120
  rspec-support (3.11.0)
113
- rubocop (1.48.1)
121
+ rubocop (1.65.1)
114
122
  json (~> 2.3)
123
+ language_server-protocol (>= 3.17.0)
115
124
  parallel (~> 1.10)
116
- parser (>= 3.2.0.0)
125
+ parser (>= 3.3.0.2)
117
126
  rainbow (>= 2.2.2, < 4.0)
118
- regexp_parser (>= 1.8, < 3.0)
127
+ regexp_parser (>= 2.4, < 3.0)
119
128
  rexml (>= 3.2.5, < 4.0)
120
- rubocop-ast (>= 1.26.0, < 2.0)
129
+ rubocop-ast (>= 1.31.1, < 2.0)
121
130
  ruby-progressbar (~> 1.7)
122
131
  unicode-display_width (>= 2.4.0, < 3.0)
123
- rubocop-ast (1.28.0)
124
- parser (>= 3.2.1.0)
125
- rubocop-capybara (2.17.1)
132
+ rubocop-ast (1.32.1)
133
+ parser (>= 3.3.1.0)
134
+ rubocop-capybara (2.21.0)
126
135
  rubocop (~> 1.41)
127
- rubocop-performance (1.16.0)
128
- rubocop (>= 1.7.0, < 2.0)
129
- rubocop-ast (>= 0.4.0)
130
- rubocop-rails (2.18.0)
136
+ rubocop-factory_bot (2.26.1)
137
+ rubocop (~> 1.61)
138
+ rubocop-performance (1.21.1)
139
+ rubocop (>= 1.48.1, < 2.0)
140
+ rubocop-ast (>= 1.31.1, < 2.0)
141
+ rubocop-rails (2.26.0)
131
142
  activesupport (>= 4.2.0)
132
143
  rack (>= 1.1)
133
- rubocop (>= 1.33.0, < 2.0)
134
- rubocop-rspec (2.19.0)
135
- rubocop (~> 1.33)
136
- rubocop-capybara (~> 2.17)
144
+ rubocop (>= 1.52.0, < 2.0)
145
+ rubocop-ast (>= 1.31.1, < 2.0)
146
+ rubocop-rspec (3.0.4)
147
+ rubocop (~> 1.61)
148
+ rubocop-rspec_rails (2.30.0)
149
+ rubocop (~> 1.61)
150
+ rubocop-rspec (~> 3, >= 3.0.1)
137
151
  ruby-progressbar (1.13.0)
152
+ strscan (3.1.0)
138
153
  thor (1.2.1)
139
154
  tzinfo (2.0.6)
140
155
  concurrent-ruby (~> 1.0)
141
- unicode-display_width (2.4.2)
156
+ unicode-display_width (2.5.0)
142
157
  zeitwerk (2.6.7)
143
158
 
144
159
  PLATFORMS
160
+ arm64-darwin-23
145
161
  x86_64-linux
146
162
 
147
163
  DEPENDENCIES
data/README.md CHANGED
@@ -38,7 +38,7 @@ changed_ids =
38
38
  { id: 1, address: { city: 'Berlin' }, name: 'Hanz' },
39
39
  { id: 2, address: { city: 'London' }, name: 'John' }
40
40
  ],
41
- key_to_match: :id,
41
+ key_to_match: :id, # :key_to_match can be omitted if it matches primary key
42
42
  )
43
43
  ```
44
44
 
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,23 @@
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?
16
+
17
+ keyword_args[:key_to_match] ||= primary_key
9
18
 
10
- case subclass.connection.raw_connection
11
- when ::PG::Connection
12
- subclass.extend UpdateValuesAll::Adapters::Postgres
13
- end
19
+ if defined?(::PG::Connection) && connection.raw_connection.is_a?(::PG::Connection)
20
+ pg_update_values_all(data, **keyword_args)
14
21
  end
15
22
  end
16
23
 
@@ -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.1.0'
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
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.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergei Malykh
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-28 00:00:00.000000000 Z
11
+ date: 2024-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.2'
27
- description:
27
+ description:
28
28
  email:
29
29
  - xronos.i.am@gmail.com
30
30
  executables: []
@@ -48,7 +48,6 @@ files:
48
48
  - lib/update_values_all/batch_update.rb
49
49
  - lib/update_values_all/railtie.rb
50
50
  - lib/update_values_all/version.rb
51
- - update_values_all.gemspec
52
51
  homepage: https://github.com/corp-gp/update_values_all
53
52
  licenses:
54
53
  - MIT
@@ -58,7 +57,7 @@ metadata:
58
57
  source_code_uri: https://github.com/corp-gp/update_values_all
59
58
  changelog_uri: https://github.com/corp-gp/update_values_all/CHANGELOG.md
60
59
  rubygems_mfa_required: 'true'
61
- post_install_message:
60
+ post_install_message:
62
61
  rdoc_options: []
63
62
  require_paths:
64
63
  - lib
@@ -73,8 +72,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
72
  - !ruby/object:Gem::Version
74
73
  version: '0'
75
74
  requirements: []
76
- rubygems_version: 3.4.6
77
- signing_key:
75
+ rubygems_version: 3.3.17
76
+ signing_key:
78
77
  specification_version: 4
79
78
  summary: The gem allows to update AR-records in batch
80
79
  test_files: []
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/update_values_all/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "update_values_all"
7
- spec.version = UpdateValuesAll::VERSION
8
- spec.authors = ["Sergei Malykh"]
9
- spec.email = ["xronos.i.am@gmail.com"]
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"
15
-
16
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
17
-
18
- spec.metadata['homepage_uri'] = spec.homepage
19
- spec.metadata['source_code_uri'] = 'https://github.com/corp-gp/update_values_all'
20
- spec.metadata['changelog_uri'] = 'https://github.com/corp-gp/update_values_all/CHANGELOG.md'
21
-
22
- # Specify which files should be added to the gem when it is released.
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)})
27
- end
28
- end
29
- spec.require_paths = ['lib']
30
-
31
- spec.add_dependency 'activerecord', '>= 4.2'
32
-
33
- # For more information and examples about making a new gem, check out our
34
- # guide at: https://bundler.io/guides/creating_gem.html
35
- spec.metadata['rubygems_mfa_required'] = 'true'
36
- end