umbrellio-utils 0.4.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6591e877185cd730c9c7fffd76144a0ab204fd8b3c69ea1765be7876209e715c
4
- data.tar.gz: c08f9523f33faf6f6ea605edf44a9bb13a600e6fcfdf7620fadcde1f666dea78
3
+ metadata.gz: c467440e60fca9a678c36cf4ef98a64bf907d6255ab125fa49c1c5a7bebcc58c
4
+ data.tar.gz: ae937f7096cd4cc0facc940990cfffd0263cf16d8f568628cef84fd78d36d4cf
5
5
  SHA512:
6
- metadata.gz: b3c4ee473805b89b4b8f9e7c3de13c4ddbf5d7d3e22062c2e311149b5c2a9aa7d92d581523f5d586e015c0d4c54d3af0f8a89b2bfb84eeb24a26f0e6b97ffda8
7
- data.tar.gz: e3aea7d7838ebd2ff3dd3b2d8fb7449563122349f099d469ea217e3fc4c8702b026c94e4240853f64fd402556a250e00a1fbc33b9ce3f46713565a55b3f7da9b
6
+ metadata.gz: cd966392f19e67cf5c7fbc36d9b2e5add185160d6cc7d3679efa6d3a40884eec37f83467af847b29bc14ddc8cced216e39402b6c645abcb6811162e7f59ad3cc
7
+ data.tar.gz: fbaad56491705678f219b645f535e4a409d42007ccdbbe6aaaa4f6c76f79e48f48132e44fea3d98952636d72cc1f9f0ea0465328feed1998170faf04448b50b2
@@ -16,7 +16,7 @@ jobs:
16
16
  - uses: actions/checkout@v2
17
17
  - uses: ruby/setup-ruby@v1
18
18
  with:
19
- ruby-version: 3
19
+ ruby-version: "3.1"
20
20
  bundler-cache: true
21
21
  - name: Run Linter
22
22
  run: bundle exec ci-helper RubocopLint
@@ -42,8 +42,7 @@ jobs:
42
42
  strategy:
43
43
  fail-fast: false
44
44
  matrix:
45
- ruby: [2.6, 2.7]
46
-
45
+ ruby: ["2.7", "3.0"]
47
46
 
48
47
  steps:
49
48
  - uses: actions/checkout@v2
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ inherit_gem:
3
3
 
4
4
  AllCops:
5
5
  DisplayCopNames: true
6
- TargetRubyVersion: 2.6
6
+ TargetRubyVersion: 2.7
7
7
 
8
8
  Naming/MethodParameterName:
9
9
  AllowedNames: ["x", "y", "z"]
data/Gemfile.lock CHANGED
@@ -1,134 +1,138 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- umbrellio-utils (0.4.3)
4
+ umbrellio-utils (0.5.0)
5
5
  memery (~> 1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (6.1.4.1)
10
+ activesupport (7.0.3.1)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 1.6, < 2)
13
13
  minitest (>= 5.1)
14
14
  tzinfo (~> 2.0)
15
- zeitwerk (~> 2.3)
15
+ amazing_print (1.4.0)
16
16
  ast (2.4.2)
17
- awesome_print (1.9.2)
18
- bundler-audit (0.9.0.1)
17
+ bundler-audit (0.9.1)
19
18
  bundler (>= 1.2.0, < 3)
20
19
  thor (~> 1.0)
21
- ci-helper (0.4.2)
20
+ ci-helper (0.5.0)
22
21
  colorize (~> 0.8)
23
22
  dry-inflector (~> 0.2)
24
23
  umbrellio-sequel-plugins (~> 0.4)
25
24
  coderay (1.1.3)
26
25
  colorize (0.8.1)
27
- concurrent-ruby (1.1.9)
28
- diff-lcs (1.4.4)
26
+ concurrent-ruby (1.1.10)
27
+ diff-lcs (1.5.0)
29
28
  docile (1.4.0)
30
- dry-inflector (0.2.1)
31
- i18n (1.8.10)
29
+ dry-inflector (0.3.0)
30
+ i18n (1.12.0)
32
31
  concurrent-ruby (~> 1.0)
33
- json (2.6.1)
32
+ json (2.6.2)
34
33
  memery (1.4.1)
35
34
  ruby2_keywords (~> 0.0.2)
36
35
  method_source (1.0.0)
37
- minitest (5.14.4)
38
- nokogiri (1.12.5-arm64-darwin)
36
+ mini_portile2 (2.8.0)
37
+ minitest (5.16.2)
38
+ nokogiri (1.13.8)
39
+ mini_portile2 (~> 2.8.0)
39
40
  racc (~> 1.4)
40
- nokogiri (1.12.5-x86_64-darwin)
41
+ nokogiri (1.13.8-arm64-darwin)
41
42
  racc (~> 1.4)
42
- nokogiri (1.12.5-x86_64-linux)
43
+ nokogiri (1.13.8-x86_64-darwin)
44
+ racc (~> 1.4)
45
+ nokogiri (1.13.8-x86_64-linux)
43
46
  racc (~> 1.4)
