Class: FPM::Fry::Recipe

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

Overview

A FPM::Fry::Recipe contains all information needed to build a package.

It is usually created by Builder.

Defined Under Namespace

Classes: Builder, Error, NotFound, PackageBuilder, PackageRecipe, Step

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRecipe

Returns a new instance of Recipe.



159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/fpm/fry/recipe.rb', line 159

def initialize
  @source = Source::Null
  @before_dependencies_steps = []
  @before_build_steps = []
  @steps = []
  @packages = [PackageRecipe.new]
  @packages[0].files << '**'
  @build_depends = {}
  @input_hooks = []
  @dockerfile_hooks = []
  @build_mounts = []
end

Instance Attribute Details

#before_build_stepsArray<#to_s>

Returns steps that will be carried out before build.

Returns:

  • (Array<#to_s>)

    steps that will be carried out before build



142
143
144
# File 'lib/fpm/fry/recipe.rb', line 142

def before_build_steps
  @before_build_steps
end

#before_dependencies_stepsArray<#to_s>

Returns steps that will be carried out before dependencies are installed.

Returns:

  • (Array<#to_s>)

    steps that will be carried out before dependencies are installed



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

def before_dependencies_steps
  @before_dependencies_steps
end

#build_dependsHash<String,Hash>

Returns build dependencies.

Returns:

  • (Hash<String,Hash>)

    build dependencies



151
152
153
# File 'lib/fpm/fry/recipe.rb', line 151

def build_depends
  @build_depends
end

#build_mountsObject

Returns the value of attribute build_mounts.



136
137
138
# File 'lib/fpm/fry/recipe.rb', line 136

def build_mounts
  @build_mounts
end

#dockerfile_hooksArray<#call>

Returns hooks that will be called when building the Dockerfile.

Returns:

  • (Array<#call>)

    hooks that will be called when building the Dockerfile



157
158
159
# File 'lib/fpm/fry/recipe.rb', line 157

def dockerfile_hooks
  @dockerfile_hooks
end

#input_hooksArray<#call>

Returns hooks that will be called on the input package.

Returns:

  • (Array<#call>)

    hooks that will be called on the input package



154
155
156
# File 'lib/fpm/fry/recipe.rb', line 154

def input_hooks
  @input_hooks
end

#packagesArray<FPM::Fry::PackageRecipe>

Returns a list of packages that will be created.

Returns:

  • (Array<FPM::Fry::PackageRecipe>)

    a list of packages that will be created



148
149
150
# File 'lib/fpm/fry/recipe.rb', line 148

def packages
  @packages
end

#sourceFPM::Fry::Source

Returns the source used for building.

Returns:



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

def source
  @source
end

#stepsArray<#to_s>

Returns steps that will be carried out during build.

Returns:

  • (Array<#to_s>)

    steps that will be carried out during build



145
146
147
# File 'lib/fpm/fry/recipe.rb', line 145

def steps
  @steps
end

Instance Method Details

#apply_dockerfile_hooks(df) ⇒ Object

Filters the dockerfile

Parameters:

  • df (Hash)


199
200
201
202
203
204
# File 'lib/fpm/fry/recipe.rb', line 199

def apply_dockerfile_hooks( df )
  dockerfile_hooks.each do |hook|
    hook.call(self, df)
  end
  return nil
end

#apply_input(package) ⇒ FPM::Package

Applies input settings to package

Parameters:

  • package (FPM::Package)

Returns:

  • (FPM::Package)


191
192
193
194
# File 'lib/fpm/fry/recipe.rb', line 191

def apply_input( package )
  input_hooks.each{|h| h.call(self, package) }
  return package
end

#dependsHash<String,Hash>

Calculates all dependencies of this recipe

Returns:

  • (Hash<String,Hash>)

    the dependencies



174
175
176
177
178
179
180
# File 'lib/fpm/fry/recipe.rb', line 174

def depends
  depends = @packages.map(&:depends).inject(:merge)
  @packages.map(&:name).each do | n |
    depends.delete(n)
  end
  return depends
end

#lintArray<String>

Checks all packages for common errors

Returns:

  • (Array<String>)

    problems



184
185
186
# File 'lib/fpm/fry/recipe.rb', line 184

def lint
  packages.flat_map(&:lint)
end