checkability 0.4.1 → 0.5.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 +5 -5
- data/Rakefile +2 -0
- data/bin/checkability +1 -0
- data/lib/checkability.rb +2 -0
- data/lib/checkability/acts_as_checkable.rb +4 -4
- data/lib/checkability/checkable.rb +5 -3
- data/lib/checkability/external_api_checker.rb +12 -9
- data/lib/checkability/external_api_connector.rb +2 -0
- data/lib/checkability/railtie.rb +2 -0
- data/lib/checkability/storage_checker.rb +6 -3
- data/lib/checkability/validator.rb +4 -2
- data/lib/checkability/version.rb +3 -1
- data/lib/tasks/checkability_tasks.rake +1 -0
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ae53afa68f33c527bee835d3c84e304c7596f46665cc41ff1df67b2e4189f595
|
4
|
+
data.tar.gz: 8de80e50a31b5e3c7b2f498b8c81de8793b4d80f9a4665653dd12be745331721
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32ed1b0305e36d037d38bde6acf78f4c7d4ae04e49764d4129fb5d9f455cf349607131ea17b5a500a0f47ab38f31698d06eeaec07dc9a014b030518be42e66fa
|
7
|
+
data.tar.gz: cec99b497500443955ef650e56948037e8e7855456f14aa66a491e71ecd884c9d1553c64bbb10fd7a1ce23ae535fa1d42bb730a0979bfead71db07a625bc2407
|
data/Rakefile
CHANGED
data/bin/checkability
CHANGED
data/lib/checkability.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Checkability
|
2
4
|
# Adding class and instance methods
|
3
5
|
#
|
@@ -10,9 +12,7 @@ module Checkability
|
|
10
12
|
|
11
13
|
class_methods do
|
12
14
|
def acts_as_checkable(options = {})
|
13
|
-
if !options.is_a?(Hash) && !options.empty?
|
14
|
-
raise ArgumentError, "Hash expected, got #{options.class.name}"
|
15
|
-
end
|
15
|
+
raise ArgumentError, "Hash expected, got #{options.class.name}" if !options.is_a?(Hash) && !options.empty?
|
16
16
|
|
17
17
|
class_attribute :checkable_conf
|
18
18
|
|
@@ -25,7 +25,7 @@ module Checkability
|
|
25
25
|
def perform_check
|
26
26
|
_setup
|
27
27
|
self.allowed = _check
|
28
|
-
messages << "'#{value}' is #{_allowness}. "
|
28
|
+
messages << "#{allowed}::'#{value}' is #{_allowness}. "
|
29
29
|
end
|
30
30
|
|
31
31
|
private
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Checkability
|
2
4
|
# Implements check method to Iterate on chechers
|
3
5
|
# Possible to implemet as Iterator in future
|
@@ -9,11 +11,11 @@ module Checkability
|
|
9
11
|
@checkable = checkable
|
10
12
|
end
|
11
13
|
|
12
|
-
#
|
14
|
+
# strategy is a proc
|
13
15
|
# like { |a,b,c| a && ( b || c ) }
|
14
16
|
# where a,b,c are checkers
|
15
17
|
# and each should return true|false
|
16
|
-
#
|
18
|
+
# checker_confs is an array of checker_conf hashes
|
17
19
|
# e.g. [storage_checker, external_api_checker]
|
18
20
|
def check(opts = {})
|
19
21
|
results = []
|
@@ -31,7 +33,7 @@ module Checkability
|
|
31
33
|
k = "Checkability::#{checker_conf[:name].to_s.camelize}".constantize
|
32
34
|
k.new(checker_conf).check_value(checkable)
|
33
35
|
rescue NameError => e
|
34
|
-
checkable.messages << "
|
36
|
+
checkable.messages << "false::#{e}: #{checker_conf[:name]}."
|
35
37
|
false
|
36
38
|
end
|
37
39
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'faraday'
|
2
4
|
require 'net/http'
|
3
5
|
require 'net/https'
|
@@ -21,8 +23,9 @@ module Checkability
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def check_value(checkable)
|
24
|
-
@resp = connection
|
25
|
-
|
26
|
+
@resp = connection
|
27
|
+
.connect
|
28
|
+
.send(http_verb, "#{checkable.value.delete(' ')}#{path_suffix}")
|
26
29
|
result, message = _result_and_message
|
27
30
|
checkable.messages << message
|
28
31
|
result
|
@@ -30,8 +33,8 @@ module Checkability
|
|
30
33
|
|
31
34
|
private
|
32
35
|
|
33
|
-
def _message(str)
|
34
|
-
"#{path}: #{str}"
|
36
|
+
def _message(str, res)
|
37
|
+
"#{res}::#{path}: #{str}"
|
35
38
|
end
|
36
39
|
|
37
40
|
def _parsed(resp)
|
@@ -39,14 +42,14 @@ module Checkability
|
|
39
42
|
end
|
40
43
|
|
41
44
|
def _result_and_message
|
42
|
-
return [false, _message(@resp.status)] unless @resp.status == 200
|
45
|
+
return [false, _message(@resp.status, false)] unless @resp.status == 200
|
43
46
|
|
44
|
-
return [true, _message(success_message)] if check_method
|
45
|
-
|
47
|
+
return [true, _message(success_message, true)] if check_method
|
48
|
+
.call(_parsed(@resp))
|
46
49
|
|
47
|
-
[false, _message(failure_message)]
|
50
|
+
[false, _message(failure_message, false)]
|
48
51
|
rescue StandardError => e
|
49
|
-
[false, _message(e)]
|
52
|
+
[false, _message(e, false)]
|
50
53
|
end
|
51
54
|
end
|
52
55
|
end
|
data/lib/checkability/railtie.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Checkability
|
2
4
|
# Checks if postcode exists in Storage
|
3
5
|
#
|
@@ -11,7 +13,8 @@ module Checkability
|
|
11
13
|
def check_value(checkable)
|
12
14
|
value = checkable.value.upcase
|
13
15
|
result = _present_in_storage(value)
|
14
|
-
checkable.messages << (
|
16
|
+
checkable.messages << (
|
17
|
+
result ? _message('Found', result) : _message('Not found', result))
|
15
18
|
result
|
16
19
|
end
|
17
20
|
|
@@ -22,8 +25,8 @@ module Checkability
|
|
22
25
|
.present?
|
23
26
|
end
|
24
27
|
|
25
|
-
def _message(str)
|
26
|
-
"Allowed #{storage_class}s list: #{str}."
|
28
|
+
def _message(str, res)
|
29
|
+
"#{res}::Allowed #{storage_class}s list: #{str}."
|
27
30
|
end
|
28
31
|
end
|
29
32
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Checkability
|
2
4
|
# Checks if postcode comply with regex
|
3
5
|
#
|
@@ -18,9 +20,9 @@ module Checkability
|
|
18
20
|
|
19
21
|
def _result_and_message(checkable)
|
20
22
|
if (checkable.value.delete(' ') =~ format[:regex]).nil?
|
21
|
-
[false, "Value is NOT COMPLY with format of #{format[:name]}."]
|
23
|
+
[false, "false::Value is NOT COMPLY with format of #{format[:name]}."]
|
22
24
|
else
|
23
|
-
[true, "Value is COMPLY with format of #{format[:name]}."]
|
25
|
+
[true, "true::Value is COMPLY with format of #{format[:name]}."]
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
data/lib/checkability/version.rb
CHANGED
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: checkability
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Eremeev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2021-04-01 00:00:00.000000000 Z
|
@@ -40,7 +40,7 @@ metadata:
|
|
40
40
|
homepage_uri: https://github.com/azazelo/checkability
|
41
41
|
source_code_uri: https://rubygems.org
|
42
42
|
changelog_uri: https://rubygems.org
|
43
|
-
post_install_message:
|
43
|
+
post_install_message:
|
44
44
|
rdoc_options: []
|
45
45
|
require_paths:
|
46
46
|
- lib
|
@@ -48,16 +48,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
48
48
|
requirements:
|
49
49
|
- - ">="
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version:
|
51
|
+
version: 2.6.2
|
52
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0'
|
57
57
|
requirements: []
|
58
|
-
|
59
|
-
|
60
|
-
signing_key:
|
58
|
+
rubygems_version: 3.0.3
|
59
|
+
signing_key:
|
61
60
|
specification_version: 4
|
62
61
|
summary: Provide Checkers functionality.
|
63
62
|
test_files: []
|