Class: FPM::Source

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

Overview

Abstract class for a “thing to build a package from”

Direct Known Subclasses

Dir, Gem, Npm, Python, RPM, Tar

Defined Under Namespace

Classes: Dir, Gem, Npm, Python, RPM, Tar

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths, root, params = {}) ⇒ Source

Returns a new instance of Source.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fpm/source.rb', line 29

def initialize(paths, root, params={})
  @logger = Logger.new(STDERR)
  @logger.level = $DEBUG ? Logger::DEBUG : Logger::WARN

  @paths = paths
  @root = root

  self[:suffix] = params[:suffix]
  self[:settings] = params[:settings]

  get_source(params)
  

  # override the inferred data with the passed-in data
  params.each do |k,v|
    self[k] = v if v != nil
  end
end

Instance Attribute Details

#pathsObject (readonly)

Returns the value of attribute paths.



26
27
28
# File 'lib/fpm/source.rb', line 26

def paths
  @paths
end

#rootObject

Returns the value of attribute root.



27
28
29
# File 'lib/fpm/source.rb', line 27

def root
  @root
end

Instance Method Details

#[](key) ⇒ Object



70
71
72
# File 'lib/fpm/source.rb', line 70

def [](key)
  [key.to_sym]
end

#[]=(key, val) ⇒ Object



74
75
76
# File 'lib/fpm/source.rb', line 74

def []=(key,val)
  [key.to_sym] = val
end

#dependenciesObject



22
23
24
# File 'lib/fpm/source.rb', line 22

def dependencies
  self[:dependencies] ||= []
end

#get_metadataObject

this method should take the paths and root and infer as much about the package as it can.

Raises:

  • (NoMethodError)


50
51
52
53
# File 'lib/fpm/source.rb', line 50

def 
  raise NoMethodError,
    "Please subclass FPM::Source and define get_metadata"
end

#get_source(params) ⇒ Object

This method should be overridden by package sources that need to do any kind of fetching.



57
58
59
# File 'lib/fpm/source.rb', line 57

def get_source(params)
  # noop by default
end

#make_tarball!(tar_path, builddir) ⇒ Object

def get_source

Raises:

  • (NoMethodError)


61
62
63
64
# File 'lib/fpm/source.rb', line 61

def make_tarball!(tar_path, builddir)
  raise NoMethodError,
    "Please subclass FPM::Source and define make_tarball!(tar_path)"
end

#metadataObject



66
67
68
# File 'lib/fpm/source.rb', line 66

def 
  @metadata ||= {}
end

#package(pkg_cls) ⇒ Object

MySourceClass.new(‘/tmp/build’).package(FPM::Deb).assemble(params)



79
80
81
# File 'lib/fpm/source.rb', line 79

def package(pkg_cls)
  pkg_cls.new(self)
end