44
47
  nori (2.6.0)
45
- parallel (1.21.0)
46
- parser (3.0.2.0)
48
+ parallel (1.22.1)
49
+ parser (3.1.2.0)
47
50
  ast (~> 2.4.1)
48
51
  pry (0.14.1)
49
52
  coderay (~> 1.1)
50
53
  method_source (~> 1.0)
51
54
  racc (1.6.0)
52
- rack (2.2.3)
53
- rainbow (3.0.0)
55
+ rack (2.2.4)
56
+ rainbow (3.1.1)
54
57
  rake (13.0.6)
55
- regexp_parser (2.1.1)
58
+ regexp_parser (2.5.0)
56
59
  rexml (3.2.5)
57
- rspec (3.10.0)
58
- rspec-core (~> 3.10.0)
59
- rspec-expectations (~> 3.10.0)
60
- rspec-mocks (~> 3.10.0)
61
- rspec-core (3.10.1)
62
- rspec-support (~> 3.10.0)
63
- rspec-expectations (3.10.1)
60
+ rspec (3.11.0)
61
+ rspec-core (~> 3.11.0)
62
+ rspec-expectations (~> 3.11.0)
63
+ rspec-mocks (~> 3.11.0)
64
+ rspec-core (3.11.0)
65
+ rspec-support (~> 3.11.0)
66
+ rspec-expectations (3.11.0)
64
67
  diff-lcs (>= 1.2.0, < 2.0)
65
- rspec-support (~> 3.10.0)
66
- rspec-json_matcher (0.1.6)
67
- awesome_print
68
+ rspec-support (~> 3.11.0)
69
+ rspec-json_matcher (0.2.0)
70
+ amazing_print
68
71
  json
69
- rspec-mocks (3.10.2)
72
+ rspec-mocks (3.11.1)
70
73
  diff-lcs (>= 1.2.0, < 2.0)
71
- rspec-support (~> 3.10.0)
72
- rspec-support (3.10.2)
73
- rubocop (1.17.0)
74
+ rspec-support (~> 3.11.0)
75
+ rspec-support (3.11.0)
76
+ rubocop (1.30.1)
74
77
  parallel (~> 1.10)
75
- parser (>= 3.0.0.0)
78
+ parser (>= 3.1.0.0)
76
79
  rainbow (>= 2.2.2, < 4.0)
77
80
  regexp_parser (>= 1.8, < 3.0)
78
- rexml
79
- rubocop-ast (>= 1.7.0, < 2.0)
81
+ rexml (>= 3.2.5, < 4.0)
82
+ rubocop-ast (>= 1.18.0, < 2.0)
80
83
  ruby-progressbar (~> 1.7)
81
84
  unicode-display_width (>= 1.4.0, < 3.0)
82
- rubocop-ast (1.12.0)
83
- parser (>= 3.0.1.1)
84
- rubocop-config-umbrellio (1.17.0.53)
85
- rubocop (= 1.17.0)
86
- rubocop-performance (= 1.10.0)
87
- rubocop-rails (= 2.9.1)
88
- rubocop-rake (= 0.5.1)
89
- rubocop-rspec (= 2.2.0)
90
- rubocop-sequel (= 0.2.0)
91
- rubocop-performance (1.10.0)
92
- rubocop (>= 0.90.0, < 2.0)
85
+ rubocop-ast (1.19.1)
86
+ parser (>= 3.1.1.0)
87
+ rubocop-config-umbrellio (1.30.0.65)
88
+ rubocop (~> 1.30.0)
89
+ rubocop-performance (~> 1.14.0)
90
+ rubocop-rails (~> 2.14.2)
91
+ rubocop-rake (~> 0.6.0)
92
+ rubocop-rspec (~> 2.11.1)
93
+ rubocop-sequel (~> 0.3.3)
94
+ rubocop-performance (1.14.3)
95
+ rubocop (>= 1.7.0, < 2.0)
93
96
  rubocop-ast (>= 0.4.0)
94
- rubocop-rails (2.9.1)
97
+ rubocop-rails (2.14.2)
95
98
  activesupport (>= 4.2.0)
96
99
  rack (>= 1.1)
97
- rubocop (>= 0.90.0, < 2.0)
98
- rubocop-rake (0.5.1)
99
- rubocop
100
- rubocop-rspec (2.2.0)
100
+ rubocop (>= 1.7.0, < 2.0)
101
+ rubocop-rake (0.6.0)
101
102
  rubocop (~> 1.0)
102
- rubocop-ast (>= 1.1.0)
103
- rubocop-sequel (0.2.0)
103
+ rubocop-rspec (2.11.1)
104
+ rubocop (~> 1.19)
105
+ rubocop-sequel (0.3.4)
104
106
  rubocop (~> 1.0)
105
107
  ruby-progressbar (1.11.0)
106
108
  ruby2_keywords (0.0.5)
107
- semantic_logger (4.8.2)
109
+ semantic_logger (4.11.0)
108
110
  concurrent-ruby (~> 1.0)
