umbrellio-utils 0.4.3 → 0.5.2

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: a50b129107cbc0b88c6ca792692965517f94d37d55585a4c872ac7ed33f96144
4
+ data.tar.gz: 5fb7a079b3510edd5ea05a93e9752eba6ce02aba59a7160f8bd06c1ea2344086
5
5
  SHA512:
6
- metadata.gz: b3c4ee473805b89b4b8f9e7c3de13c4ddbf5d7d3e22062c2e311149b5c2a9aa7d92d581523f5d586e015c0d4c54d3af0f8a89b2bfb84eeb24a26f0e6b97ffda8
7
- data.tar.gz: e3aea7d7838ebd2ff3dd3b2d8fb7449563122349f099d469ea217e3fc4c8702b026c94e4240853f64fd402556a250e00a1fbc33b9ce3f46713565a55b3f7da9b
6
+ metadata.gz: c3d0a08ffac0fac4c414bcdc695ec4b34730f7c1d6570cc8f73328885d3e950ef684c0a96911fd3838de5d4c008b56d96a702599f0b7e7f039bd65ee146a7e21
7
+ data.tar.gz: e066d6dc4d56ffc7842cc26e787431d053ba441b8c2ebeaa57d57533a4eb47416778860959fb65ace91d95d965d7782591964983d762c587b998666b856e752f
@@ -3,53 +3,60 @@ name: Test
3
3
  on: [push, pull_request]
4
4
 
5
5
  env:
6
- FULL_COVERAGE_CHECK: false # Sometimes, sometimes...
6
+ FULL_COVERAGE_CHECK: false # Someday, someday...
7
7
 
8
8
  jobs:
9
- full-check:
9
+ test:
10
10
  runs-on: ubuntu-latest
11
11
 
12
12
  # We want to run on external PRs, but not on our own internal PRs as they'll be run on push event
13
13
  if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'umbrellio/utils'
14
14
 
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby: ["2.7", "3.0", "3.1"]
19
+
20
+ services:
21
+ postgres:
22
+ image: postgres
23
+ env:
24
+ POSTGRES_USER: root
25
+ POSTGRES_HOST_AUTH_METHOD: trust
26
+ options: >-
27
+ --health-cmd pg_isready
28
+ --health-interval 10s
29
+ --health-timeout 5s
30
+ --health-retries 5
31
+ ports:
32
+ - 5432:5432
33
+ env:
34
+ PGHOST: localhost
35
+ PGUSER: root
36
+
15
37
  steps:
16
38
  - uses: actions/checkout@v2
39
+
17
40
  - uses: ruby/setup-ruby@v1
18
41
  with:
19
- ruby-version: 3
42
+ ruby-version: ${{ matrix.ruby }}
20
43
  bundler-cache: true
44
+
45
+ - run: psql -c 'CREATE DATABASE umbrellio_utils_test'
46
+
21
47
  - name: Run Linter
22
48
  run: bundle exec ci-helper RubocopLint
49
+
23
50
  - name: Check missed spec suffixes
24
51
  run: bundle exec ci-helper CheckSpecSuffixes --extra-paths spec/*.rb --ignored-paths spec/*_helper.rb
52
+
25
53
  - name: Run specs
26
54
  run: bundle exec ci-helper RunSpecs
55
+
27
56
  - name: Audit
28
57
  run: bundle exec ci-helper BundlerAudit
58
+
29
59
  - name: Coveralls
30
60
  uses: coverallsapp/github-action@master
31
61
  with:
32
62
  github-token: ${{ secrets.GITHUB_TOKEN }}
33
- specs:
34
- runs-on: ubuntu-latest
35
-
36
- env:
37
- FULL_TEST_COVERAGE_CHECK: false
38
-
39
- # We want to run on external PRs, but not on our own internal PRs as they'll be run on push event
40
- if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'umbrellio/utils'
41
-
42
- strategy:
43
- fail-fast: false
44
- matrix:
45
- ruby: [2.6, 2.7]
46
-
47
-
48
- steps:
49
- - uses: actions/checkout@v2
50
- - uses: ruby/setup-ruby@v1
51
- with:
52
- ruby-version: ${{ matrix.ruby }}
53
- bundler-cache: true
54
- - name: Run specs
55
- run: bundle exec rspec
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /log/
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"]
@@ -21,3 +21,6 @@ Naming/RescuedExceptionsVariableName:
21
21
  Style/HashConversion:
22
22
  Exclude:
23
23
  - spec/**/*_spec.rb
24
+
25
+ Naming/VariableNumber:
26
+ CheckSymbols: false
data/Gemfile.lock CHANGED
@@ -1,134 +1,139 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- umbrellio-utils (0.4.3)
4
+ umbrellio-utils (0.5.2)
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)
51
+ pg (1.4.2)
48
52
  pry (0.14.1)
49
53
  coderay (~> 1.1)
50
54
  method_source (~> 1.0)
51
55
  racc (1.6.0)
