Class: Lazy::Checker::CheckedUrl
- Inherits:
-
Object
- Object
- Lazy::Checker::CheckedUrl
- Defined in:
- lib/lazy/check/checked_url.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#error ⇒ Object
readonly
- String
-
L’erreur éventuelle à écrire.
Instance Method Summary collapse
-
#check(**options) ⇒ Object
— TESTS METHODS —.
-
#errors ⇒ Object
Les erreurs rencontrées.
-
#initialize(data) ⇒ CheckedUrl
constructor
Instanciation.
- #name ⇒ Object (also: #message)
- #reporter ⇒ Object
- #test_redirection? ⇒ Boolean
-
#test_response? ⇒ Boolean
– Predicate Methods –.
-
#urler ⇒ Object
– Data Methods –.
Constructor Details
#initialize(data) ⇒ CheckedUrl
Instanciation
19 20 21 |
# File 'lib/lazy/check/checked_url.rb', line 19 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
11 12 13 |
# File 'lib/lazy/check/checked_url.rb', line 11 def data @data end |
#error ⇒ Object (readonly)
- String
-
L’erreur éventuelle à écrire
14 15 16 |
# File 'lib/lazy/check/checked_url.rb', line 14 def error @error end |
Instance Method Details
#check(**options) ⇒ Object
— TESTS METHODS —
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/lazy/check/checked_url.rb', line 30 def check(**) urler.readit if test_redirection? if urler.redirection? && urler.redirect_to == data[:redirect_to] reporter.add_success(self) elsif urler.redirect_to.nil? @error = ERRORS[5500] % {e:data[:redirect_to]} reporter.add_failure(self) else @error = ERRORS[5501] % {a:urler.redirect_to, e:data[:redirect_to]} reporter.add_failure(self) end elsif test_response? # STDOUT.write("\nurler.rvalue = #{urler.rvalue.inspect}".jaune) if urler.rvalue == data[:response] reporter.add_success(self) else case urler.rvalue when 404 @error = ERRORS[5503] % {e: urler.url} else @error = ERRORS[5502] % {a:urler.rvalue, e:data[:response]} end reporter.add_failure(self) end end end |
#errors ⇒ Object
Returns les erreurs rencontrées.
24 25 26 |
# File 'lib/lazy/check/checked_url.rb', line 24 def errors @errors.join("\n") + "Sous-erreurs : #{@sub_errors.join("\n")}" end |
#name ⇒ Object Also known as: message
72 |
# File 'lib/lazy/check/checked_url.rb', line 72 def name ; data[:name] end |
#reporter ⇒ Object
74 |
# File 'lib/lazy/check/checked_url.rb', line 74 def reporter ; data[:reporter] end |
#test_redirection? ⇒ Boolean
65 66 67 |
# File 'lib/lazy/check/checked_url.rb', line 65 def test_redirection? data.key?(:redirect_to) && not(data[:redirect_to].nil?) end |
#test_response? ⇒ Boolean
– Predicate Methods –
61 62 63 |
# File 'lib/lazy/check/checked_url.rb', line 61 def test_response? data.key?(:response) && not(data[:response].nil?) end |
#urler ⇒ Object
– Data Methods –
71 |
# File 'lib/lazy/check/checked_url.rb', line 71 def urler ; data[:urler] end |