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'.freeze
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
36 37 38 39 40 41 42 43 |
# File 'lib/validate_website/core.rb', line 36 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.
21 22 23 |
# File 'lib/validate_website/core.rb', line 21 def errors_count @errors_count end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
21 22 23 |
# File 'lib/validate_website/core.rb', line 21 def host @host end |
#not_founds_count ⇒ Object (readonly)
Returns the value of attribute not_founds_count.
21 22 23 |
# File 'lib/validate_website/core.rb', line 21 def not_founds_count @not_founds_count end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
21 22 23 |
# File 'lib/validate_website/core.rb', line 21 def @options end |
#site ⇒ Object
Returns the value of attribute site.
20 21 22 |
# File 'lib/validate_website/core.rb', line 20 def site @site end |
Instance Method Details
#default_cookies ⇒ Object
65 66 67 68 69 70 |
# File 'lib/validate_website/core.rb', line 65 def WEBrick::Cookie.parse(@options[:cookies]).each_with_object({}) do |c, h| h[c.name] = c.value h end end |
#errors? ⇒ Boolean
45 46 47 |
# File 'lib/validate_website/core.rb', line 45 def errors? @errors_count > 0 end |
#exit_status ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/validate_website/core.rb', line 53 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
49 50 51 |
# File 'lib/validate_website/core.rb', line 49 def not_founds? @not_founds_count > 0 end |