Class: PackagingTask
Class Method Summary collapse
- .class_for_source(source_name) ⇒ Object
- .class_for_target(target_name) ⇒ Object
- .create(file_or_directory, source_name, target_name, options = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(source, target) ⇒ PackagingTask
constructor
A new instance of PackagingTask.
- #run ⇒ Object
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, = {}) [:work_dir] ||= Dir.mktmpdir source_class = class_for_source(source_name) source = source_class::Factory.new(file_or_directory, ).create target_class = class_for_target(target_name) target = target_class.new([:work_dir], ) new(source,target) end |
Instance Method Details
#run ⇒ Object
30 31 32 |
# File 'lib/gpm/packaging_task.rb', line 30 def run @target.create_package(@source) end |