Class: Spandx::Rubygems::Backups

Inherits:
Object
  • Object
show all
Defined in:
lib/spandx/rubygems/backups.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url: 'https://s3-us-west-2.amazonaws.com/rubygems-dumps/') ⇒ Backups

Returns a new instance of Backups.



8
9
10
11
# File 'lib/spandx/rubygems/backups.rb', line 8

def initialize(base_url: 'https://s3-us-west-2.amazonaws.com/rubygems-dumps/')
  @base_url = base_url
  @http = Net::Hippie::Client.new
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



6
7
8
# File 'lib/spandx/rubygems/backups.rb', line 6

def base_url
  @base_url
end

Instance Method Details

#eachObject



13
14
15
16
17
18
19
20
# File 'lib/spandx/rubygems/backups.rb', line 13

def each
  response = @http.get(base_url)
  to_xml(response.body).search('//Contents/Key').reverse.each do |node|
    next unless valid?(node.text)

    yield Backup.new(URI.join(base_url, node.text), db_connection)
  end
end