checkability 2.0.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/checkability/acts_as_checkable.rb +3 -2
- data/lib/checkability/base_checker.rb +4 -4
- data/lib/checkability/checkable.rb +14 -13
- data/lib/checkability/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 025ba09f183579762584e89daf10b06fe93c8d2da5ce899120ae2c9b8bf15726
|
4
|
+
data.tar.gz: 3b5f2c538aa618dfc077c35c2d176bf78a36336a97395caeab236f1101795aa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 464e94ce7a7c4538f27c1e740b92f61392f0a08683debb21d39e7189782fc214ad4dc8e9add85278352c36d40249799cef53f00005361cf20439d9d6f534e12b
|
7
|
+
data.tar.gz: 16c0f544f7b2164fb31c9be12bfcedcae5a28a54b31028ed048ae4bafe1e49d22dea0ba606ce750eeebdac64cb8fd0a25b9ff5dc4fdab559d982260287a2105e
|
data/README.md
CHANGED
@@ -76,4 +76,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
76
76
|
|
77
77
|
## Future works
|
78
78
|
|
79
|
-
- [
|
79
|
+
- [X] Use ChainOfResponsibility pattern to simplify call of checkers
|
80
|
+
- [ ] Improve test with adding doubles
|
@@ -23,7 +23,7 @@ module Checkability
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
attr_accessor :ch_allowed, :ch_messages
|
26
|
+
attr_accessor :ch_allowed, :ch_messages, :ch_conf
|
27
27
|
|
28
28
|
def initialize(params)
|
29
29
|
@ch_messages = []
|
@@ -32,7 +32,8 @@ module Checkability
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def perform_check
|
35
|
-
|
35
|
+
@ch_conf = ch_conf
|
36
|
+
Checkability::Checkable.new(self).check
|
36
37
|
ch_messages << "#{ch_allowed}:::'#{_value}' is #{_allowness}. "
|
37
38
|
end
|
38
39
|
|
@@ -10,10 +10,10 @@ module Checkability
|
|
10
10
|
:success_message, :failure_message
|
11
11
|
|
12
12
|
def initialize(opts = {})
|
13
|
-
@stop_process_on_failure = opts
|
14
|
-
@stop_process_on_success = opts
|
15
|
-
@success_message = opts
|
16
|
-
@failure_message = opts
|
13
|
+
@stop_process_on_failure = opts.fetch(:stop_process_on_failure) { false }
|
14
|
+
@stop_process_on_success = opts.fetch(:stop_process_on_success) { false }
|
15
|
+
@success_message = opts.fetch(:success_message) { 'Success.' }
|
16
|
+
@failure_message = opts.fetch(:failure_message) { 'Failed.' }
|
17
17
|
|
18
18
|
@next_handler = nil
|
19
19
|
post_initialize(opts) # implemented in subclass
|
@@ -7,10 +7,10 @@ module Checkability
|
|
7
7
|
# Possible to implemet as Iterator in future
|
8
8
|
#
|
9
9
|
class Checkable
|
10
|
-
attr_accessor :check_obj
|
10
|
+
attr_accessor :check_obj, :handler_confs
|
11
11
|
|
12
12
|
extend Forwardable
|
13
|
-
def_delegators :@check_obj, :ch_messages, :ch_allowed
|
13
|
+
def_delegators :@check_obj, :ch_messages, :ch_allowed, :ch_conf
|
14
14
|
|
15
15
|
def initialize(check_obj)
|
16
16
|
@check_obj = check_obj
|
@@ -26,11 +26,8 @@ module Checkability
|
|
26
26
|
#
|
27
27
|
# ChainOfResponsibilty
|
28
28
|
#
|
29
|
-
def check
|
30
|
-
|
31
|
-
first_handler = _handlers(handler_confs)[first_handler_name]
|
32
|
-
|
33
|
-
first_handler.handle(check_obj)
|
29
|
+
def check
|
30
|
+
_first_handler.handle(check_obj)
|
34
31
|
rescue StandardError => e
|
35
32
|
check_obj.ch_messages << "false:::#{e}: #{handler_confs}."
|
36
33
|
false
|
@@ -38,17 +35,21 @@ module Checkability
|
|
38
35
|
|
39
36
|
private
|
40
37
|
|
41
|
-
def
|
42
|
-
|
38
|
+
def _first_handler
|
39
|
+
_handlers[ch_conf.keys.first]
|
40
|
+
end
|
41
|
+
|
42
|
+
def _handlers
|
43
|
+
handlers = _make_handlers
|
43
44
|
handlers.each_value.with_index do |handler, i|
|
44
|
-
|
45
|
-
handler.next_handler(
|
45
|
+
next_handler = handlers[handlers.keys[i + 1]]
|
46
|
+
handler.next_handler(next_handler) if next_handler
|
46
47
|
end
|
47
48
|
handlers
|
48
49
|
end
|
49
50
|
|
50
|
-
def _make_handlers
|
51
|
-
|
51
|
+
def _make_handlers
|
52
|
+
ch_conf.transform_values { |conf| _make_handler(conf) }
|
52
53
|
end
|
53
54
|
|
54
55
|
def _make_handler(conf)
|
data/lib/checkability/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: checkability
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Eremeev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Provide Checkers functionality.
|
14
14
|
email:
|