Class: FPM::Fry::Recipe::PackageBuilder
- Inherits:
-
Struct
- Object
- Struct
- FPM::Fry::Recipe::PackageBuilder
- Defined in:
- lib/fpm/fry/recipe/builder.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#package_recipe ⇒ Object
Returns the value of attribute package_recipe.
-
#variables ⇒ Object
Returns the value of attribute variables.
Instance Method Summary collapse
- #after_install(*args) ⇒ Object (also: #post_install, #postinstall)
- #after_remove(*args) ⇒ Object (also: #after_uninstall, #post_uninstall, #postuninstall)
- #before_install(*args) ⇒ Object (also: #pre_install, #preinstall)
- #before_remove(*args) ⇒ Object (also: #before_uninstall, #pre_uninstall, #preuninstall)
- #codename ⇒ Object
- #conflicts(name, options = {}) ⇒ Object
- #depends(name, options = {}) ⇒ Object
- #distribution ⇒ Object (also: #platform)
- #distribution_version ⇒ Object (also: #platform_version)
- #files(pattern) ⇒ Object
- #flavour ⇒ Object
-
#initialize(variables, recipe = PackageRecipe.new, options = {}) ⇒ PackageBuilder
constructor
A new instance of PackageBuilder.
- #iteration(value = Not) ⇒ Object (also: #revision)
- #name(value = Not) ⇒ Object
- #output_hooks ⇒ Object
- #plugin(name, *args, &block) ⇒ Object
- #provides(name, options = {}) ⇒ Object
- #replaces(name, options = {}) ⇒ Object
- #script(type, value = Not) ⇒ Object
- #vendor(value = Not) ⇒ Object
- #version(value = Not) ⇒ Object
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, = {}) super(variables, recipe) @logger = .fetch(:logger){ Cabin::Channel.get } end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
12 13 14 |
# File 'lib/fpm/fry/recipe/builder.rb', line 12 def logger @logger end |
#package_recipe ⇒ Object
Returns the value of attribute package_recipe
10 11 12 |
# File 'lib/fpm/fry/recipe/builder.rb', line 10 def package_recipe @package_recipe end |
#variables ⇒ Object
Returns the value of attribute 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 |
#codename ⇒ Object
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 , = {} ) name, = parse_package(name, ) 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] = 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 , = {} ) name, = parse_package(name, ) 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] = end |
#distribution ⇒ Object Also known as: platform
23 24 25 |
# File 'lib/fpm/fry/recipe/builder.rb', line 23 def distribution variables[:distribution] end |
#distribution_version ⇒ Object 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 |
#flavour ⇒ Object
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_hooks ⇒ Object
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 , = {} ) name, = parse_package(name, ) package_recipe.provides[name] = end |
#replaces(name, options = {}) ⇒ Object
79 80 81 82 |
# File 'lib/fpm/fry/recipe/builder.rb', line 79 def replaces( name , = {} ) name, = parse_package(name, ) package_recipe.replaces[name] = 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 |