class Prepare

Public Class Methods

new(file) click to toggle source
# File lib/aml/Prepare.rb, line 3
def initialize(file)
        @log = []
        @cluster = false
        @file = []
        @watch = []
        # Load Core Bundle
        path = File.join(File.dirname(File.expand_path(__FILE__)),'core')
        add_file(File.join(path,'mixin.aml'),'mixin', 'core')
        add_watch(File.join(path,'method.rb'), 'method', 'core')
        # Load Local Bundles
        bundles = Definition.new(file, false)
        bundles.self[:hash].reject{|k|k[:bundle] == false or k[:bundle] == nil}.each do |bundle|
                if @file.select{|k|k[:bundle] == bundle[:bundle]}.count == 0
                        path = File.join(File.dirname(file), bundle[:bundle])
                        add_file(File.join(path,'mixin.aml'), 'mixin', bundle[:bundle])
                        add_watch(File.join(path,'method.rb'), 'method', bundle[:bundle])
                        # Load Only Required Partials
                        bundles.self[:hash].reject{|k|k[:bundle] != bundle[:bundle]}.reject{|k|k[:type] != :partial}.each do |partial|
                                add_file(File.join(path,'partial',partial[:name]+'.aml'), 'partial', bundle[:bundle], bundle[:name])
                        end
                end
        end
        # Load Local File Mixin & Method
        path =  File.join(File.dirname(file))
        add_file(File.join(path,'mixin.aml'), 'mixin')
        add_watch(File.join(path,'method.rb'), 'method')
        # Load Only Requird Local Partials
        bundles.self[:hash].select{|k|k[:type] == :partial and k[:bundle] == false}.each do |bundle|
                add_file(File.join(path,'partial',bundle[:name]+'.aml'), 'partial', bundle[:bundle], bundle[:name])
        end
        # Load Local File
        add_file(file,'base')
        @watch.concat(@file)
        process
end

Public Instance Methods

add_file(file, type, bundle=false, partial=false) click to toggle source
# File lib/aml/Prepare.rb, line 38
def add_file(file, type, bundle=false, partial=false)
        @file << {:file=>file, :type=> type, :bundle=>bundle, :partial=>partial}
end
add_watch(file, type, bundle=false) click to toggle source
# File lib/aml/Prepare.rb, line 41
def add_watch(file, type, bundle=false)
        @watch << {:file=>file, :bundle=>bundle}
end
cluster() click to toggle source
# File lib/aml/Prepare.rb, line 52
def cluster
        @cluster
end
log() click to toggle source
# File lib/aml/Prepare.rb, line 49
def log
        @log
end
process() click to toggle source
# File lib/aml/Prepare.rb, line 44
def process
        @cluster = Cluster.new(@file)
        @cluster.process
        @log = cluster.log
end
watch() click to toggle source
# File lib/aml/Prepare.rb, line 55
def watch
        @watch
end