Module: Earth::Loader
- Defined in:
- lib/earth/loader.rb
Class Method Summary collapse
- .load_plugins ⇒ Object
- .require_all(options = {}) ⇒ Object
- .require_domain(domain, options = {}) ⇒ Object
- .require_glob(glob, options = {}) ⇒ Object
- .require_related(path) ⇒ Object
Class Method Details
.load_plugins ⇒ Object
40 41 42 43 44 45 |
# File 'lib/earth/loader.rb', line 40 def Loader.load_plugins Dir[File.('../../../vendor/**/init.rb', __FILE__)].each do |pluginit| $LOAD_PATH.unshift ::File.join(::File.dirname(pluginit), 'lib') Kernel.load pluginit end end |
.require_all(options = {}) ⇒ Object
12 13 14 |
# File 'lib/earth/loader.rb', line 12 def Loader.require_all( = {}) require_glob ::File.join(LIB_DIR, '**', '*.rb'), end |
.require_domain(domain, options = {}) ⇒ Object
16 17 18 |
# File 'lib/earth/loader.rb', line 16 def Loader.require_domain(domain, = {}) require_glob ::File.join(LIB_DIR, domain.to_s, '**', '*.rb'), end |
.require_glob(glob, options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/earth/loader.rb', line 20 def Loader.require_glob(glob, = {}) @require_glob ||= [] args = [glob, ] return if @require_glob.include?(args) @require_glob << args data_miner_paths = [] ::Dir[glob].each do |path| if path.include?('data_miner') data_miner_paths << path else require path end end # load data_miner blocks second to make sure they override data_miner_paths.each do |path| require path end if [:load_data_miner] || [:mine_original_sources] nil end |
.require_related(path) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/earth/loader.rb', line 5 def Loader.(path) path = ::File. path raise ::ArgumentError, %{[earth gem] #{path} is not in #{LIB_DIR}} unless path.start_with?(LIB_DIR) domain = %r{#{LIB_DIR}/([^\./]+)}.match(path).captures.first require_domain domain, :mine_original_sources => path.include?('data_miner') end |