52
- rack (2.2.3)
53
- rainbow (3.0.0)
56
+ rack (2.2.4)
57
+ rainbow (3.1.1)
54
58
  rake (13.0.6)
55
- regexp_parser (2.1.1)
59
+ regexp_parser (2.5.0)
56
60
  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)
61
+ rspec (3.11.0)
62
+ rspec-core (~> 3.11.0)
63
+ rspec-expectations (~> 3.11.0)
64
+ rspec-mocks (~> 3.11.0)
65
+ rspec-core (3.11.0)
66
+ rspec-support (~> 3.11.0)
67
+ rspec-expectations (3.11.0)
64
68
  diff-lcs (>= 1.2.0, < 2.0)
65
- rspec-support (~> 3.10.0)
66
- rspec-json_matcher (0.1.6)
67
- awesome_print
69
+ rspec-support (~> 3.11.0)
70
+ rspec-json_matcher (0.2.0)
71
+ amazing_print
68
72
  json
69
- rspec-mocks (3.10.2)
73
+ rspec-mocks (3.11.1)
70
74
  diff-lcs (>= 1.2.0, < 2.0)
71
- rspec-support (~> 3.10.0)
72
- rspec-support (3.10.2)
73
- rubocop (1.17.0)
75
+ rspec-support (~> 3.11.0)
76
+ rspec-support (3.11.0)
77
+ rubocop (1.30.1)
74
78
  parallel (~> 1.10)
75
- parser (>= 3.0.0.0)
79
+ parser (>= 3.1.0.0)
76
80
  rainbow (>= 2.2.2, < 4.0)
77
81
  regexp_parser (>= 1.8, < 3.0)
78
- rexml
79
- rubocop-ast (>= 1.7.0, < 2.0)
82
+ rexml (>= 3.2.5, < 4.0)
83
+ rubocop-ast (>= 1.18.0, < 2.0)
80
84
  ruby-progressbar (~> 1.7)
81
85
  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)
86
+ rubocop-ast (1.19.1)
87
+ parser (>= 3.1.1.0)
88
+ rubocop-config-umbrellio (1.30.0.65)
89
+ rubocop (~> 1.30.0)
90
+ rubocop-performance (~> 1.14.0)
91
+ rubocop-rails (~> 2.14.2)
92
+ rubocop-rake (~> 0.6.0)
93
+ rubocop-rspec (~> 2.11.1)
94
+ rubocop-sequel (~> 0.3.3)
95
+ rubocop-performance (1.14.3)
96
+ rubocop (>= 1.7.0, < 2.0)
93
97
  rubocop-ast (>= 0.4.0)
94
- rubocop-rails (2.9.1)
98
+ rubocop-rails (2.14.2)
95
99
  activesupport (>= 4.2.0)
96
100
  rack (>= 1.1)
97
- rubocop (>= 0.90.0, < 2.0)
98
- rubocop-rake (0.5.1)
99
- rubocop
100
- rubocop-rspec (2.2.0)
101
+ rubocop (>= 1.7.0, < 2.0)
102
+ rubocop-rake (0.6.0)
101
103
  rubocop (~> 1.0)
102
- rubocop-ast (>= 1.1.0)
103
- rubocop-sequel (0.2.0)
104
+ rubocop-rspec (2.11.1)
105
+ rubocop (~> 1.19)
106
+ rubocop-sequel (0.3.4)
104
107
  rubocop (~> 1.0)
105
108
  ruby-progressbar (1.11.0)
106
109
  ruby2_keywords (0.0.5)
107
- semantic_logger (4.8.2)
110
+ semantic_logger (4.11.0)
108
111
  concurrent-ruby (~> 1.0)
109
- sequel (5.49.0)
112
+ sequel (5.58.0)
110
113
  simplecov (0.21.2)
111
114
  docile (~> 1.1)
112
115
  simplecov-html (~> 0.11)
113
116
  simplecov_json_formatter (~> 0.1)
114
117
  simplecov-html (0.12.3)
115
118
  simplecov-lcov (0.8.0)
116
- simplecov_json_formatter (0.1.3)
119
+ simplecov_json_formatter (0.1.4)
117
120
  symbiont-ruby (0.7.0)
118
- thor (1.1.0)
119
- timecop (0.9.4)
120
- tzinfo (2.0.4)
121
+ thor (1.2.1)
122
+ timecop (0.9.5)
123
+ tzinfo (2.0.5)
121
124
  concurrent-ruby (~> 1.0)
122
- umbrellio-sequel-plugins (0.5.1.27)
125
+ umbrellio-sequel-plugins (0.9.0.76)
123
126
  sequel
124
127
  symbiont-ruby
125
- unicode-display_width (2.1.0)
126
- yard (0.9.26)
127
- zeitwerk (2.5.1)
128
+ unicode-display_width (2.2.0)
129
+ webrick (1.7.0)
130
+ yard (0.9.28)
131
+ webrick (~> 1.7.0)
128
132
 
129
133
  PLATFORMS
130
134
  arm64-darwin-20
131
135
  arm64-darwin-21
136
+ ruby
132
137
  x86_64-darwin-20
