Module: CqmValidators::BaseValidator

Instance Method Summary collapse

Instance Method Details

#build_error(msg, loc, file_name) ⇒ Object



5
6
7
# File 'lib/base_validator.rb', line 5

def build_error(msg, loc, file_name)
  ValidationError.new(message: msg, location: loc, file_name: file_name, validator: @name)
end

#get_document(input) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/base_validator.rb', line 9

def get_document(input)
  doc = case input
        when File
          input.rewind
          input.read
        when Nokogiri::XML::Document
          return input
        else
          input
        end
  Nokogiri::XML(doc.to_s) { |conf| conf.strict.nonet.noblanks } # grumble, grumble nokogiri java @SS
end