Class: Albacore::FpmAppSpec
- Inherits:
-
Object
- Object
- Albacore::FpmAppSpec
- Includes:
- Logging
- Defined in:
- lib/albacore/fpm_app_spec.rb
Overview
An object that is capable of generating FPM commands - use by giving it a spec and then calling #execute or #generate_flags. You may use this object to package a directory.
Defined Under Namespace
Instance Method Summary collapse
-
#filename(flags = nil) ⇒ Object
gets the filename that the resulting file will have, based on the flags to be passed to fpm.
-
#generate ⇒ Object
Calls FPM with the flags generated.
-
#generate_flags(overrides = {}) ⇒ Object
Generate flags for FPM - if you don’t want to execute directly with the object you can use this method to generate what you should give to FPM yourself.
-
#generate_flags_flat(overrides = {}) ⇒ Object
Generates the flags and flatten them to an array that is possible to feed into the #system command.
-
#initialize(app_spec, output_dir_path = '.') ⇒ FpmAppSpec
constructor
Initialize the object with an ::Albacore::AppSpec.
Methods included from Logging
#debug, #err, #error, #fatal, #info, #puts, #trace, #warn
Constructor Details
#initialize(app_spec, output_dir_path = '.') ⇒ FpmAppSpec
Initialize the object with an ::Albacore::AppSpec
18 19 20 21 22 |
# File 'lib/albacore/fpm_app_spec.rb', line 18 def initialize app_spec, output_dir_path = '.' raise ArgumentError, 'missing app_spec parameter' unless app_spec @spec = app_spec @out = output_dir_path end |
Instance Method Details
#filename(flags = nil) ⇒ Object
gets the filename that the resulting file will have, based on the flags to be passed to fpm
53 54 55 56 57 |
# File 'lib/albacore/fpm_app_spec.rb', line 53 def filename flags = nil flags ||= generate_flags # TODO: handle OS architecture properly by taking from context "#{flags['--name']}-#{flags['--version']}-#{flags['--epoch']}.x86_64.rpm" end |
#generate ⇒ Object
Calls FPM with the flags generated
60 61 62 |
# File 'lib/albacore/fpm_app_spec.rb', line 60 def generate ::Albacore::CrossPlatformCmd.system 'fpm', generate_flags_flat end |
#generate_flags(overrides = {}) ⇒ Object
Generate flags for FPM - if you don’t want to execute directly with the object you can use this method to generate what you should give to FPM yourself
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/albacore/fpm_app_spec.rb', line 27 def generate_flags overrides = {} { '-s' => 'dir', '-t' => 'rpm', '--name' => @spec.title, '--description' => @spec.description, '--url' => @spec.uri, '--category' => @spec.category, '--version' => @spec.version, '--epoch' => 1, '--license' => @spec.license, '-C' => @spec.dir_path, '--depends' => 'mono', '--rpm-digest' => 'sha256', '--package' => @out }.merge(overrides).reject { |_, v| v.nil? } end |
#generate_flags_flat(overrides = {}) ⇒ Object
Generates the flags and flatten them to an array that is possible to feed into the #system command
47 48 49 |
# File 'lib/albacore/fpm_app_spec.rb', line 47 def generate_flags_flat overrides = {} generate_flags(overrides).map { |k, v| [k, v] }.concat(%w|--force .|).flatten end |