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