Class: Spider::App::RuntimeSort

Inherits:
Object
  • Object
show all
Includes:
TSort
Defined in:
lib/spiderfw/app.rb

Instance Method Summary collapse

Constructor Details

#initializeRuntimeSort

Returns a new instance of RuntimeSort.



348
349
350
351
# File 'lib/spiderfw/app.rb', line 348

def initialize
    @apps = []
    @apps_hash = {}
end

Instance Method Details

#add(app) ⇒ Object



353
354
355
356
357
358
359
360
# File 'lib/spiderfw/app.rb', line 353

def add(app)
    @apps << app
    if app.is_a?(AppSpec)
        @apps_hash[app.app_id] = app
    else
        @apps_hash[app] = app
    end
end

#tsortObject



371
372
373
374
# File 'lib/spiderfw/app.rb', line 371

def tsort
    sorted = super
    sorted.map{ |a| a.is_a?(AppSpec) ? a.app_id : a }
end

#tsort_each_child(node, &block) ⇒ Object



366
367
368
369
# File 'lib/spiderfw/app.rb', line 366

def tsort_each_child(node, &block)
    return unless node.is_a?(AppSpec)
    node.load_after.map{ |a| @apps_hash[a] }.each(&block)
end

#tsort_each_node(&block) ⇒ Object



362
363
364
# File 'lib/spiderfw/app.rb', line 362

def tsort_each_node(&block)
    @apps.each(&block)
end