class Manifest

Scans a specified source tree for ActionScript and MXML files and for each one found creates a manifest entry. When complete writes the resulting manfiest file to disk.

Attributes

components[R]
xml[R]

Public Class Methods

new(opt,out=STDOUT) click to toggle source
Calls superclass method Tool::new
# File lib/shed/manifest.rb, line 12
def initialize(opt,out=STDOUT)
  super(opt,out)

  @filetypes = /\.(as|mxml|fxg)$/
  @filter = opt[:filter] || ''

  build
end

Public Instance Methods

add(path, id) click to toggle source

Generates a hash containing id and xml vales. The xml can be to be inserted into the manifest for the specified class.

# File lib/shed/manifest.rb, line 25
def add(path, id)
  log("Adding '#{path}'")

  cp = ProjectTools.import(path)

  { :key => id, :xml => "<component id=\"#{id}\" class=\"#{cp}\" />" }
end
build() click to toggle source

Build the manifest file and save it to disk.

# File lib/shed/manifest.rb, line 67
def build
  @components = scan(@src)

  if @components.empty?
    puts "No ActionScript, MXML or FXG files found."
  else
    create_xml(@components)

    #Open/Create the manifest file and write the output to it.
    to_disk(xml)
  end
end
create_xml(comps) click to toggle source

Constructs the flex complier config file when given a list of paths to asdoc files.

# File lib/shed/manifest.rb, line 84
def create_xml(comps)
  @xml = "<?xml version='1.0'?>\n<componentPackage>\n"
  comps.each { |component| @xml << "\t#{component[:xml]}\n" }
  @xml << "</componentPackage>"
end
process(list) click to toggle source

Proccesses the list to remove duplicates, sort alphabetically and reject any items that do not match the filter.

# File lib/shed/manifest.rb, line 58
def process(list)
  list.uniq!
  list.sort! { |before,after| before[:xml] <=> after[:xml] }
  list.select { |element| element[:xml].match(@filter) }
end
scan(dir) click to toggle source

Search the provided path for as and mxml documents and return those found as a list.

# File lib/shed/manifest.rb, line 37
def scan(dir)
  puts "Scanning '#{dir}' for as and mxml files..."

  found = []

  Search.find_all(@filetypes,dir,@excludes) do |path|
    ext = File.extname(path)
    name = File.basename(path, ext)

    found << add(path, name)
  end

  found = process(found) unless found.empty?

  found
end