Class: CVEList::CVE

Inherits:
CVESchema::CVE
  • Object
show all
Defined in:
lib/cvelist/cve.rb

Overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, **kwargs) ⇒ CVE

Initializes the CVE.



22
23
24
25
26
# File 'lib/cvelist/cve.rb', line 22

def initialize(path, **kwargs)
  super(**kwargs)

  @path = path
end

Instance Attribute Details

#pathString (readonly)

The path to the CVE JSON.



14
15
16
# File 'lib/cvelist/cve.rb', line 14

def path
  @path
end

Class Method Details

.load(file) ⇒ CVE

Loads the CVE JSON from the given file.

Raises:

  • Failed to load the CVE JSON.



78
79
80
# File 'lib/cvelist/cve.rb', line 78

def self.load(file)
  new(file, **from_json(read(file)))
end

.parse(json) ⇒ Hash{String => Object}

Parses the given JSON.

Raises:

  • Could not parse the JSON in the given file.

API:

  • semipublic



42
43
44
45
46
# File 'lib/cvelist/cve.rb', line 42

def self.parse(json)
  MultiJson.load(json)
rescue MultiJson::ParseError => error
  raise(InvalidJSON,error.message)
end

.read(file) ⇒ Hash{String => Object}

Parses the JSON in the given file.

Raises:

  • Could not parse the JSON in the given file.

API:

  • semipublic



62
63
64
# File 'lib/cvelist/cve.rb', line 62

def self.read(file)
  parse(File.read(file))
end