Class: PackagingTask

Inherits:
Object show all
Defined in:
lib/gpm/packaging_task.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, target) ⇒ PackagingTask

Returns a new instance of PackagingTask.



25
26
27
28
# File 'lib/gpm/packaging_task.rb', line 25

def initialize(source,target)
  @source = source
  @target = target
end

Class Method Details

.class_for_source(source_name) ⇒ Object



3
4
5
6
7
# File 'lib/gpm/packaging_task.rb', line 3

def self.class_for_source(source_name)
  require_relative "source"
  require_relative "source/#{source_name}"
  Source.const_get(source_name.capitalize)
end

.class_for_target(target_name) ⇒ Object



9
10
11
12
13
# File 'lib/gpm/packaging_task.rb', line 9

def self.class_for_target(target_name)
  require_relative "target"
  require_relative "target/#{target_name}"
  Target.const_get(target_name.capitalize)
end

.create(file_or_directory, source_name, target_name, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/gpm/packaging_task.rb', line 15

def self.create(file_or_directory, source_name, target_name, options = {})
  options[:work_dir] ||= Dir.mktmpdir
  source_class = class_for_source(source_name)
  source = source_class::Factory.new(file_or_directory, options).create

  target_class = class_for_target(target_name)
  target = target_class.new(options[:work_dir], options)
  new(source,target)
end

Instance Method Details

#runObject



30
31
32
# File 'lib/gpm/packaging_task.rb', line 30

def run
  @target.create_package(@source)
end