Class: FPM::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/fpm/rake_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package_name, opts = {}, &block) ⇒ RakeTask

Returns a new instance of RakeTask.


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fpm/rake_task.rb', line 9

def initialize(package_name, opts = {}, &block)
  @options = OpenStruct.new(:name => package_name.to_s)
  @source, @target = opts.values_at(:source, :target).map(&:to_s)
  @directory = File.expand_path(opts[:directory].to_s)

  (@source.empty? || @target.empty? || options.name.empty?) &&
    abort("Must specify package name, source and output")

  desc "Package #{@name}" unless ::Rake.application.last_description

  task(options.name) do |_, task_args|
    block.call(*[options, task_args].first(block.arity)) if block_given?
    abort("Must specify args") unless options.respond_to?(:args)
    @args = options.delete_field(:args)
    run_cli
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options


7
8
9
# File 'lib/fpm/rake_task.rb', line 7

def options
  @options
end