Class: PanamaxTemplateValidator::TemplateFile
- Inherits:
-
Object
- Object
- PanamaxTemplateValidator::TemplateFile
- Defined in:
- lib/panamax_template_validator/template_file.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(file) ⇒ TemplateFile
constructor
A new instance of TemplateFile.
- #validate ⇒ Object
Constructor Details
#initialize(file) ⇒ TemplateFile
Returns a new instance of TemplateFile.
11 12 13 14 |
# File 'lib/panamax_template_validator/template_file.rb', line 11 def initialize(file) @file = file @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/panamax_template_validator/template_file.rb', line 9 def errors @errors end |
Instance Method Details
#validate ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/panamax_template_validator/template_file.rb', line 16 def validate if template = load_template(@file) template_validator = Template.new(template) template_validator.validate errors = template_validator.errors if errors.empty? puts "#{@file} is valid".green else puts "#{@file} has the following errors:".red puts errors.map { |x| x.red } @errors += errors end else no_exist = "#{@file} does not exist" puts no_exist @errors << no_exist end end |