Class: Ssg::Downloader

Inherits:
Object
  • Object
show all
Defined in:
lib/ssg/downloader.rb

Overview

Downloads SCAP datastreams from the SCAP Security Guide github.com/ComplianceAsCode/content

Constant Summary collapse

RELEASES_API =
'https://api.github.com/repos'\
'/ComplianceAsCode/content/releases/'
SSG_DS_REGEX =
/scap-security-guide-(\d+\.)+zip$/

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version = 'latest') ⇒ Downloader

Returns a new instance of Downloader.



14
15
16
17
18
# File 'lib/ssg/downloader.rb', line 14

def initialize(version = 'latest')
  @release_uri = URI(
    "#{RELEASES_API}#{'tags/' unless version[/^latest$/]}#{version}"
  )
end

Class Method Details

.download!(versions = []) ⇒ Object



20
21
22
23
24
# File 'lib/ssg/downloader.rb', line 20

def self.download!(versions = [])
  versions.uniq.map do |version|
    [version, new(version).fetch_datastream_file]
  end.to_h
end

Instance Method Details

#fetch_datastream_fileObject



26
27
28
29
30
31
# File 'lib/ssg/downloader.rb', line 26

def fetch_datastream_file
  puts "Fetching #{datastream_filename}"
  get_chunked(datastream_uri)

  datastream_filename
end