133
138
  x86_64-linux
134
139
 
@@ -139,12 +144,14 @@ DEPENDENCIES
139
144
  ci-helper
140
145
  nokogiri
141
146
  nori
147
+ pg
142
148
  pry
143
149
  rake
144
150
  rspec
145
151
  rspec-json_matcher
146
152
  rubocop-config-umbrellio
147
153
  semantic_logger
154
+ sequel
148
155
  simplecov
149
156
  simplecov-lcov
150
157
  timecop
@@ -152,4 +159,4 @@ DEPENDENCIES
152
159
  yard
153
160
 
154
161
  BUNDLED WITH
155
- 2.3.0
162
+ 2.3.19
@@ -22,16 +22,16 @@ module UmbrellioUtils
22
22
  end
23
23
 
24
24
  def each_record(dataset, **options, &block)
25
- primary_key = primary_key_from(options)
25
+ primary_key = primary_key_from(**options)
26
+
26
27
  with_temp_table(dataset, **options) do |ids|
27
- dataset.model.where(primary_key => ids).each(&block)
28
+ dataset.model.where(primary_key => ids).reverse(primary_key).each(&block)
28
29
  end
29
30
  end
30
31
 
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?)
32
+ def with_temp_table(dataset, page_size: 1_000, sleep: nil, **options)
33
+ primary_key = primary_key_from(**options)
34
+ sleep_interval = sleep_interval_from(sleep)
35
35
 
36
36
  temp_table_name = create_temp_table(dataset, primary_key: primary_key)
37
37
 
@@ -49,7 +49,7 @@ module UmbrellioUtils
49
49
 
50
50
  break if pk_set.empty?
51
51
 
52
- sleep(1) if do_sleep
52
+ Kernel.sleep(sleep_interval) if sleep_interval.positive?
53
53
  clear_lamian_logs!
54
54
  end
55
55
  ensure
@@ -57,6 +57,7 @@ module UmbrellioUtils
57
57
  end
58
58
 
59
59
  def clear_lamian_logs!
60
+ return unless defined?(Lamian)
60
61
  Lamian.logger.send(:logdevs).each { |x| x.truncate(0) && x.rewind }
61
62
  end
62
63
 
@@ -78,8 +79,19 @@ module UmbrellioUtils
78
79
 
79
80
  private
80
81
 
81
- def primary_key_from(options)
82
+ def primary_key_from(**options)
82
83
  options.fetch(:primary_key, :id)
83
84
  end
85
+
86
+ def sleep_interval_from(sleep)
87
+ case sleep
88
+ when Numeric
89
+ sleep
90
+ when FalseClass
91
+ 0
92
+ else
93
+ defined?(Rails) && Rails.env.production? ? 1 : 0
94
+ end
95
+ end
84
96
  end
85
97
  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.2"
5
5
  end
data/log/.keep ADDED
File without changes
@@ -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"
@@ -35,12 +35,14 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency "ci-helper"
36
36
  spec.add_development_dependency "nokogiri"
37
37
  spec.add_development_dependency "nori"
38
+ spec.add_development_dependency "pg"
38
39
  spec.add_development_dependency "pry"
39
40
  spec.add_development_dependency "rake"
40
41
  spec.add_development_dependency "rspec"
41
42
  spec.add_development_dependency "rspec-json_matcher"
42
43
  spec.add_development_dependency "rubocop-config-umbrellio"
43
44
  spec.add_development_dependency "semantic_logger"
45
+ spec.add_development_dependency "sequel"
44
46
  spec.add_development_dependency "simplecov"
45
47
  spec.add_development_dependency "simplecov-lcov"
46
48
  spec.add_development_dependency "timecop"
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.2
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-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: memery
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pg
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: pry
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +206,20 @@ dependencies:
192
206
  - - ">="
193
207
  - !ruby/object:Gem::Version
194
208
  version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: sequel
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
195
223
  - !ruby/object:Gem::Dependency
196
224
  name: simplecov
197
225
  requirement: !ruby/object:Gem::Requirement
@@ -286,6 +314,7 @@ files:
286
314
  - lib/umbrellio_utils/store.rb
287
315
  - lib/umbrellio_utils/vault.rb
288
316
  - lib/umbrellio_utils/version.rb
317
+ - log/.keep
289
318
  - umbrellio_utils.gemspec
290
319
  homepage: https://github.com/umbrellio/utils
291
320
  licenses:
@@ -302,14 +331,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
302
331
  requirements:
303
332
  - - ">="
304
333
  - !ruby/object:Gem::Version
305
- version: 2.6.0
334
+ version: 2.7.0
306
335
  required_rubygems_version: !ruby/object:Gem::Requirement
307
336
  requirements:
308
337
  - - ">="
309
338
  - !ruby/object:Gem::Version
310
339
  version: '0'
311
340
  requirements: []
312
- rubygems_version: 3.3.0
341
+ rubygems_version: 3.3.17
313
342
  signing_key:
314
343
  specification_version: 4
315
344
  summary: A set of utilities that speed up development