class NVD::JSONFeeds::GzFeedFile
Public Instance Methods
extract()
click to toggle source
Extracts the feed file.
@return [JSONFeedFile]
@raise [ExtractFailed]
The `gunzip` command failed or did the `.json` file was not extracted.
# File lib/nvd/json_feeds/gz_feed_file.rb, line 44 def extract unless system('gunzip', '-q', '-k', @path) raise(ExtractFailed,"gunzip command failed") end extracted_dir = File.dirname(@path) extracted_path = File.join(extracted_dir,json_filename) unless File.file?(extracted_path) raise(ExtractFailed,"extraction failed: #{@path.inspect}") end return JSONFeedFile.new(extracted_path) end
json_filename()
click to toggle source
The filename of the `.json` file within the `.gz` archive.
@return [String]
# File lib/nvd/json_feeds/gz_feed_file.rb, line 18 def json_filename File.basename(@path,'.gz') end
read()
click to toggle source
Reads the compressed feed file.
@return [String]
@raise [ReadFailed]
The `gunzip` command is not installed.
# File lib/nvd/json_feeds/gz_feed_file.rb, line 30 def read `gunzip -q -c -k #{Shellwords.escape(@path)}` rescue Errno::ENOENT raise(ReadFailed,"gunzip command is not installed") end