Class: OsCtl::Repo::Downloader::Direct
- Defined in:
- lib/osctl/repo/downloader/direct.rb
Overview
Download image in a specified format, no caching involved
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#get(vendor, variant, arch, dist, vtag, format, _opts = {}, &block) ⇒ Object
yieldparam [String] downloaded data.
- #list ⇒ Array<Remote::Image>
Methods inherited from Base
#connect, #index_uri, #initialize
Constructor Details
This class inherits a constructor from OsCtl::Repo::Downloader::Base
Instance Method Details
#get(vendor, variant, arch, dist, vtag, format, _opts = {}, &block) ⇒ Object
yieldparam [String] downloaded data
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/osctl/repo/downloader/direct.rb', line 16 def get(vendor, variant, arch, dist, vtag, format, _opts = {}, &block) connect do |http| index = Remote::Index.from_string(repo, http.get(index_uri.path).body) t = index.lookup(vendor, variant, arch, dist, vtag) raise 'image not found' unless t raise 'image not in given format' unless t.has_image?(format) uri = URI(t.abs_image_url(format)) http.request_get(uri.path) do |res| raise 'bad response' unless res.code == '200' res.read_body(&block) end end end |
#list ⇒ Array<Remote::Image>
8 9 10 11 12 13 |
# File 'lib/osctl/repo/downloader/direct.rb', line 8 def list connect do |http| index = Remote::Index.from_string(repo, http.get(index_uri.path).body) index.images end end |