class CVEList::CVE

@see rubydoc.info/gems/cve_schema/CVESchema/CVE/frames

Attributes

path[R]

The path to the CVE JSON.

@return [String]

Public Class Methods

load(file) click to toggle source

Loads the CVE JSON from the given file.

@param [String] file

The path to the file.

@return [CVE]

The loaded CVE object.

@raise [InvalidJSON, MissingJSONKey, UnknownJSONValue]

Failed to load the CVE JSON.
# File lib/cvelist/cve.rb, line 78
def self.load(file)
  new(file, **from_json(read(file)))
end
new(path, **kwargs) click to toggle source

Initializes the CVE.

@param [String] path

The path to the CVE JSON.
Calls superclass method
# File lib/cvelist/cve.rb, line 22
def initialize(path, **kwargs)
  super(**kwargs)

  @path = path
end
parse(json) click to toggle source

Parses the given JSON.

@param [String] json

The raw JSON.

@return [Hash{String => Object}]

The parsed JSON.

@raise [InvalidJSON]

Could not parse the JSON in the given file.

@api semipublic

# 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) click to toggle source

Parses the JSON in the given file.

@param [String] file

The path to the file.

@return [Hash{String => Object}]

The parsed JSON.

@raise [InvalidJSON]

Could not parse the JSON in the given file.

@api semipublic

# File lib/cvelist/cve.rb, line 62
def self.read(file)
  parse(File.read(file))
end