Class: Laze::Target
- Inherits:
-
Object
- Object
- Laze::Target
- Defined in:
- lib/laze/target.rb
Constant Summary collapse
- TargetException =
Generic exception to be raised for store-specific exceptions.
Class.new(Exception)
- FileSystemException =
Exception for when interacting with the filesystem goes bad.
Class.new(TargetException)
Instance Attribute Summary collapse
-
#output_dir ⇒ Object
readonly
The base directory to create all the files in.
Class Method Summary collapse
-
.find(kind) ⇒ Object
Find a target deployment engine by name and return its class.
-
.inherited(child) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#create(item) ⇒ Object
Given an item this will create the output file in the right output location.
-
#initialize(output_dir) ⇒ Target
constructor
:nodoc:.
-
#reset ⇒ Object
Empty the current output directory.
-
#save ⇒ Object
Finalize the generation and process any after hooks.
Constructor Details
Instance Attribute Details
#output_dir ⇒ Object (readonly)
The base directory to create all the files in. This is relative the location where laze is run from.
14 15 16 |
# File 'lib/laze/target.rb', line 14 def output_dir @output_dir end |
Class Method Details
.find(kind) ⇒ Object
Find a target deployment engine by name and return its class.
When loading Laze::Targets::Filesystem
you would call:
Target.find(:filesystem)
22 23 24 25 26 |
# File 'lib/laze/target.rb', line 22 def self.find(kind) targets = @targets.select { |s| s.name.to_s.split('::').last.downcase.to_sym == kind } raise TargetException, 'No such target.' unless targets.any? targets.first end |
.inherited(child) ⇒ Object
:nodoc:
28 29 30 |
# File 'lib/laze/target.rb', line 28 def self.inherited(child) #:nodoc: @targets << child end |
Instance Method Details
#create(item) ⇒ Object
Given an item this will create the output file in the right output location.
45 46 47 |
# File 'lib/laze/target.rb', line 45 def create(item) raise 'This is a generic target. Please use a subclass.' end |
#reset ⇒ Object
Empty the current output directory
50 51 52 53 54 |
# File 'lib/laze/target.rb', line 50 def reset FileUtils.rm_rf(output_dir) if File.directory?(output_dir) FileUtils.mkdir(output_dir) unless File.directory?(output_dir) Laze.debug "Emptied output directory #{output_dir}" end |
#save ⇒ Object
Finalize the generation and process any after hooks.
39 40 41 |
# File 'lib/laze/target.rb', line 39 def save raise 'This is a generic target. Please use a subclass.' end |