Class: OsCtl::Repo::Remote::Index
- Inherits:
-
Object
- Object
- OsCtl::Repo::Remote::Index
- Defined in:
- lib/osctl/repo/remote/index.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
protected
Returns the value of attribute contents.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#vendors ⇒ Object
readonly
protected
Returns the value of attribute vendors.
Class Method Summary collapse
Instance Method Summary collapse
- #images ⇒ Object
-
#initialize(repo, data) ⇒ Index
constructor
A new instance of Index.
- #lookup(vendor, variant, arch, dist, vtag) ⇒ Object
Constructor Details
Instance Attribute Details
#contents ⇒ Object (readonly, protected)
Returns the value of attribute contents.
40 41 42 |
# File 'lib/osctl/repo/remote/index.rb', line 40 def contents @contents end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
13 14 15 |
# File 'lib/osctl/repo/remote/index.rb', line 13 def repo @repo end |
#vendors ⇒ Object (readonly, protected)
Returns the value of attribute vendors.
40 41 42 |
# File 'lib/osctl/repo/remote/index.rb', line 40 def vendors @vendors end |
Class Method Details
.from_file(repo, path) ⇒ Object
9 10 11 |
# File 'lib/osctl/repo/remote/index.rb', line 9 def self.from_file(repo, path) from_string(repo, File.read(path)) end |
.from_string(repo, str) ⇒ Object
5 6 7 |
# File 'lib/osctl/repo/remote/index.rb', line 5 def self.from_string(repo, str) new(repo, JSON.parse(str, symbolize_names: true)) end |
Instance Method Details
#images ⇒ Object
34 35 36 |
# File 'lib/osctl/repo/remote/index.rb', line 34 def images @contents end |
#lookup(vendor, variant, arch, dist, vtag) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/osctl/repo/remote/index.rb', line 21 def lookup(vendor, variant, arch, dist, vtag) real_vendor = vendor == 'default' ? vendors[:default] : vendor real_variant = variant == 'default' ? vendors[real_vendor.to_sym] : variant contents.detect do |t| t.vendor == real_vendor \ && t.variant == real_variant \ && t.arch == arch \ && t.distribution == dist \ && (t.version == vtag || t..include?(vtag)) end end |