invoca-utils 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/pipeline.yml +20 -0
- data/.gitignore +1 -3
- data/.rspec +3 -0
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/Appraisals +13 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +9 -16
- data/Gemfile.lock +39 -48
- data/Rakefile +9 -6
- data/gemfiles/activesupport_5.gemfile +12 -0
- data/gemfiles/activesupport_5.gemfile.lock +58 -0
- data/gemfiles/activesupport_6.gemfile +12 -0
- data/gemfiles/activesupport_6.gemfile.lock +59 -0
- data/gemfiles/activesupport_7.gemfile +12 -0
- data/gemfiles/activesupport_7.gemfile.lock +57 -0
- data/invoca-utils.gemspec +18 -6
- data/lib/invoca/utils/exceptions.rb +5 -3
- data/lib/invoca/utils/version.rb +1 -1
- data/{test → spec}/helpers/constant_overrides.rb +0 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/unit/array_spec.rb +20 -0
- data/spec/unit/enumerable_spec.rb +80 -0
- data/{test/unit/exceptions_test.rb → spec/unit/exceptions_spec.rb} +17 -17
- data/spec/unit/guaranteed_utf8_string_spec.rb +260 -0
- data/spec/unit/hash_spec.rb +81 -0
- data/spec/unit/hash_with_indifferent_access_spec.rb +100 -0
- data/spec/unit/map_compact_spec.rb +25 -0
- data/{test/unit/module_test.rb → spec/unit/module_spec.rb} +4 -4
- data/spec/unit/multi_sender_spec.rb +54 -0
- data/{test/unit/stable_sort_test.rb → spec/unit/stable_sort_spec.rb} +14 -14
- data/spec/unit/time_calculations_spec.rb +39 -0
- data/{test/unit/utils_test.rb → spec/unit/utils_spec.rb} +14 -14
- metadata +59 -37
- data/.jenkins/Jenkinsfile +0 -50
- data/.jenkins/ruby_build_pod.yml +0 -19
- data/test/test_helper.rb +0 -14
- data/test/unit/array_test.rb +0 -20
- data/test/unit/enumerable_test.rb +0 -80
- data/test/unit/guaranteed_utf8_string_test.rb +0 -263
- data/test/unit/hash_test.rb +0 -81
- data/test/unit/hash_with_indifferent_access_test.rb +0 -100
- data/test/unit/map_compact_test.rb +0 -25
- data/test/unit/multi_sender_test.rb +0 -56
- data/test/unit/time_calculations_test.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99f6039ed702e76afaf3bd88fc084f158fcb7bbbf16cf9817a692b4adef8b5bc
|
4
|
+
data.tar.gz: 71c80ef09bfa85f98b889975e6c721f3f643d552f25cce6bb3a479216fd6b82a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04d05c8ea6ef6c3814b2f013d991328628af1907d4f1d703981896af36efadfcbf4344b63bcaba4eee1028951243db9cfc53bca352cd21c944ab58aed5bd3135
|
7
|
+
data.tar.gz: e5fa5ddcb14d16b44dab87bcff1f952b0588415de5ebd7e85bc6190c33bbcb82cc9a3834186441a32b2f1015872abfb789160b19d8a9d9f1910ba7eb85cdc64e
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
name: Pipeline
|
3
|
+
on: [push]
|
4
|
+
jobs:
|
5
|
+
tests:
|
6
|
+
name: Unit Tests
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
ruby: [2.5, 2.6, 2.7, '3.0', 3.1]
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: ${{ matrix.ruby }}
|
17
|
+
bundler: 2.2.29
|
18
|
+
bundler-cache: true
|
19
|
+
- name: Unit Tests
|
20
|
+
run: bundle exec rspec
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.5
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.7.5
|
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,14 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
5
5
|
Note: This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [0.5.0] - 2023-02-10
|
8
|
+
### Added
|
9
|
+
- Relaxed version requirement for ActiveSupport
|
10
|
+
|
11
|
+
## [0.4.1] - 2020-06-17
|
12
|
+
### Fixed
|
13
|
+
- Support Ruby < 2.5 by adding `begin`/`end` around `rescue` in `retry_on_exception`.
|
14
|
+
|
7
15
|
## [0.4.0] - 2020-06-09
|
8
16
|
### Added
|
9
17
|
- Added `Invoca::Utils.retry_on_exception`.
|
@@ -23,6 +31,8 @@ Note: This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
|
|
23
31
|
- Enumerable::build_hash method ported from HoboSupport
|
24
32
|
- Enumerable::* operator ported from HoboSupport
|
25
33
|
|
34
|
+
[0.5.0]: https://github.com/Invoca/invoca-utils/compare/v0.4.1...v0.5.0
|
35
|
+
[0.4.1]: https://github.com/Invoca/invoca-utils/compare/v0.4.0...v0.4.1
|
26
36
|
[0.4.0]: https://github.com/Invoca/invoca-utils/compare/v0.3.0...v0.4.0
|
27
37
|
[0.3.0]: https://github.com/Invoca/invoca-utils/compare/v0.2.0...v0.3.0
|
28
38
|
[0.2.0]: https://github.com/Invoca/invoca-utils/compare/v0.1.1...v0.2.0
|
data/Gemfile
CHANGED
@@ -2,21 +2,14 @@
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
+
# Specify your gem's run time dependencies in invoca-utils.gemspec
|
5
6
|
gemspec
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
gem 'shoulda', '= 3.5.0'
|
16
|
-
gem 'test-unit', '= 1.2.3'
|
17
|
-
gem 'tzinfo'
|
18
|
-
end
|
19
|
-
|
20
|
-
source 'https://gem.fury.io/invoca' do
|
21
|
-
gem 'test_overrides', '~> 0.13'
|
22
|
-
end
|
8
|
+
# Specify your gem's development and test dependencies below
|
9
|
+
gem "appraisal", "~> 2.4"
|
10
|
+
gem "rake", "~> 13.0"
|
11
|
+
gem "rspec", "~> 3.0"
|
12
|
+
gem "rspec_junit_formatter", "~> 0.4"
|
13
|
+
# minitest, which is a transitive dependency of activesupport,
|
14
|
+
# version should support ruby 2.5 which is the minimum github pipeline targets
|
15
|
+
gem "minitest", "~> 5.10.0"
|
data/Gemfile.lock
CHANGED
@@ -1,68 +1,59 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
invoca-utils (0.
|
4
|
+
invoca-utils (0.5.0)
|
5
|
+
activesupport (>= 5.0)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
|
-
remote: https://gem.fury.io/invoca/
|
9
9
|
specs:
|
10
|
-
activesupport (
|
11
|
-
|
10
|
+
activesupport (5.2.8.1)
|
11
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
+
i18n (>= 0.7, < 2)
|
12
13
|
minitest (~> 5.1)
|
13
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
14
14
|
tzinfo (~> 1.1)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
i18n (
|
15
|
+
appraisal (2.4.1)
|
16
|
+
bundler
|
17
|
+
rake
|
18
|
+
thor (>= 0.14.0)
|
19
|
+
concurrent-ruby (1.2.0)
|
20
|
+
diff-lcs (1.5.0)
|
21
|
+
i18n (1.12.0)
|
22
22
|
concurrent-ruby (~> 1.0)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
shoulda-matchers (2.8.0)
|
42
|
-
activesupport (>= 3.0.0)
|
43
|
-
test-unit (1.2.3)
|
44
|
-
hoe (>= 1.5.1)
|
45
|
-
test_overrides (0.13.0)
|
23
|
+
minitest (5.10.3)
|
24
|
+
rake (13.0.6)
|
25
|
+
rspec (3.12.0)
|
26
|
+
rspec-core (~> 3.12.0)
|
27
|
+
rspec-expectations (~> 3.12.0)
|
28
|
+
rspec-mocks (~> 3.12.0)
|
29
|
+
rspec-core (3.12.1)
|
30
|
+
rspec-support (~> 3.12.0)
|
31
|
+
rspec-expectations (3.12.2)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.12.0)
|
34
|
+
rspec-mocks (3.12.3)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.12.0)
|
37
|
+
rspec-support (3.12.0)
|
38
|
+
rspec_junit_formatter (0.6.0)
|
39
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
40
|
+
thor (1.2.1)
|
46
41
|
thread_safe (0.3.6)
|
47
|
-
tzinfo (1.2.
|
42
|
+
tzinfo (1.2.11)
|
48
43
|
thread_safe (~> 0.1)
|
49
44
|
|
50
45
|
PLATFORMS
|
46
|
+
arm64-darwin-22
|
51
47
|
ruby
|
48
|
+
x86_64-linux
|
52
49
|
|
53
50
|
DEPENDENCIES
|
54
|
-
|
51
|
+
appraisal (~> 2.4)
|
55
52
|
invoca-utils!
|
56
|
-
minitest
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
rr (= 1.1.2)!
|
61
|
-
ruby-prof!
|
62
|
-
shoulda (= 3.5.0)!
|
63
|
-
test-unit (= 1.2.3)!
|
64
|
-
test_overrides (~> 0.13)!
|
65
|
-
tzinfo!
|
53
|
+
minitest (~> 5.10.0)
|
54
|
+
rake (~> 13.0)
|
55
|
+
rspec (~> 3.0)
|
56
|
+
rspec_junit_formatter (~> 0.4)
|
66
57
|
|
67
58
|
BUNDLED WITH
|
68
|
-
|
59
|
+
2.2.29
|
data/Rakefile
CHANGED
@@ -2,11 +2,14 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require "bundler/gem_tasks"
|
5
|
-
require 'rake
|
6
|
-
require 'rake_test_warning_false'
|
5
|
+
require 'rake'
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
desc "run rspec unit tests"
|
8
|
+
begin
|
9
|
+
require 'rspec/core/rake_task'
|
10
|
+
RSpec::Core::RakeTask.new(:rspec) do |rspec_task|
|
11
|
+
rspec_task.pattern = "spec/**{,/*/**}/*_spec.rb"
|
12
|
+
end
|
12
13
|
end
|
14
|
+
|
15
|
+
task default: :rspec
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "appraisal", "~> 2.4"
|
6
|
+
gem "rake", "~> 13.0"
|
7
|
+
gem "rspec", "~> 3.0"
|
8
|
+
gem "rspec_junit_formatter", "~> 0.4"
|
9
|
+
gem "minitest", "~> 5.10.0"
|
10
|
+
gem "activesupport", "~> 5.2"
|
11
|
+
|
12
|
+
gemspec path: "../"
|
@@ -0,0 +1,58 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
invoca-utils (0.5.0)
|
5
|
+
activesupport (>= 5.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (5.2.8.1)
|
11
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
+
i18n (>= 0.7, < 2)
|
13
|
+
minitest (~> 5.1)
|
14
|
+
tzinfo (~> 1.1)
|
15
|
+
appraisal (2.4.1)
|
16
|
+
bundler
|
17
|
+
rake
|
18
|
+
thor (>= 0.14.0)
|
19
|
+
concurrent-ruby (1.2.0)
|
20
|
+
diff-lcs (1.5.0)
|
21
|
+
i18n (1.12.0)
|
22
|
+
concurrent-ruby (~> 1.0)
|
23
|
+
minitest (5.10.3)
|
24
|
+
rake (13.0.6)
|
25
|
+
rspec (3.12.0)
|
26
|
+
rspec-core (~> 3.12.0)
|
27
|
+
rspec-expectations (~> 3.12.0)
|
28
|
+
rspec-mocks (~> 3.12.0)
|
29
|
+
rspec-core (3.12.1)
|
30
|
+
rspec-support (~> 3.12.0)
|
31
|
+
rspec-expectations (3.12.2)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.12.0)
|
34
|
+
rspec-mocks (3.12.3)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.12.0)
|
37
|
+
rspec-support (3.12.0)
|
38
|
+
rspec_junit_formatter (0.6.0)
|
39
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
40
|
+
thor (1.2.1)
|
41
|
+
thread_safe (0.3.6)
|
42
|
+
tzinfo (1.2.11)
|
43
|
+
thread_safe (~> 0.1)
|
44
|
+
|
45
|
+
PLATFORMS
|
46
|
+
arm64-darwin-22
|
47
|
+
|
48
|
+
DEPENDENCIES
|
49
|
+
activesupport (~> 5.2)
|
50
|
+
appraisal (~> 2.4)
|
51
|
+
invoca-utils!
|
52
|
+
minitest (~> 5.10.0)
|
53
|
+
rake (~> 13.0)
|
54
|
+
rspec (~> 3.0)
|
55
|
+
rspec_junit_formatter (~> 0.4)
|
56
|
+
|
57
|
+
BUNDLED WITH
|
58
|
+
2.3.17
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "appraisal", "~> 2.4"
|
6
|
+
gem "rake", "~> 13.0"
|
7
|
+
gem "rspec", "~> 3.0"
|
8
|
+
gem "rspec_junit_formatter", "~> 0.4"
|
9
|
+
gem "minitest", "~> 5.10.0"
|
10
|
+
gem "activesupport", "~> 6.0"
|
11
|
+
|
12
|
+
gemspec path: "../"
|
@@ -0,0 +1,59 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
invoca-utils (0.5.0)
|
5
|
+
activesupport (>= 5.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (6.1.7.2)
|
11
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
+
i18n (>= 1.6, < 2)
|
13
|
+
minitest (>= 5.1)
|
14
|
+
tzinfo (~> 2.0)
|
15
|
+
zeitwerk (~> 2.3)
|
16
|
+
appraisal (2.4.1)
|
17
|
+
bundler
|
18
|
+
rake
|
19
|
+
thor (>= 0.14.0)
|
20
|
+
concurrent-ruby (1.2.0)
|
21
|
+
diff-lcs (1.5.0)
|
22
|
+
i18n (1.12.0)
|
23
|
+
concurrent-ruby (~> 1.0)
|
24
|
+
minitest (5.10.3)
|
25
|
+
rake (13.0.6)
|
26
|
+
rspec (3.12.0)
|
27
|
+
rspec-core (~> 3.12.0)
|
28
|
+
rspec-expectations (~> 3.12.0)
|
29
|
+
rspec-mocks (~> 3.12.0)
|
30
|
+
rspec-core (3.12.1)
|
31
|
+
rspec-support (~> 3.12.0)
|
32
|
+
rspec-expectations (3.12.2)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.12.0)
|
35
|
+
rspec-mocks (3.12.3)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.12.0)
|
38
|
+
rspec-support (3.12.0)
|
39
|
+
rspec_junit_formatter (0.6.0)
|
40
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
41
|
+
thor (1.2.1)
|
42
|
+
tzinfo (2.0.6)
|
43
|
+
concurrent-ruby (~> 1.0)
|
44
|
+
zeitwerk (2.6.6)
|
45
|
+
|
46
|
+
PLATFORMS
|
47
|
+
arm64-darwin-22
|
48
|
+
|
49
|
+
DEPENDENCIES
|
50
|
+
activesupport (~> 6.0)
|
51
|
+
appraisal (~> 2.4)
|
52
|
+
invoca-utils!
|
53
|
+
minitest (~> 5.10.0)
|
54
|
+
rake (~> 13.0)
|
55
|
+
rspec (~> 3.0)
|
56
|
+
rspec_junit_formatter (~> 0.4)
|
57
|
+
|
58
|
+
BUNDLED WITH
|
59
|
+
2.3.17
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "appraisal", "~> 2.4"
|
6
|
+
gem "rake", "~> 13.0"
|
7
|
+
gem "rspec", "~> 3.0"
|
8
|
+
gem "rspec_junit_formatter", "~> 0.4"
|
9
|
+
gem "minitest", "~> 5.10.0"
|
10
|
+
gem "activesupport", "~> 7.0"
|
11
|
+
|
12
|
+
gemspec path: "../"
|
@@ -0,0 +1,57 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
invoca-utils (0.5.0)
|
5
|
+
activesupport (>= 5.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (7.0.4.2)
|
11
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
+
i18n (>= 1.6, < 2)
|
13
|
+
minitest (>= 5.1)
|
14
|
+
tzinfo (~> 2.0)
|
15
|
+
appraisal (2.4.1)
|
16
|
+
bundler
|
17
|
+
rake
|
18
|
+
thor (>= 0.14.0)
|
19
|
+
concurrent-ruby (1.2.0)
|
20
|
+
diff-lcs (1.5.0)
|
21
|
+
i18n (1.12.0)
|
22
|
+
concurrent-ruby (~> 1.0)
|
23
|
+
minitest (5.10.3)
|
24
|
+
rake (13.0.6)
|
25
|
+
rspec (3.12.0)
|
26
|
+
rspec-core (~> 3.12.0)
|
27
|
+
rspec-expectations (~> 3.12.0)
|
28
|
+
rspec-mocks (~> 3.12.0)
|
29
|
+
rspec-core (3.12.1)
|
30
|
+
rspec-support (~> 3.12.0)
|
31
|
+
rspec-expectations (3.12.2)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.12.0)
|
34
|
+
rspec-mocks (3.12.3)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.12.0)
|
37
|
+
rspec-support (3.12.0)
|
38
|
+
rspec_junit_formatter (0.6.0)
|
39
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
40
|
+
thor (1.2.1)
|
41
|
+
tzinfo (2.0.6)
|
42
|
+
concurrent-ruby (~> 1.0)
|
43
|
+
|
44
|
+
PLATFORMS
|
45
|
+
arm64-darwin-22
|
46
|
+
|
47
|
+
DEPENDENCIES
|
48
|
+
activesupport (~> 7.0)
|
49
|
+
appraisal (~> 2.4)
|
50
|
+
invoca-utils!
|
51
|
+
minitest (~> 5.10.0)
|
52
|
+
rake (~> 13.0)
|
53
|
+
rspec (~> 3.0)
|
54
|
+
rspec_junit_formatter (~> 0.4)
|
55
|
+
|
56
|
+
BUNDLED WITH
|
57
|
+
2.3.17
|
data/invoca-utils.gemspec
CHANGED
@@ -1,22 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
3
6
|
require 'invoca/utils/version'
|
4
7
|
|
5
8
|
Gem::Specification.new do |spec|
|
6
9
|
spec.name = "invoca-utils"
|
7
10
|
spec.version = Invoca::Utils::VERSION
|
11
|
+
spec.licenses = ["MIT"]
|
12
|
+
|
8
13
|
spec.authors = ["Invoca development"]
|
9
14
|
spec.email = ["development@invoca.com"]
|
15
|
+
|
10
16
|
spec.summary = "A public collection of helpers used in multiple projects"
|
11
|
-
spec.
|
12
|
-
spec.
|
17
|
+
spec.description = "A public collection of helpers used in multiple projects"
|
18
|
+
spec.homepage = "https://github.com/Invoca/invoca-utils"
|
13
19
|
|
14
|
-
spec.metadata =
|
15
|
-
'allowed_push_host' => 'https://rubygems.org'
|
16
|
-
}
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
17
21
|
|
18
22
|
spec.files = `git ls-files -z`.split("\x0")
|
19
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |
|
23
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |file| File.basename(file) }
|
20
24
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
25
|
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
# this should match the minimum github pipeline targets
|
28
|
+
# which is currently set to 2.5
|
29
|
+
spec.required_ruby_version = ">= 2.5.0"
|
30
|
+
|
31
|
+
spec.add_dependency "activesupport", ">= 5.0"
|
32
|
+
|
33
|
+
# Specify this gem's development and test dependencies in Gemfile
|
22
34
|
end
|
@@ -13,9 +13,11 @@ module Invoca
|
|
13
13
|
# @return the value from yield
|
14
14
|
def retry_on_exception(exception_classes, retries: 1, before_retry: nil)
|
15
15
|
retries.times do |attempt_number|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
begin
|
17
|
+
return yield(attempt_number)
|
18
|
+
rescue *Array(exception_classes) => ex
|
19
|
+
before_retry&.call(ex)
|
20
|
+
end
|
19
21
|
end
|
20
22
|
|
21
23
|
yield(retries) # no rescue for this last try, so any exceptions will raise out
|
data/lib/invoca/utils/version.rb
CHANGED
File without changes
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/all'
|
4
|
+
|
5
|
+
require 'invoca/utils'
|
6
|
+
require 'rspec_junit_formatter'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.add_formatter(RspecJunitFormatter, 'spec/reports/rspec.xml')
|
10
|
+
|
11
|
+
config.mock_with :rspec do |mocks|
|
12
|
+
mocks.verify_partial_doubles = true
|
13
|
+
end
|
14
|
+
|
15
|
+
RSpec::Support::ObjectFormatter.default_instance.max_formatted_output_length = 2_000
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../lib/invoca/utils/array.rb'
|
4
|
+
require_relative '../spec_helper'
|
5
|
+
|
6
|
+
describe Array do
|
7
|
+
context '* operator' do
|
8
|
+
it 'call the same method on each item in an array and return the results as an array' do
|
9
|
+
expect(['some', 'short', 'words'].*.length).to eq([4, 5, 5])
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'handle methods with arguments' do
|
13
|
+
expect(['some', 'short', 'words'].*.slice(1, 2)).to eq(['om', 'ho', 'or'])
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'not alter normal behavior (multiplication) when there is a right hand side to the expression' do
|
17
|
+
expect(['some', 'short', 'words'] * 2).to eq(['some', 'short', 'words', 'some', 'short', 'words'])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'set'
|
4
|
+
require_relative '../../lib/invoca/utils/enumerable.rb'
|
5
|
+
require_relative '../spec_helper'
|
6
|
+
|
7
|
+
describe Enumerable do
|
8
|
+
|
9
|
+
context 'map_and_find' do
|
10
|
+
it 'return the mapped value of the first match' do
|
11
|
+
expect([1, 2, 3, 4].map_and_find { |v| 'FOUND 3' if v == 3 }).to eq('FOUND 3')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'return the mapped value of the first match, even if there are multiple matches' do
|
15
|
+
expect([1, 2, 3, 4].map_and_find { |v| "FOUND #{v}" if v > 2 }).to eq('FOUND 3')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'return the provided argument if the value is not found' do
|
19
|
+
expect([1, 2, 3, 4].map_and_find('NOT FOUND') { |v| "FOUND 6" if v == 6 }).to eq('NOT FOUND')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'return nil if the value is not found and no argument is provided' do
|
23
|
+
expect([1, 2, 3, 4].map_and_find { |v| "FOUND 6" if v == 6 }).to be_nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'map_with_index' do
|
28
|
+
it 'call the block with the value and index' do
|
29
|
+
expect([10, 20, 30, 40].map_with_index { |v, index| v + index }).to eq([10, 21, 32, 43])
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'assumulate into the provided enumerable' do
|
33
|
+
expect([10, 20, 30, 40].map_with_index([1]) { |v, index| v + index }).to eq([1, 10, 21, 32, 43])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'map_hash' do
|
38
|
+
it 'convert enumerables into a hash using the value for key and the map result as the hash value' do
|
39
|
+
expect([1, 2, 3].map_hash { |v| v + 10 }).to eq({ 1 => 11, 2 => 12, 3 => 13 })
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'includes nils returned from map' do
|
43
|
+
expect([1, 2, 3].map_hash { |v| v + 10 unless v == 2 }).to eq({ 1 => 11, 2 => nil, 3 => 13 })
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'build_hash' do
|
48
|
+
it 'convert arrays of [key, value] to a hash of { key => value }' do
|
49
|
+
expect(['some', 'short', 'words'].build_hash { |s| [s, s.length] }).to eq({ 'some' => 4, 'short' => 5, 'words' => 5 })
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'ignore nils returned from map' do
|
53
|
+
expect(['some', 'short', 'words'].build_hash { |s| s == 'short' ? nil : [s, s.length] }).to eq({ 'some' => 4, 'words' => 5 })
|
54
|
+
end
|
55
|
+
|
56
|
+
# these seem like erroneous behavior, but, they have been left as-is for backward compatibility with hobosupport::Enumerable::build_hash
|
57
|
+
|
58
|
+
it 'convert arrays of [single_value] to a hash of { single_value => single_value }' do
|
59
|
+
expect(['some', 'short', 'words'].build_hash { |s| s == 'short' ? [s] : [s, s.length] }).to eq({ 'some' => 4, 'short' => 'short', 'words' => 5 })
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'convert arrays of [first, ..., last] to a hash of { first => last }' do
|
63
|
+
expect(['some', 'short', 'words'].build_hash { |s| s == 'short' ? [s, 'two', 'three'] : [s, s.length] }).to eq({ 'some' => 4, 'short' => 'three', 'words' => 5 })
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'convert empty arrays to a hash of { nil => nil }' do
|
67
|
+
expect(['some', 'short', 'words'].build_hash { |s| s == 'short' ? [] : [s, s.length] }).to eq({ 'some' => 4, nil => nil, 'words' => 5 })
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context '* operator' do
|
72
|
+
it 'call the same method on each item in an Set and return the results as an array' do
|
73
|
+
expect(Set['some', 'short', 'words'].*.length).to eq([4, 5, 5])
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'call the same method on each item in an Hash and return the results as an array' do
|
77
|
+
expect({ key1: 'value1', key2: 'value2' }.*.join(':')).to eq(['key1:value1', 'key2:value2'])
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|