class Prettyp::Formatter::XML::Xmllint

Public Class Methods

check_requirement() click to toggle source
# File lib/prettyp/formatter/xml/xmllint.rb, line 11
def self.check_requirement
  !%x|which #{executeable}|.empty?
end
executeable() click to toggle source
# File lib/prettyp/formatter/xml/xmllint.rb, line 10
def self.executeable; 'xmllint'; end
languages() click to toggle source
# File lib/prettyp/formatter/xml/xmllint.rb, line 6
def self.languages
  [:xml, :html]
end

Public Instance Methods

format(input, language) click to toggle source
# File lib/prettyp/formatter/xml/xmllint.rb, line 15
def format input, language
  extra_opts = '--html' if language.eql? :html
  with_file(input) do |file|
    out = execute_command("cat #{file.path} | #{self.class.executeable} --format #{extra_opts} -",
                          on_error: Proc.new { |output| raise FormatError, output })
  end
end