Class: OsCtl::Repo::Downloader::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/osctl/repo/downloader/base.rb

Direct Known Subclasses

Cached, Direct

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo) ⇒ Base

Returns a new instance of Base.



5
6
7
# File 'lib/osctl/repo/downloader/base.rb', line 5

def initialize(repo)
  @repo = repo
end

Instance Attribute Details

#repoObject (readonly, protected)

Returns the value of attribute repo.



11
12
13
# File 'lib/osctl/repo/downloader/base.rb', line 11

def repo
  @repo
end

Instance Method Details

#connectObject (protected)



13
14
15
16
17
18
19
20
# File 'lib/osctl/repo/downloader/base.rb', line 13

def connect(&)
  uri = URI(repo.url)
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = (uri.scheme == 'https')
  http.start(&)
rescue SystemCallError => e
  raise NetworkError, e
end

#index_uriObject (protected)



22
23
24
# File 'lib/osctl/repo/downloader/base.rb', line 22

def index_uri
  URI(repo.index_url)
end