class Alki::Loader::Registry
Public Class Methods
new()
click to toggle source
# File lib/alki/loader/registry.rb, line 6 def initialize @lock = Monitor.new clear end
Public Instance Methods
add(entry)
click to toggle source
# File lib/alki/loader/registry.rb, line 24 def add(entry) @lock.synchronize do @paths.delete_if{|e| e.path == entry.path } @paths << entry @names.sort!{|a,b| b.path <=> a.path} if entry.name @names.delete_if{|e| e.name == entry.name } @names << entry @names.sort!{|a,b| b.name <=> a.name} end end end
clear()
click to toggle source
# File lib/alki/loader/registry.rb, line 11 def clear @lock.synchronize do @paths = [] @names = [] @configs_loaded = false end end
load_alki_loader_files()
click to toggle source
# File lib/alki/loader/registry.rb, line 62 def load_alki_loader_files Gem.find_latest_files('alki_loader.rb').each do |config_path| require config_path end end
load_configs!()
click to toggle source
# File lib/alki/loader/registry.rb, line 53 def load_configs! @lock.synchronize do path_hash = $LOAD_PATH.hash return if @configs_loaded == path_hash @configs_loaded = path_hash load_alki_loader_files end end
lookup_name(name)
click to toggle source
# File lib/alki/loader/registry.rb, line 37 def lookup_name(name) load_configs! @names.find do |e| name.start_with?(e.name) && (name.size == e.name.size || name[e.name.size] == '/') end end
lookup_path(path)
click to toggle source
# File lib/alki/loader/registry.rb, line 45 def lookup_path(path) load_configs! @paths.find do |e| path.start_with?(e.path) && (path.size == e.path.size || path[e.path.size] == '/') end end
paths()
click to toggle source
# File lib/alki/loader/registry.rb, line 19 def paths load_configs! @paths.map{|e| e.path } end