Class: Yamln8tor::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/yamln8tor/validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Validator

Returns a new instance of Validator.



10
11
12
13
# File 'lib/yamln8tor/validator.rb', line 10

def initialize(filename)
  @filename = filename
  @errors = []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



8
9
10
# File 'lib/yamln8tor/validator.rb', line 8

def errors
  @errors
end

#filenameObject (readonly)

Returns the value of attribute filename.



8
9
10
# File 'lib/yamln8tor/validator.rb', line 8

def filename
  @filename
end

Instance Method Details

#validateObject



15
16
17
18
19
20
21
22
23
# File 'lib/yamln8tor/validator.rb', line 15

def validate
  ym = ::YAML.load read_file
  ym.ya2yaml(:syck_compatible => true)
  return true
rescue ArgumentError => e
  error = ::OpenStruct.new(:message => e.message, :filename => filename)
  errors << error
  return false
end