checkability 0.4.1 → 0.5.0

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
- SHA1:
3
- metadata.gz: ae846f196e0b6d2648429f824e02205b9a3fe04d
4
- data.tar.gz: 10156c70279d72817146d19fceaef9cbba3f116d
2
+ SHA256:
3
+ metadata.gz: ae53afa68f33c527bee835d3c84e304c7596f46665cc41ff1df67b2e4189f595
4
+ data.tar.gz: 8de80e50a31b5e3c7b2f498b8c81de8793b4d80f9a4665653dd12be745331721
5
5
  SHA512:
6
- metadata.gz: 990b1575b7ebfb0e667aa1ab2e6a0601e3388ea1b2ecd7f4808d843d1341085f454477804fa8f0edeb743fd2508fdb16d2b7a9eb2d8451a20a212791f67f411d
7
- data.tar.gz: 445c267c33c75d63188d6ec04767409afed7734292a369e880d8e1d1cc03b5b8a9af80339b076968d60816ec9834901ab9ed6a7299606b9d3fe496276e869af3
6
+ metadata.gz: 32ed1b0305e36d037d38bde6acf78f4c7d4ae04e49764d4129fb5d9f455cf349607131ea17b5a500a0f47ab38f31698d06eeaec07dc9a014b030518be42e66fa
7
+ data.tar.gz: cec99b497500443955ef650e56948037e8e7855456f14aa66a491e71ecd884c9d1553c64bbb10fd7a1ce23ae535fa1d42bb730a0979bfead71db07a625bc2407
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/setup'
2
4
 
3
5
  require 'bundler/gem_tasks'
data/bin/checkability CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require_relative '../lib/checkability'
4
5
 
data/lib/checkability.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_record'
2
4
  require 'active_support'
3
5
  require_relative 'checkability/version'
@@ -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
- # sentence is a proc
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
- # checkers is an array of checker objects
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 << "#{e}: #{checker_conf[:name]}."
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.connect.send(http_verb,
25
- checkable.value.delete(' ') + path_suffix)
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
- .call(_parsed(@resp))
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Checkability
2
4
  # Create connection
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Checkability
2
4
  class Railtie < ::Rails::Railtie
3
5
  end
@@ -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 << (result ? _message('Found') : _message('Not found'))
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Checkability
2
- VERSION = '0.4.1'.freeze
4
+ VERSION = '0.5.0'
3
5
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # desc "Explaining what the task does"
2
3
  # task :checkability do
3
4
  # # Task goes here
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.1
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: '0'
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
- rubyforge_project:
59
- rubygems_version: 2.4.6
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: []