Class: ValidateWebsite::Core
- Inherits:
-
Object
- Object
- ValidateWebsite::Core
- Includes:
- ColorfulMessages
- Defined in:
- lib/validate_website/core.rb
Overview
Core class for static or website validation
Constant Summary collapse
- EXIT_SUCCESS =
0
- EXIT_FAILURE_MARKUP =
64
- EXIT_FAILURE_NOT_FOUND =
65
- EXIT_FAILURE_MARKUP_NOT_FOUND =
66
- START_MESSAGE =
'Validating'
Instance Attribute Summary collapse
-
#errors_count ⇒ Object
readonly
Returns the value of attribute errors_count.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#not_founds_count ⇒ Object
readonly
Returns the value of attribute not_founds_count.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#site ⇒ Object
Returns the value of attribute site.
Instance Method Summary collapse
- #default_cookies ⇒ Object
- #errors? ⇒ Boolean
- #exit_status ⇒ Object
-
#initialize(options, validation_type) ⇒ NilClass
constructor
Initialize core ValidateWebsite class.
- #not_founds? ⇒ Boolean
Methods included from ColorfulMessages
#color, #error, #info, #note, #success, #warning
Constructor Details
#initialize(options, validation_type) ⇒ NilClass
Initialize core ValidateWebsite class
39 40 41 42 43 44 45 46 |
# File 'lib/validate_website/core.rb', line 39 def initialize(, validation_type) @not_founds_count = 0 @errors_count = 0 @options = Parser.parse(, validation_type).to_h @site = @options[:site] @service_url = @options[:html5_validator_service_url] Validator.html5_validator_service_url = @service_url if @service_url end |
Instance Attribute Details
#errors_count ⇒ Object (readonly)
Returns the value of attribute errors_count.
23 24 25 |
# File 'lib/validate_website/core.rb', line 23 def errors_count @errors_count end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
23 24 25 |
# File 'lib/validate_website/core.rb', line 23 def host @host end |
#not_founds_count ⇒ Object (readonly)
Returns the value of attribute not_founds_count.
23 24 25 |
# File 'lib/validate_website/core.rb', line 23 def not_founds_count @not_founds_count end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
23 24 25 |
# File 'lib/validate_website/core.rb', line 23 def @options end |
#site ⇒ Object
Returns the value of attribute site.
22 23 24 |
# File 'lib/validate_website/core.rb', line 22 def site @site end |
Instance Method Details
#default_cookies ⇒ Object
68 69 70 71 72 73 |
# File 'lib/validate_website/core.rb', line 68 def WEBrick::Cookie.parse(@options[:cookies]).each_with_object({}) do |c, h| h[c.name] = c.value h end end |
#errors? ⇒ Boolean
48 49 50 |
# File 'lib/validate_website/core.rb', line 48 def errors? @errors_count.positive? end |
#exit_status ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/validate_website/core.rb', line 56 def exit_status if errors? && not_founds? EXIT_FAILURE_MARKUP_NOT_FOUND elsif errors? EXIT_FAILURE_MARKUP elsif not_founds? EXIT_FAILURE_NOT_FOUND else EXIT_SUCCESS end end |
#not_founds? ⇒ Boolean
52 53 54 |
# File 'lib/validate_website/core.rb', line 52 def not_founds? @not_founds_count.positive? end |