Class: OsCtl::Repo::Base::Image
- Inherits:
-
Object
- Object
- OsCtl::Repo::Base::Image
- Defined in:
- lib/osctl/repo/base/image.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#arch ⇒ Object
readonly
Returns the value of attribute arch.
-
#distribution ⇒ Object
readonly
Returns the value of attribute distribution.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
-
#vendor ⇒ Object
readonly
Returns the value of attribute vendor.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #abs_dir_path ⇒ Object
- #abs_image_path(format) ⇒ Object
- #abs_tag_path(tag) ⇒ Object
- #dir_path ⇒ Object
- #dump ⇒ Object
- #has_image?(fmt) ⇒ Boolean
- #image_name(format) ⇒ Object
- #image_path(format) ⇒ Object
-
#initialize(repo, vendor, variant, arch, dist, ver, opts) ⇒ Image
constructor
A new instance of Image.
- #to_s ⇒ Object
- #version_image_path(format) ⇒ Object
Constructor Details
#initialize(repo, vendor, variant, arch, dist, ver, opts) ⇒ Image
Returns a new instance of Image.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/osctl/repo/base/image.rb', line 19 def initialize(repo, vendor, variant, arch, dist, ver, opts) @repo = repo @vendor = vendor @variant = variant @arch = arch @distribution = dist @version = ver @tags = opts[:tags] || [] @image = opts[:image] end |
Instance Attribute Details
#arch ⇒ Object (readonly)
Returns the value of attribute arch.
16 17 18 |
# File 'lib/osctl/repo/base/image.rb', line 16 def arch @arch end |
#distribution ⇒ Object (readonly)
Returns the value of attribute distribution.
16 17 18 |
# File 'lib/osctl/repo/base/image.rb', line 16 def distribution @distribution end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
16 17 18 |
# File 'lib/osctl/repo/base/image.rb', line 16 def image @image end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
16 17 18 |
# File 'lib/osctl/repo/base/image.rb', line 16 def repo @repo end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
16 17 18 |
# File 'lib/osctl/repo/base/image.rb', line 16 def @tags end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
16 17 18 |
# File 'lib/osctl/repo/base/image.rb', line 16 def variant @variant end |
#vendor ⇒ Object (readonly)
Returns the value of attribute vendor.
16 17 18 |
# File 'lib/osctl/repo/base/image.rb', line 16 def vendor @vendor end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
16 17 18 |
# File 'lib/osctl/repo/base/image.rb', line 16 def version @version end |
Class Method Details
.load(repo, data) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/osctl/repo/base/image.rb', line 3 def self.load(repo, data) new( repo, data[:vendor], data[:variant], data[:arch], data[:distribution], data[:version], tags: data[:tags], image: data[:image].keys.map(&:to_s) ) end |
Instance Method Details
#<=>(other) ⇒ Object
87 88 89 90 91 |
# File 'lib/osctl/repo/base/image.rb', line 87 def <=>(other) [vendor, variant, arch, distribution, version] \ <=> \ [other.vendor, other.variant, other.arch, other.distribution, other.version] end |
#==(other) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/osctl/repo/base/image.rb', line 79 def ==(other) vendor == other.vendor \ && variant == other.variant \ && arch == other.arch \ && distribution == other.distribution \ && version == other.version end |
#abs_dir_path ⇒ Object
46 47 48 |
# File 'lib/osctl/repo/base/image.rb', line 46 def abs_dir_path File.join(repo.path, dir_path) end |
#abs_image_path(format) ⇒ Object
71 72 73 |
# File 'lib/osctl/repo/base/image.rb', line 71 def abs_image_path(format) File.join(repo.path, image_path(format)) end |
#abs_tag_path(tag) ⇒ Object
50 51 52 |
# File 'lib/osctl/repo/base/image.rb', line 50 def abs_tag_path(tag) File.join(repo.path, vendor, variant, arch, distribution, tag) end |
#dir_path ⇒ Object
42 43 44 |
# File 'lib/osctl/repo/base/image.rb', line 42 def dir_path File.join(vendor, variant, arch, distribution, version) end |
#dump ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/osctl/repo/base/image.rb', line 30 def dump { vendor:, variant:, arch:, distribution:, version:, tags: .sort, image: image.to_h { |v| [v, image_path(v)] } } end |
#has_image?(fmt) ⇒ Boolean
75 76 77 |
# File 'lib/osctl/repo/base/image.rb', line 75 def has_image?(fmt) image.include?(fmt) end |
#image_name(format) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/osctl/repo/base/image.rb', line 62 def image_name(format) case format.to_sym when :tar 'image-archive.tar' when :zfs 'image-stream.tar' end end |
#image_path(format) ⇒ Object
54 55 56 |
# File 'lib/osctl/repo/base/image.rb', line 54 def image_path(format) File.join(dir_path, image_name(format)) end |
#to_s ⇒ Object
93 94 95 |
# File 'lib/osctl/repo/base/image.rb', line 93 def to_s "#{distribution}-#{version}-#{arch}-#{vendor}-#{variant}" end |
#version_image_path(format) ⇒ Object
58 59 60 |
# File 'lib/osctl/repo/base/image.rb', line 58 def version_image_path(format) File.join("v#{SCHEMA}", image_path(format)) end |