Class: NVD::JSONFeeds::Meta
- Inherits:
-
Object
- Object
- NVD::JSONFeeds::Meta
- Defined in:
- lib/nvd/json_feeds/meta.rb
Overview
Represents the parsed contents of a .meta
file.
Instance Attribute Summary collapse
-
#gz_size ⇒ Integer
readonly
The size of the
.gz
feed file. -
#last_modified_date ⇒ DateTime
readonly
The date the feed file was last updated.
-
#sha256 ⇒ String
readonly
The SHA256 checksum of the uncompressed
.json
feed file. -
#size ⇒ Integer
readonly
The size of the uncompressed
.json
feed file. -
#zip_size ⇒ Integer
readonly
The size of the
.zip
feed file.
Class Method Summary collapse
-
.parse(string) ⇒ Meta
Parses the text.
Instance Method Summary collapse
-
#initialize(last_modified_date, size, zip_size, gz_size, sha256) ⇒ Meta
constructor
Initializes the feed metadata.
Constructor Details
#initialize(last_modified_date, size, zip_size, gz_size, sha256) ⇒ Meta
Initializes the feed metadata.
56 57 58 59 60 61 62 63 |
# File 'lib/nvd/json_feeds/meta.rb', line 56 def initialize(last_modified_date,size,zip_size,gz_size,sha256) @last_modified_date = last_modified_date @size = size @zip_size = zip_size @gz_size = gz_size @sha256 = sha256 end |
Instance Attribute Details
#gz_size ⇒ Integer (readonly)
The size of the .gz
feed file.
30 31 32 |
# File 'lib/nvd/json_feeds/meta.rb', line 30 def gz_size @gz_size end |
#last_modified_date ⇒ DateTime (readonly)
The date the feed file was last updated.
15 16 17 |
# File 'lib/nvd/json_feeds/meta.rb', line 15 def last_modified_date @last_modified_date end |
#sha256 ⇒ String (readonly)
Note:
NVD uses all upper-case SHA256 checksums.
The SHA256 checksum of the uncompressed .json
feed file.
36 37 38 |
# File 'lib/nvd/json_feeds/meta.rb', line 36 def sha256 @sha256 end |
#size ⇒ Integer (readonly)
The size of the uncompressed .json
feed file.
20 21 22 |
# File 'lib/nvd/json_feeds/meta.rb', line 20 def size @size end |
#zip_size ⇒ Integer (readonly)
The size of the .zip
feed file.
25 26 27 |
# File 'lib/nvd/json_feeds/meta.rb', line 25 def zip_size @zip_size end |
Class Method Details
.parse(string) ⇒ Meta
Parses the text.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/nvd/json_feeds/meta.rb', line 77 def self.parse(string) last_modified_date = nil size = nil zip_size = nil gz_size = nil sha256 = nil string.each_line do |line| name, value = line.chomp.split(':',2) case name when 'lastModifiedDate' last_modified_date = DateTime.parse(value) when 'size' then size = value.to_i when 'zipSize' then zip_size = value.to_i when 'gzSize' then gz_size = value.to_i when 'sha256' then sha256 = value end end unless last_modified_date raise(MetaParseError,"lastModifiedDate missing") end unless size raise(MetaParseError,"size entry missing") end unless zip_size raise(MetaParseError,"zipSize entry missing") end unless gz_size raise(MetaParseError,"gzSize entry missing") end unless sha256 raise(MetaParseError,"sha256 entry missing") end return new(last_modified_date,size,zip_size,gz_size,sha256) end |