made method to extract metadata into json
This commit is contained in:
parent
4736d84e7d
commit
fa25c05ab9
1 changed files with 17 additions and 9 deletions
|
@ -75,7 +75,7 @@ module NvdTools
|
|||
# of all of the json.gz from each year + recent + modified json feeds
|
||||
end
|
||||
|
||||
def modified_meta(filename)
|
||||
def get_metadata_file(filename)
|
||||
file = filenames('meta').select do |name|
|
||||
name == filename
|
||||
end.first
|
||||
|
@ -85,18 +85,26 @@ module NvdTools
|
|||
# this should be a method that builds
|
||||
# the modified filename with the meta file extension included
|
||||
end
|
||||
|
||||
def check_metafile(metafile)
|
||||
|
||||
# open the metafile, build a hash of k/v pairs of the data inside of the file
|
||||
def extract_metadata(metadata)
|
||||
metaf = get_metadata_file(metadata)
|
||||
keys_and_values_str = metaf.map do |line|
|
||||
line.split(":", 2)
|
||||
end
|
||||
json = Hash[keys_and_values_str].to_json
|
||||
JSON.parse(json, { symbolize_names: true })
|
||||
end
|
||||
|
||||
def check_metadata(metadata_file_to_check, metadata_to_check_against)
|
||||
# check each k/v pair against the file on disk
|
||||
# return a new hash with the same k as before, but the value being a boolean true or false if the value from the k/v pair
|
||||
|
||||
end
|
||||
|
||||
def detect_changes(metafile)
|
||||
# this should be a method that detects changes in the metafile.
|
||||
# run the check_metafile method against the current metafile on disk.
|
||||
|
||||
def detect_changes(metadata)
|
||||
# this should be a method that detects changes in the metadata.
|
||||
# run the check_metadata method against the current metadata.
|
||||
# if there is a change, return true, if not return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue