Class: FPM::Fry::Inspector

Inherits:
Object
  • Object
show all
Defined in:
lib/fpm/fry/inspector.rb

Overview

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_image(client, image) ⇒ Object



51
52
53
54
55
56
57
58
# 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

Instance Method Details

#exists?(path) ⇒ true, false

Checks if file exists at path

Parameters:

  • path (String)

Returns:

  • (true)

    when path exists

  • (false)

    otherwise



43
44
45
46
47
48
49
# 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

Parameters:

  • path (String)

Returns:

  • (String)

    target

  • (nil)

    when file is not a link

Raises:



34
35
36
# File 'lib/fpm/fry/inspector.rb', line 34

def link_target(path)
  return client.link_target(container, path)
end

#read(path) {|entry| ... } ⇒ Object

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.

Parameters:

  • path (String)

    path to a file

Yields:

  • (entry)

    tar file entry

Yield Parameters:

  • entry (Gem::Package::TarEntry)

Raises:



24
25
26
# File 'lib/fpm/fry/inspector.rb', line 24

def read(path, &block)
  return client.read(container, path, &block)
end

#read_content(path) ⇒ String

Gets the file content at path.

Parameters:

  • path (String)

    path to a file

Returns:

  • (String)

    file content as string

Raises:



12
13
14
# File 'lib/fpm/fry/inspector.rb', line 12

def read_content(path)
  return client.read_content(container, path)
end