Class: BuildrIzPack::Pack

Inherits:
Object
  • Object
show all
Defined in:
lib/buildrizpack/package.rb

Overview

A simple helper class to create a single pack

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributesObject (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

#defaultPathObject (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

#descriptionObject (readonly)

A more elaborate description of the pack



31
32
33
# File 'lib/buildrizpack/package.rb', line 31

def description
  @description
end

#filesObject (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