module Kernel
Public Class Methods
computed_dependencies(acc = [], graph = $FILES_TO_TYPECHECK)
click to toggle source
# File lib/typed.rb, line 83 def self.computed_dependencies(acc = [], graph = $FILES_TO_TYPECHECK) graph.each do |(file, deps)| acc = computed_dependencies(acc, deps) if deps != {} acc << file end acc end
reset_dependencies()
click to toggle source
# File lib/typed.rb, line 71 def self.reset_dependencies $FILES_TO_TYPECHECK = {} $CURRENT_DEPS = $FILES_TO_TYPECHECK $LOADED_MAP = {} end
with_dependency_tracking() { || ... }
click to toggle source
# File lib/typed.rb, line 77 def self.with_dependency_tracking $LOAD_TO_TYPECHECK = true yield $LOAD_TO_TYPECHECK = false end
Public Instance Methods
load(name, wrap = false)
click to toggle source
# File lib/typed.rb, line 15 def load(name, wrap = false) if $LOAD_TO_TYPECHECK return if $LOADED_MAP[name] to_load = if File.exist?(name) File.absolute_path(name) else dir = $LOAD_PATH.detect do |d| File.exist?(File.join(d, name)) end return if dir.nil? File.absolute_path(File.join(dir, name)) end if $LOADED_MAP[to_load].nil? #puts "** LOADING #{to_load}" process_dependency(to_load) { old_load(name, wrap) } else old_load(name, wrap) end else old_load(name, wrap) end end
Also aliased as: old_load
process_dependency(to_load) { |to_load| ... }
click to toggle source
# File lib/typed.rb, line 91 def process_dependency(to_load) $LOADED_MAP[to_load] = true $CURRENT_DEPS[to_load] = {} old_current_deps = $CURRENT_DEPS $CURRENT_DEPS = $CURRENT_DEPS[to_load] yield to_load $CURRENT_DEPS = old_current_deps end
require(name)
click to toggle source
# File lib/typed.rb, line 38 def require(name) if $LOAD_TO_TYPECHECK dependency = ["#{name}.rb", name].detect { |f| File.exist?(f) } if dependency.nil? # system dependency old_require(name) else to_load = File.absolute_path(dependency) if $LOADED_MAP[to_load].nil? # puts "** REQUIRING #{to_load}" process_dependency(to_load) { old_require(name) } else old_require(name) end end else old_require(name) end end
Also aliased as: old_require
require_relative(name)
click to toggle source
# File lib/typed.rb, line 58 def require_relative(name) dirs = caller.map do |call| file = call.split(':').first File.dirname(file) end.uniq found = dirs.map do |dir| File.join(dir, name) end.detect do |potential_file| (File.exist?(potential_file + '.rb') || File.exist?(potential_file + '.rb')) end require(found) end
Also aliased as: old_require_relative