109
- sequel (5.49.0)
111
+ sequel (5.58.0)
110
112
  simplecov (0.21.2)
111
113
  docile (~> 1.1)
112
114
  simplecov-html (~> 0.11)
113
115
  simplecov_json_formatter (~> 0.1)
114
116
  simplecov-html (0.12.3)
115
117
  simplecov-lcov (0.8.0)
116
- simplecov_json_formatter (0.1.3)
118
+ simplecov_json_formatter (0.1.4)
117
119
  symbiont-ruby (0.7.0)
118
- thor (1.1.0)
119
- timecop (0.9.4)
120
- tzinfo (2.0.4)
120
+ thor (1.2.1)
121
+ timecop (0.9.5)
122
+ tzinfo (2.0.5)
121
123
  concurrent-ruby (~> 1.0)
122
- umbrellio-sequel-plugins (0.5.1.27)
124
+ umbrellio-sequel-plugins (0.9.0.76)
123
125
  sequel
124
126
  symbiont-ruby
125
- unicode-display_width (2.1.0)
126
- yard (0.9.26)
127
- zeitwerk (2.5.1)
127
+ unicode-display_width (2.2.0)
128
+ webrick (1.7.0)
129
+ yard (0.9.28)
130
+ webrick (~> 1.7.0)
128
131
 
129
132
  PLATFORMS
130
133
  arm64-darwin-20
131
134
  arm64-darwin-21
135
+ ruby
132
136
  x86_64-darwin-20
133
137
  x86_64-linux
134
138
 
@@ -152,4 +156,4 @@ DEPENDENCIES
152
156
  yard
153
157
 
154
158
  BUNDLED WITH
155
- 2.3.0
159
+ 2.3.19
@@ -6,6 +6,8 @@ module UmbrellioUtils
6
6
 
7
7
  HandledConstaintError = Class.new(StandardError)
8
8
 
9
+ DEFAULT_SLEEP_INTERVAL = defined?(Rails) && Rails.env.production? ? 1 : 0
10
+
9
11
  def handle_constraint_error(constraint_name, &block)
10
12
  DB.transaction(savepoint: true, &block)
11
13
  rescue Sequel::UniqueConstraintViolation => e
@@ -22,16 +24,16 @@ module UmbrellioUtils
22
24
  end
23
25
 
24
26
  def each_record(dataset, **options, &block)
25
- primary_key = primary_key_from(options)
27
+ primary_key = primary_key_from(**options)
28
+
26
29
  with_temp_table(dataset, **options) do |ids|
27
30
  dataset.model.where(primary_key => ids).each(&block)
28
31
  end
29
32
  end
30
33
 
31
- def with_temp_table(dataset, **options)
32
- primary_key = primary_key_from(options)
33
- page_size = options.fetch(:page_size, 1_000)
34
- do_sleep = options.fetch(:sleep, Rails.env.production?)
34
+ def with_temp_table(dataset, page_size: 1_000, sleep: nil, **options)
35
+ primary_key = primary_key_from(**options)
36
+ sleep_interval = sleep_interval_from(sleep)
35
37
 
36
38
  temp_table_name = create_temp_table(dataset, primary_key: primary_key)
37
39
 
@@ -49,7 +51,7 @@ module UmbrellioUtils
49
51
 
50
52
  break if pk_set.empty?
51
53
 
52
- sleep(1) if do_sleep
54
+ sleep(sleep_interval) if sleep_interval.positive?
53
55
  clear_lamian_logs!
54
56
  end
55
57
  ensure
@@ -78,8 +80,19 @@ module UmbrellioUtils
78
80
 
79
81
  private
80
82
 
81
- def primary_key_from(options)
83
+ def primary_key_from(**options)
82
84
  options.fetch(:primary_key, :id)
83
85
  end
86
+
87
+ def sleep_inteval_from(sleep)
88
+ case sleep
89
+ when Numeric
90
+ sleep
91
+ when FalseClass
92
+ 0
93
+ else
94
+ DEFAULT_SLEEP_INTERVAL
95
+ end
96
+ end
84
97
  end
85
98
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UmbrellioUtils
4
- VERSION = "0.4.3"
4
+ VERSION = "0.5.0"
5
5
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "UmbrellioUtils is collection of utility classes and helpers"
13
13
  spec.homepage = "https://github.com/umbrellio/utils"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/umbrellio/utils"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: umbrellio-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JustAnotherDude
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-22 00:00:00.000000000 Z
11
+ date: 2022-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: memery
@@ -302,14 +302,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
302
302
  requirements:
303
303
  - - ">="
304
304
  - !ruby/object:Gem::Version
305
- version: 2.6.0
305
+ version: 2.7.0
306
306
  required_rubygems_version: !ruby/object:Gem::Requirement
307
307
  requirements:
308
308
  - - ">="
309
309
  - !ruby/object:Gem::Version
310
310
  version: '0'
311
311
  requirements: []
312
- rubygems_version: 3.3.0
312
+ rubygems_version: 3.3.17
313
313
  signing_key:
314
314
  specification_version: 4
315
315
  summary: A set of utilities that speed up development