Class: BuildrIzPack::Pack
- Inherits:
-
Object
- Object
- BuildrIzPack::Pack
- Defined in:
- lib/buildrizpack/package.rb
Overview
A simple helper class to create a single pack
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Attributes of the pack.
-
#defaultPath ⇒ Object
readonly
The path to be used by the IzPack-installer for this pack.
-
#description ⇒ Object
readonly
A more elaborate description of the pack.
-
#files ⇒ Object
readonly
A hast of the files to be packed (src => installpath).
Instance Method Summary collapse
-
#addFile(src, dest = nil) ⇒ Object
Add a single file to the pack.
-
#emitIzPackXML(xm) ⇒ Object
collect the XML representation for the pack using an XMLMarkup object.
-
#initialize(name, description, attributes = {}, defaultPath = '$INSTALL_PATH/plugins') ⇒ Pack
constructor
Initialize an IzPack-Pack by name, description.
Constructor Details
#initialize(name, description, attributes = {}, defaultPath = '$INSTALL_PATH/plugins') ⇒ Pack
Initialize an IzPack-Pack by name, description. :attributes: Attributes of the pack, a Hash, eg. { ‘required’ => ‘yes’ }
36 37 38 39 40 41 42 43 |
# File 'lib/buildrizpack/package.rb', line 36 def initialize(name, description, attributes = {}, defaultPath = '$INSTALL_PATH/plugins') @description = description @attributes = attributes @attributes['name'] = name @files = Hash.new @defaultPath = defaultPath @attributes['required'] = 'no' if !@attributes['required'] end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Attributes of the pack. a hash of name => value, eg. ‘require’ => ‘yes’
33 34 35 |
# File 'lib/buildrizpack/package.rb', line 33 def attributes @attributes end |
#defaultPath ⇒ Object (readonly)
The path to be used by the IzPack-installer for this pack. Defaults to
27 28 29 |
# File 'lib/buildrizpack/package.rb', line 27 def defaultPath @defaultPath end |
#description ⇒ Object (readonly)
A more elaborate description of the pack
31 32 33 |
# File 'lib/buildrizpack/package.rb', line 31 def description @description end |
#files ⇒ Object (readonly)
A hast of the files to be packed (src => installpath)
29 30 31 |
# File 'lib/buildrizpack/package.rb', line 29 def files @files end |
Instance Method Details
#addFile(src, dest = nil) ⇒ Object
Add a single file to the pack
46 47 48 49 50 |
# File 'lib/buildrizpack/package.rb', line 46 def addFile(src, dest=nil) orig = dest dest = File.join(@defaultPath, File.basename(src)) if !dest @files[src] = dest end |
#emitIzPackXML(xm) ⇒ Object
collect the XML representation for the pack using an XMLMarkup object
53 54 55 56 57 58 59 |
# File 'lib/buildrizpack/package.rb', line 53 def emitIzPackXML(xm) # raise "xm must be an Builder::XmlMarkup object, but is #{xm.class}" if xm.class != Builder::XmlMarkup xm.pack(@attributes) { xm.description(@description) @files.each{ |src, dest| xm.singlefile('src'=> src, 'target' =>dest) } } end |