Class: Jdt::ManifestValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/jdt/manifest/validation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manifest) ⇒ ManifestValidator

Returns a new instance of ManifestValidator.



89
90
91
# File 'lib/jdt/manifest/validation.rb', line 89

def initialize(manifest)
  @manifest = manifest
end

Instance Attribute Details

#manifestObject

Returns the value of attribute manifest.



87
88
89
# File 'lib/jdt/manifest/validation.rb', line 87

def manifest
  @manifest
end

Instance Method Details

#valid?Boolean

Validates the manifest

Returns:

  • (Boolean)

    bool true if valid, false otherwise



96
97
98
99
100
101
102
103
104
105
# File 'lib/jdt/manifest/validation.rb', line 96

def valid?

  # ERROR when specified files and folders do not exist

  # ERROR when optional metadata field is missing (version, author, ...)
  # WARNING when metadata is missing

  # evaluate the validation result
  @manifest.errors.empty?
end

#validate_directory_existence(dir) ⇒ Object



113
114
115
116
117
# File 'lib/jdt/manifest/validation.rb', line 113

def validate_directory_existence(dir)
  if (not Dir.exist?(file))
    manifest.errors << "File #{file} does not exist, but should"
  end
end

#validate_file_existence(file) ⇒ Object



107
108
109
110
111
# File 'lib/jdt/manifest/validation.rb', line 107

def validate_file_existence(file)
  if (not File.exist?(file))
    manifest.errors << "File #{file} does not exist, but should"
  end
end