diff --git a/classes/nvd_downloader.rb b/classes/nvd_downloader.rb index b0c2151..9d465d9 100644 --- a/classes/nvd_downloader.rb +++ b/classes/nvd_downloader.rb @@ -1,4 +1,6 @@ require 'rest-client' +require 'zlib' +require 'json' class NvdDownloader attr_accessor :base_url, :years @@ -22,9 +24,18 @@ class NvdDownloader years[year] end - def get(url) - + r = RestClient.get "#{base_url}#{url}" + r.body if r.code == 200 end + def read_gzip_stream(gzip_stream) + io_stream = StringIO.new(gzip_stream) + gz = Zlib::GzipReader.new(io_stream) + gz.read + end + + def parse_json(json_string) + JSON.parse(json_string) + end end \ No newline at end of file