class FPM::Fry::Inspector
An inspector allows a plugin to gather information about the image used to build a package.
Attributes
Public Class Methods
# 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
# File lib/fpm/fry/inspector.rb, line 61 def initialize(client, container) @client, @container = client, container end
Public Instance Methods
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
Determines the target of a link
@param [String] path @raise [FPM::Fry::Client::FileNotFound] when the given path doesn’t exist @return [String] target @return [nil] when file is not a link
# File lib/fpm/fry/inspector.rb, line 34 def link_target(path) return client.link_target(container, path) end
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
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