Class: FPM::Cookery::Recipe

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
PathHelper, Utils, FileUtils
Defined in:
lib/fpm/cookery/recipe.rb

Instance Attribute Summary collapse

Attributes included from PathHelper

#installing

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PathHelper

#bin, #doc, #etc, #include, #info, #installing?, #lib, #libexec, #man, #man1, #man2, #man3, #man4, #man5, #man6, #man7, #man8, #opt, #prefix, #sbin, #share, #var, #with_trueprefix

Constructor Details

#initialize(filename) ⇒ Recipe

Returns a new instance of Recipe.



81
82
83
84
85
86
87
88
# File 'lib/fpm/cookery/recipe.rb', line 81

def initialize(filename)
  @filename = Path.new(filename).expand_path
  @source_handler = SourceHandler.new(Source.new(source, spec), cachedir, builddir)

  # Set some defaults.
  vendor || self.class.vendor('fpm')
  revision || self.class.revision(0)
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



90
91
92
# File 'lib/fpm/cookery/recipe.rb', line 90

def filename
  @filename
end

#source_handlerObject (readonly)

Returns the value of attribute source_handler.



90
91
92
# File 'lib/fpm/cookery/recipe.rb', line 90

def source_handler
  @source_handler
end

Class Method Details

.architectures(archs) ⇒ Object



34
35
36
# File 'lib/fpm/cookery/recipe.rb', line 34

def self.architectures(archs)
  Array(archs).member?(FPM::Cookery::Facts.arch) and block_given? ? yield : false
end

.attr_rw(*attrs) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fpm/cookery/recipe.rb', line 16

def self.attr_rw(*attrs)
  attrs.each do |attr|
    class_eval %Q{
      def self.#{attr}(value = nil)
        value.nil? ? @#{attr} : @#{attr} = value
      end

      def #{attr}
        self.class.#{attr}
      end
    }
  end
end

.attr_rw_list(*attrs) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fpm/cookery/recipe.rb', line 38

def self.attr_rw_list(*attrs)
  attrs.each do |attr|
    class_eval %Q{
      def self.#{attr}(*list)
        @#{attr} ||= []
        @#{attr} << list
        @#{attr}.flatten!
        @#{attr}.uniq!
        @#{attr}
      end

      def #{attr}
        self.class.#{attr}
      end
    }
  end
end

.platformObject



72
73
74
# File 'lib/fpm/cookery/recipe.rb', line 72

def platform
  FPM::Cookery::Facts.platform
end

.platforms(valid_platforms) ⇒ Object



30
31
32
# File 'lib/fpm/cookery/recipe.rb', line 30

def self.platforms(valid_platforms)
  Array(valid_platforms).member?(self.platform) and block_given? ? yield : false
end

.source(source = nil, spec = {}) ⇒ Object



65
66
67
68
69
# File 'lib/fpm/cookery/recipe.rb', line 65

def source(source = nil, spec = {})
  return @source if source.nil?
  @source = source
  @spec = spec
end

.urlObject



70
71
72
73
74
# File 'lib/fpm/cookery/recipe.rb', line 70

def source(source = nil, spec = {})
  return @source if source.nil?
  @source = source
  @spec = spec
end

Instance Method Details

#builddir(path = nil) ⇒ Object



103
# File 'lib/fpm/cookery/recipe.rb', line 103

def builddir(path = nil) (@builddir ||= workdir('tmp-build'))/path   end

#builddir=(value) ⇒ Object



97
# File 'lib/fpm/cookery/recipe.rb', line 97

def builddir=(value) @builddir = Path.new(value) end

#cachedir(path = nil) ⇒ Object



105
# File 'lib/fpm/cookery/recipe.rb', line 105

def cachedir(path = nil) (@cachedir ||= workdir('cache'))/path       end

#cachedir=(value) ⇒ Object



99
# File 'lib/fpm/cookery/recipe.rb', line 99

def cachedir=(value) @cachedir = Path.new(value) end

#destdir(path = nil) ⇒ Object



102
# File 'lib/fpm/cookery/recipe.rb', line 102

def destdir(path = nil)  (@destdir  ||= workdir('tmp-dest'))/path    end

#destdir=(value) ⇒ Object



96
# File 'lib/fpm/cookery/recipe.rb', line 96

def destdir=(value)  @destdir  = Path.new(value) end

#pkgdir(path = nil) ⇒ Object



104
# File 'lib/fpm/cookery/recipe.rb', line 104

def pkgdir(path = nil)   (@pkgdir   ||= workdir('pkg'))/path         end

#pkgdir=(value) ⇒ Object



98
# File 'lib/fpm/cookery/recipe.rb', line 98

def pkgdir=(value)   @pkgdir   = Path.new(value) end

#sourceObject



77
78
79
# File 'lib/fpm/cookery/recipe.rb', line 77

def source
  self.class.source
end

#workdir(path = nil) ⇒ Object



101
# File 'lib/fpm/cookery/recipe.rb', line 101

def workdir(path = nil)  (@workdir  ||= filename.dirname)/path       end

#workdir=(value) ⇒ Object



95
# File 'lib/fpm/cookery/recipe.rb', line 95

def workdir=(value)  @workdir  = Path.new(value) end