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.



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

def initialize(filename)
  @filename = Path.new(filename).expand_path
  @source_handler = SourceHandler.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.



88
89
90
# File 'lib/fpm/cookery/recipe.rb', line 88

def filename
  @filename
end

#source_handlerObject (readonly)

Returns the value of attribute source_handler.



88
89
90
# File 'lib/fpm/cookery/recipe.rb', line 88

def source_handler
  @source_handler
end

Class Method Details

.architectures(archs) ⇒ Object



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

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

.attr_rw(*attrs) ⇒ Object



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

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



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

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



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

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

.platforms(valid_platforms) ⇒ Object



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

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

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



63
64
65
66
67
# File 'lib/fpm/cookery/recipe.rb', line 63

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

.urlObject



68
69
70
71
72
# File 'lib/fpm/cookery/recipe.rb', line 68

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

Instance Method Details

#builddir(path = nil) ⇒ Object



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

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

#builddir=(value) ⇒ Object



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

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

#cachedir(path = nil) ⇒ Object



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

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

#cachedir=(value) ⇒ Object



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

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

#destdir(path = nil) ⇒ Object



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

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

#destdir=(value) ⇒ Object



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

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

#pkgdir(path = nil) ⇒ Object



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

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

#pkgdir=(value) ⇒ Object



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

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

#sourceObject



75
76
77
# File 'lib/fpm/cookery/recipe.rb', line 75

def source
  self.class.source
end

#workdir(path = nil) ⇒ Object



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

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

#workdir=(value) ⇒ Object



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

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