work_list 0.1.0 → 0.2.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 +4 -4
- data/lib/work_list/results.rb +31 -3
- data/lib/work_list/version.rb +1 -1
- data/lib/work_list.rb +3 -8
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f0b76f7f951d3892ed1fc494199469f9376ffbe7
|
|
4
|
+
data.tar.gz: 73403e93932e6b35da01db314e471d390930c67a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2352bd104ca8ab8bd4a55f4fd3b2d623c236845441ab730132fadc44c27cf0df1d9b875c85e74b65faf7e8f4ffbda47aa3eb2fed0daa3a56d88c70573953b150
|
|
7
|
+
data.tar.gz: f5069a2a9b4841e78dd271737b49791866a2186a7c4ce871e28b06e9d4722b8a69354c5cfb8a4f3852f0cf14d54ac4d8c4c5ee481d26be7023456b33ba23df89
|
data/lib/work_list/results.rb
CHANGED
|
@@ -8,7 +8,7 @@ module WorkList
|
|
|
8
8
|
@failures = 0
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
def
|
|
11
|
+
def record_success(result)
|
|
12
12
|
@successes += 1
|
|
13
13
|
@items << {
|
|
14
14
|
result: result,
|
|
@@ -17,7 +17,7 @@ module WorkList
|
|
|
17
17
|
}
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def
|
|
20
|
+
def record_failure(exception)
|
|
21
21
|
@failures += 1
|
|
22
22
|
@items << {
|
|
23
23
|
result: nil,
|
|
@@ -43,11 +43,39 @@ module WorkList
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def failure?
|
|
46
|
-
|
|
46
|
+
@failures > 0
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def noop?
|
|
50
50
|
@items.empty?
|
|
51
51
|
end
|
|
52
|
+
|
|
53
|
+
def all_failures?
|
|
54
|
+
failure_rate == 1.0
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def failure_rate
|
|
58
|
+
if noop?
|
|
59
|
+
0
|
|
60
|
+
else
|
|
61
|
+
Rational(@failures, @items.count)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def raise_if_failure
|
|
66
|
+
raise_exception if failure?
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def raise_if_all_failures
|
|
70
|
+
raise_exception if all_failures?
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def raise_if_failure_rate(threshold)
|
|
74
|
+
raise_exception if failure_rate >= threshold
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def raise_exception
|
|
78
|
+
raise exceptions.first
|
|
79
|
+
end
|
|
52
80
|
end
|
|
53
81
|
end
|
data/lib/work_list/version.rb
CHANGED
data/lib/work_list.rb
CHANGED
|
@@ -7,17 +7,12 @@ module WorkList
|
|
|
7
7
|
|
|
8
8
|
items.each do |item|
|
|
9
9
|
begin
|
|
10
|
-
results.
|
|
10
|
+
results.record_success(block.call(item))
|
|
11
11
|
rescue => exception
|
|
12
|
-
results.
|
|
12
|
+
results.record_failure(exception)
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
# Raise the first exception, as if we weren't rescuing them.
|
|
18
|
-
raise results.exceptions.first
|
|
19
|
-
else
|
|
20
|
-
results
|
|
21
|
-
end
|
|
16
|
+
results
|
|
22
17
|
end
|
|
23
18
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: work_list
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cory Kaufman-Schofield
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-01-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
91
91
|
version: '0'
|
|
92
92
|
requirements: []
|
|
93
93
|
rubyforge_project:
|
|
94
|
-
rubygems_version: 2.6.
|
|
94
|
+
rubygems_version: 2.6.14
|
|
95
95
|
signing_key:
|
|
96
96
|
specification_version: 4
|
|
97
97
|
summary: Better exception handling for operating on arrays
|