class FPM::Fry::Inspector

An inspector allows a plugin to gather information about the image used to build a package.

Attributes

client[R]
container[R]

Public Class Methods

for_image(client, image) { |new(client, container)| ... } click to toggle source
# File lib/fpm/fry/inspector.rb, line 51
def self.for_image(client, image)
  container = client.create(image)
  begin
    yield new(client, container)
  ensure
    client.destroy(container)
  end
end
new(client, container) click to toggle source
# File lib/fpm/fry/inspector.rb, line 61
def initialize(client, container)
  @client, @container = client, container
end

Public Instance Methods

exists?(path) click to toggle source

Checks if file exists at path

@param [String] path @return [true] when path exists @return [false] otherwise

# File lib/fpm/fry/inspector.rb, line 43
def exists?(path)
  client.read(container,path) do
    return true
  end
rescue FPM::Fry::Client::FileNotFound
  return false
end
read(path, &block) click to toggle source

Gets whatever is at path. This once if path is a file. And all subfiles if it’s a directory. Usually read_content is better.

@param [String] path path to a file @raise [FPM::Fry::Client::FileNotFound] when the given path doesn’t exist @raise [FPM::Fry::Client::NotAFile] when the given path is not a file @yield [entry] tar file entry @yieldparam entry [Gem::Package::TarEntry]

# File lib/fpm/fry/inspector.rb, line 24
def read(path, &block)
  return client.read(container, path, &block)
end
read_content(path) click to toggle source

Gets the file content at path.

@param [String] path path to a file @raise [FPM::Fry::Client::FileNotFound] when the given path doesn’t exist @raise [FPM::Fry::Client::NotAFile] when the given path is not a file @return [String] file content as string

# File lib/fpm/fry/inspector.rb, line 12
def read_content(path)
  return client.read_content(container, path)
end