class OpenShift::CartridgeTools::Lint

Constants

CURRENT_MANIFEST_SCHEMA

Public Class Methods

guess_manifest_path(file=nil) click to toggle source
# File lib/openshift/cartridge_tools/lint.rb, line 11
def self.guess_manifest_path(file=nil)
  base_path = Dir.pwd
  unless file.nil?
    file_path = File.join(base_path, file)
  else
    file_path = File.join(base_path, 'metadata', 'manifest.yml')
  end
  raise "File not found: #{file_path}" unless File.exists?(file_path)
  return file_path
end
guess_schema_path(schema=nil) click to toggle source
# File lib/openshift/cartridge_tools/lint.rb, line 22
def self.guess_schema_path(schema=nil)
  base_path = Dir.pwd
  unless schema.nil?
    schema_path = File.join(base_path, schema)
  else
    schema_path = File.join(File.dirname(__FILE__), '..', '..', '..', 'schema', CURRENT_MANIFEST_SCHEMA)
  end
  raise "Schema not found: #{schema_path}" unless File.exists?(schema_path)
  return schema_path
end
parse(manifest_file, schema_file=nil) click to toggle source
# File lib/openshift/cartridge_tools/lint.rb, line 33
def self.parse(manifest_file, schema_file=nil)
  manifest = YAML.load_file(manifest_file)
  schema = Kwalify::Yaml.load_file(schema_file)
  validator = Kwalify::Validator.new(schema)
  LintResult.get(validator.validate(manifest))
end