Class: AdLint::Traits

Inherits:
Object
  • Object
show all
Includes:
Validation
Defined in:
lib/adlint/traits.rb

Overview

DESCRIPTION

Analysis configuration information.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validation

#ensure_dir_presence_of, #ensure_dirs_presence_of, #ensure_exam_packages_presence_of, #ensure_file_presence_of, #ensure_inclusion_of, #ensure_numericality_of, #ensure_presence_of, #ensure_true_or_false_of, #ensure_validity_of, #ensure_with, #errors, included, #valid?, #validators

Constructor Details

#initialize(traits_fpath) ⇒ Traits

Returns a new instance of Traits.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 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

Instance Attribute Details

#exam_packagesObject (readonly)

Returns the value of attribute exam_packages.



64
65
66
# File 'lib/adlint/traits.rb', line 64

def exam_packages
  @exam_packages
end

Instance Method Details

#entity_nameObject



82
83
84
# File 'lib/adlint/traits.rb', line 82

def entity_name
  ""
end

#of_compilerObject



70
71
72
# File 'lib/adlint/traits.rb', line 70

def of_compiler
  @compiler_traits
end

#of_linkerObject



74
75
76
# File 'lib/adlint/traits.rb', line 74

def of_linker
  @linker_traits
end

#of_messageObject



78
79
80
# File 'lib/adlint/traits.rb', line 78

def of_message
  @message_traits
end

#of_projectObject



66
67
68
# File 'lib/adlint/traits.rb', line 66

def of_project
  @project_traits
end