Class: FPM::Fry::Recipe::PackageBuilder

Inherits:
Struct
  • Object
show all
Defined in:
lib/fpm/fry/recipe/builder.rb

Direct Known Subclasses

Builder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variables, recipe = PackageRecipe.new, options = {}) ⇒ PackageBuilder

Returns a new instance of PackageBuilder.



14
15
16
17
# File 'lib/fpm/fry/recipe/builder.rb', line 14

def initialize( variables, recipe = PackageRecipe.new, options = {})
  super(variables, recipe)
  @logger = options.fetch(:logger){ Cabin::Channel.get }
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



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

def logger
  @logger
end

#package_recipeObject

Returns the value of attribute package_recipe

Returns:

  • (Object)

    the current value of package_recipe



10
11
12
# File 'lib/fpm/fry/recipe/builder.rb', line 10

def package_recipe
  @package_recipe
end

#variablesObject

Returns the value of attribute variables

Returns:

  • (Object)

    the current value of variables



10
11
12
# File 'lib/fpm/fry/recipe/builder.rb', line 10

def variables
  @variables
end

Instance Method Details

#after_install(*args) ⇒ Object Also known as: post_install, postinstall



120
121
122
# File 'lib/fpm/fry/recipe/builder.rb', line 120

def after_install(*args)
  script(:after_install, *args)
end

#after_remove(*args) ⇒ Object Also known as: after_uninstall, post_uninstall, postuninstall



133
134
135
# File 'lib/fpm/fry/recipe/builder.rb', line 133

def after_remove(*args)
  script(:after_remove, *args)
end

#before_install(*args) ⇒ Object Also known as: pre_install, preinstall



114
115
116
# File 'lib/fpm/fry/recipe/builder.rb', line 114

def before_install(*args)
  script(:before_install, *args)
end

#before_remove(*args) ⇒ Object Also known as: before_uninstall, pre_uninstall, preuninstall



126
127
128
# File 'lib/fpm/fry/recipe/builder.rb', line 126

def before_remove(*args)
  script(:before_remove, *args)
end

#codenameObject



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

def codename
  variables[:codename]
end

#conflicts(name, options = {}) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/fpm/fry/recipe/builder.rb', line 64

def conflicts( name , options = {} )
  name, options = parse_package(name, options)
  if package_recipe.conflicts.key? name
    raise Error.new("duplicate conflict",package: name)
  elsif package_recipe.depends.key? name
    raise Error.new("conflicting package is already a dependency",package: name)
  end
  package_recipe.conflicts[name] = options
end

#depends(name, options = {}) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/fpm/fry/recipe/builder.rb', line 54

def depends( name , options = {} )
  name, options = parse_package(name, options)
  if package_recipe.depends.key? name
    raise Error.new("duplicate dependency",package: name)
  elsif package_recipe.conflicts.key? name
    raise Error.new("depending package is already a conflicting package",package: name)
  end
  package_recipe.depends[name] = options
end

#distributionObject Also known as: platform



23
24
25
# File 'lib/fpm/fry/recipe/builder.rb', line 23

def distribution
  variables[:distribution]
end

#distribution_versionObject Also known as: platform_version



28
29
30
# File 'lib/fpm/fry/recipe/builder.rb', line 28

def distribution_version
  variables[:distribution_version]
end

#files(pattern) ⇒ Object



84
85
86
# File 'lib/fpm/fry/recipe/builder.rb', line 84

def files( pattern )
  package_recipe.files << pattern
end

#flavourObject



19
20
21
# File 'lib/fpm/fry/recipe/builder.rb', line 19

def flavour
  variables[:flavour]
end

#iteration(value = Not) ⇒ Object Also known as: revision



37
38
39
# File 'lib/fpm/fry/recipe/builder.rb', line 37

def iteration(value = Not)
  get_or_set('@iteration',value)
end

#name(value = Not) ⇒ Object



46
47
48
# File 'lib/fpm/fry/recipe/builder.rb', line 46

def name(value = Not)
  get_or_set('@name',value)
end

#output_hooksObject



140
141
142
# File 'lib/fpm/fry/recipe/builder.rb', line 140

def output_hooks
  package_recipe.output_hooks
end

#plugin(name, *args, &block) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/fpm/fry/recipe/builder.rb', line 88

def plugin(name, *args, &block)
  logger.debug('Loading Plugin', name: name, args: args, block: block, load_path: $LOAD_PATH)
  if name =~ /\A\./
    require name
  else
    require File.join('fpm/fry/plugin',name)
  end
  module_name = File.basename(name,'.rb').gsub(/(?:\A|_)([a-z])/){ $1.upcase }
  mod = FPM::Fry::Plugin.const_get(module_name)
  if mod.respond_to? :apply
    mod.apply(self, *args, &block)
  else
    if args.any? or block_given?
      raise ArgumentError, "Simple plugins can't accept additional arguments and blocks."
    end
    extend(mod)
  end
end

#provides(name, options = {}) ⇒ Object



74
75
76
77
# File 'lib/fpm/fry/recipe/builder.rb', line 74

def provides( name , options = {} )
  name, options = parse_package(name, options)
  package_recipe.provides[name] = options
end

#replaces(name, options = {}) ⇒ Object



79
80
81
82
# File 'lib/fpm/fry/recipe/builder.rb', line 79

def replaces( name , options = {} )
  name, options = parse_package(name, options)
  package_recipe.replaces[name] = options
end

#script(type, value = Not) ⇒ Object



107
108
109
110
111
112
# File 'lib/fpm/fry/recipe/builder.rb', line 107

def script(type, value = Not)
  if value != Not
    package_recipe.scripts[type] << value
  end
  return package_recipe.scripts[type]
end

#vendor(value = Not) ⇒ Object



50
51
52
# File 'lib/fpm/fry/recipe/builder.rb', line 50

def vendor(value = Not)
  get_or_set('@vendor',value)
end

#version(value = Not) ⇒ Object



42
43
44
# File 'lib/fpm/fry/recipe/builder.rb', line 42

def version(value = Not)
  get_or_set('@version',value)
end