Sha256: e5ec867b1dfed085e78b48225bdcba3210e7756374cada85e8e656877ff648e9

Contents?: true

Size: 1.75 KB

Versions: 1

Compression:

Stored size: 1.75 KB

Contents

Alki do
  func :reload do
    root.assembly_instance.__reload__
  end

  set :enable, false

  set :main_loops do
    enable
  end

  set :watch do
    enable
  end

  set :dirs do
    ['lib']
  end

  set :whitelist do
    []
  end

  set :watch_dirs do
    handlers.inject([]) do |dirs,h|
      dirs.push *h.dirs
    end
  end

  reference_overlay '%main_loop', :reloadable_reference

  factory :reloadable_reference do
    require 'alki/reload/reloadable_delegator'
    -> (ref) {
      if main_loops
        Alki::Reload::ReloadableDelegator.new(root.assembly_instance,ref)
      else
        ref.call
      end
    }
  end

  service :handlers do
    [loader_handler,load_path_handler]
  end

  service :loader_handler do
    require 'alki/reload/loader_handler'
    Alki::Reload::LoaderHandler.new root_dir
  end

  service :load_path_handler do
    require 'alki/reload/load_path_handler'
    Alki::Reload::LoadPathHandler.new root_dir, dirs
  end

  factory :on_reload do
    -> obj, method {
      reloader.hooks << obj.method(method)
      obj
    }
  end

  service :reloader do
    require 'alki/reload/reloader'
    Alki::Reload::Reloader.new unloader
  end

  service :unloader do
    require 'alki/reload/unloader'
    Alki::Reload::Unloader.new handlers, whitelist
  end

  service :watcher do
    require 'alki/reload/listen_watcher'
    Alki::Reload::ListenWatcher.new assembly, watch_dirs
  end

  overlay :watcher, :on_reload, :stop!

  overlay 'root.assembly_instance', :assembly_delegator

  factory :assembly_delegator do
    require 'alki/reload/assembly_delegator'
    if watch
      self.watcher.start!
    end
    -> obj {
      Alki::Reload::AssemblyDelegator.new obj, reloader
    }
  end

  set :root_dir do
    File.expand_path('..',parent.config_dir)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alki-reload-0.2.0 config/assembly.rb