umbrellio-utils 0.4.2 → 0.5.1

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: 0f1da3d7102c650b1eab97c3bcd0e1b591ce801cd6d059fd587d08973584caec
4
- data.tar.gz: a0c872a73093def0f6619ef4470483246509b1354ae9b2d18cef072b57468de7
3
+ metadata.gz: 3d58375aae7fbe533515bb3437dd111f9b857fac6b6b1281ba707c262abcc406
4
+ data.tar.gz: 8440dc7bf3bdb1fe7dc36d534055e586f7f1f9831beb37c8f50c10347f2b1862
5
5
  SHA512:
6
- metadata.gz: 152ec5b9c0664c3c25726f94f9feac298465ed8d779057d27ad19e58cd5b18f614871857467cf5452ca5aa904a640ed84789a9442feef2924807943f0bf9b692
7
- data.tar.gz: f6d80689b65a50b82bdadc32d3a4ee391e4c18be22111e5e20204cf5401d91ebcabdfd358520d04201d405835bb79debee639ed0fb8e034e2845f1599cdcce92
6
+ metadata.gz: c426a03b8f9f915c5d39581381ec96083cbf79c463fe15ff94d42c97b5c95feb92efee53329d46639b353398ad7616aa750e054ac0a9d309f7b0bcf7f6fc3fb3
7
+ data.tar.gz: e9583b6c1d3fe2071ff3d18fc1e8cc0b51eb648575dddc02098df2134516d4edd73089435e32ef11b577b8860ea0e5ffe50efdce1754255b360a6357163842c2
@@ -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,133 +1,138 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- umbrellio-utils (0.4.2)
4
+ umbrellio-utils (0.5.1)
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
134
+ arm64-darwin-21
135
+ ruby
131
136
  x86_64-darwin-20
132
137
  x86_64-linux
133
138
 
@@ -151,4 +156,4 @@ DEPENDENCIES
151
156
  yard
152
157
 
153
158
  BUNDLED WITH
154
- 2.2.31
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_interval_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
@@ -53,7 +53,7 @@ module UmbrellioUtils
53
53
  attr_accessor :request
54
54
 
55
55
  def parse_params
56
- case request.content_type
56
+ case request.media_type
57
57
  when "application/json"
58
58
  Parsing.safely_parse_json(body)
59
59
  when "application/xml"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UmbrellioUtils
4
- VERSION = "0.4.2"
4
+ VERSION = "0.5.1"
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.2
4
+ version: 0.5.1
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-10 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.2.31
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