Class: RelatonNist::PubsExport
- Inherits:
-
Object
- Object
- RelatonNist::PubsExport
- Includes:
- Singleton
- Defined in:
- lib/relaton_nist/pubs_export.rb
Constant Summary collapse
- DOMAIN =
"https://csrc.nist.gov".freeze
- PUBS_EXPORT =
URI.join(DOMAIN, "/CSRC/media/feeds/metanorma/pubs-export")
- DATAFILEDIR =
File. ".relaton/nist", Dir.home
- DATAFILE =
File. "pubs-export.zip", DATAFILEDIR
Instance Method Summary collapse
-
#data ⇒ Array<Hash>
Fetches json data form server.
-
#initialize ⇒ PubsExport
constructor
A new instance of PubsExport.
Constructor Details
#initialize ⇒ PubsExport
Returns a new instance of PubsExport.
10 11 12 |
# File 'lib/relaton_nist/pubs_export.rb', line 10 def initialize @mutex = Mutex.new end |
Instance Method Details
#data ⇒ Array<Hash>
Fetches json data form server
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/relaton_nist/pubs_export.rb', line 19 def data @mutex.synchronize do @data ||= begin ctime = File.ctime DATAFILE if File.exist? DATAFILE if !ctime || ctime.to_date < Date.today || File.size(DATAFILE).zero? fetch_data(ctime) end unzip end end end |