class Prof::Product

Attributes

path[R]

Public Class Methods

new(path:) click to toggle source
# File lib/prof/product.rb, line 20
def initialize(path:)
  raise InvalidProductPathError, "Invalid path given: '#{path}'" unless path && File.exist?(path)
  @path = File.expand_path(path)
end

Public Instance Methods

==(other) click to toggle source
# File lib/prof/product.rb, line 41
def ==(other)
  self.class == other.class &&
  self.path == other.path
end
Also aliased as: eql?
eql?(other)
Alias for: ==
file() click to toggle source
# File lib/prof/product.rb, line 37
def file
  File.open(path)
end
name() click to toggle source
# File lib/prof/product.rb, line 25
def name
  metadata.fetch('name')
end
to_s() click to toggle source
# File lib/prof/product.rb, line 33
def to_s
  "#{name} v#{version}"
end
version() click to toggle source
# File lib/prof/product.rb, line 29
def version
  metadata.fetch('product_version')
end

Private Instance Methods

metadata() click to toggle source
# File lib/prof/product.rb, line 49
def metadata
  @metadata ||= begin
    yaml = Zip::File.open(path) do |zip_file|
      entry = zip_file.glob('metadata/*').first
      entry.get_input_stream.read
    end
    YAML.load(yaml)
  end
end