class TPX::Tools

Constants

TPX_INVALID
TPX_VALID
TPX_VERSION_UNKNOWN

Attributes

quiet[RW]

Public Class Methods

get_tpx_version_const(tpx_version) click to toggle source
# File lib/tpx/tools.rb, line 19
def get_tpx_version_const(tpx_version)
  underscored_tpx_version = tpx_version.gsub('.', '_')
  Object.const_get("TPX_#{underscored_tpx_version}")
rescue NameError => e
  msg( e )
  raise TPX_VERSION_UNKNOWN + "'#{tpx_version}'"
end
msg(message) click to toggle source
# File lib/tpx/tools.rb, line 15
def msg(message)
  puts message unless quiet
end
validate(tpx_version_const, filepath) click to toggle source
# File lib/tpx/tools.rb, line 27
def validate(tpx_version_const, filepath)
  begin
    tpx_version_const::Validator.validate_file! filepath
  rescue tpx_version_const::ValidationWarning => w
    msg( "Warning: #{w}" )
    puts TPX_VALID + " against " + tpx_version_const.to_s
  rescue => e
    puts TPX_INVALID
    puts e
  else
    puts TPX_VALID
  end
end