class AdLint::Traits

DESCRIPTION

Analysis configuration information.

Attributes

exam_packages[R]

Public Class Methods

new(traits_fpath) click to toggle source
# File lib/adlint/traits.rb, line 42
def initialize(traits_fpath)
  File.open(traits_fpath, "r:utf-8") do |io|
    case ary_or_stream = YAML.load_stream(io)
    when Array
      # NOTE: YAML.load_stream returns Array in Ruby 1.9.3-preview1.
      doc = ary_or_stream.first
    when YAML::Stream
      doc = ary_or_stream.documents.first
    end
    validate_version(doc["version"])

    @exam_packages = (doc["exam_packages"] || []).uniq.map { |name|
      ExaminationPackage.new(name)
    }.freeze

    @project_traits  = ProjectTraits.new(doc["project_traits"]).freeze
    @compiler_traits = CompilerTraits.new(doc["compiler_traits"]).freeze
    @linker_traits   = LinkerTraits.new(doc["linker_traits"]).freeze
    @message_traits  = MessageTraits.new(doc["message_traits"]).freeze
  end
end

Public Instance Methods

entity_name() click to toggle source
# File lib/adlint/traits.rb, line 82
def entity_name
  ""
end
of_compiler() click to toggle source
# File lib/adlint/traits.rb, line 70
def of_compiler
  @compiler_traits
end
of_linker() click to toggle source
# File lib/adlint/traits.rb, line 74
def of_linker
  @linker_traits
end
of_message() click to toggle source
# File lib/adlint/traits.rb, line 78
def of_message
  @message_traits
end
of_project() click to toggle source
# File lib/adlint/traits.rb, line 66
def of_project
  @project_traits
end

Private Instance Methods

validate_version(ver) click to toggle source
# File lib/adlint/traits.rb, line 93
def validate_version(ver)
  ver == TRAITS_SCHEMA_VERSION or
    raise "invalid version of the traits file.\n" +
          "regenerate or migrate traits file by new `adlintize' command."
end