Top Level Namespace
Defined Under Namespace
Modules: CoreEx, Dependencies, Enumerable, FileUtils, TempPath, TempPathname, Test, YAML, YamlExtension
Classes: Array, DTime, DumpableProc, Exception, Hash, Module, Numeric, Object, PathList, Pathname, Proc, Range, Regexp, String, Time, Version
Constant Summary
collapse
- CORE_EX_LOADED =
true
- CORE_EX_DIR =
Pathname.new(__FILE__).dirname.expand_path.cleanpath
Instance Method Summary
collapse
Instance Method Details
#core_ex_debug(&block) ⇒ Object
42
43
44
|
# File 'lib/core_ex.rb', line 42
def core_ex_debug &block
STDERR.puts block[].inspect
end
|
#core_ex_register_vendor(dir) ⇒ Object
70
71
72
|
# File 'lib/core_ex.rb', line 70
def core_ex_register_vendor ( dir )
$CORE_EX_VENDORS << dir unless $CORE_EX_VENDORS.include? dir
end
|
#core_ex_require(name, opts = nil) ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/core_ex.rb', line 95
def core_ex_require name, opts=nil
core_ex_debug { [:core_ex_require, name, opts] }
opts ||= {}
begin
core_ex_vendor_require(opts[:dir_name] || name,
opts[:sub_dir] || 'lib')
rescue LoadError => ex
begin
core_ex_gem_require(opts[:gem_name] || name, opts[:gem_version])
rescue LoadError
end
end
core_ex_debug { [:require, name] }
unless require name
core_ex_debug { [:require, name, :has_returned_false] }
end
end
|
#core_ex_vendor_require(dir_name, sub_dir = 'lib') ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/core_ex.rb', line 50
def core_ex_vendor_require ( dir_name, sub_dir='lib' )
if $CORE_EX_VENDORS.any? { |dir| dir.exist? }
dir = Pathname.glob("{#{$CORE_EX_VENDORS.join(',')}}/#{dir_name}/{#{sub_dir},}").first
if dir and dir.directory?
if defined? CoreEx::Pathname and Pathname.include? CoreEx::Pathname
dir.load_path!
else
$LOAD_PATH << dir.to_s
end
core_ex_debug { [:vendor, dir_name, sub_dir] }
else
core_ex_debug { [:novendor, dir] }
raise LoadError, "no vendor dir #{dir}"
end
else
core_ex_debug { [:novendor, $CORE_EX_VENDORS] }
raise LoadError, "no valid vendor dir among #{$CORE_EX_VENDORS.inspect}"
end
end
|