Module TLoad
In: lib/loader_helper.rb

Some helpers for the Talia bootstrapping (when the module is loaded)

Methods

Public Class methods

Forces the loading of the parts of the rails framework that are used by Talia

[Source]

    # File lib/loader_helper.rb, line 39
39:   def self.force_rails_parts
40:     require_module("activerecord", "active_record", "/../../../rails/activerecord", RAILS_GEM_VERSION) unless(defined?(ActiveRecord))
41:     require_module("activesupport", "active_support", "/../../../rails/activesupport", RAILS_GEM_VERSION) unless(defined?(ActiveSupport))
42:     require_module("actionpack", "action_controller", "/../../../rails/actionpack", RAILS_GEM_VERSION)
43:     # This sets the automatic loader path for Talia, allowing the ActiveSupport
44:     # classes to automatically load classes from this directory.
45:     load_paths = ActiveSupport::Dependencies.load_paths
46:     load_paths << TLoad.start_dir unless(load_paths.include?(TLoad.start_dir))
47:     # Add the other plugins to the path, if we have a Rails root
48:     if(defined?(RAILS_ROOT))
49:       Dir["#{RAILS_ROOT}/vendor/plugins/*/lib"].each do |plugin_dir|
50:         load_paths << plugin_dir if(File.directory?(plugin_dir) || !load_paths.include?(plugin_dir))
51:       end
52:     end
53:   end

This tries to load the the given module. It first attempts to load from local_path/lib/local_name The local path is always appended to the directory of the script currently running. If that fails, it tries to load the given gem

[Source]

    # File lib/loader_helper.rb, line 11
11:   def self.require_module(gem_name, local_name, local_path, gem_version = nil)
12:     begin
13:       # Try to loaTad from local if it exists
14:       search_dir = File.expand_path(File.join(File.dirname(__FILE__), local_path, "lib"))
15:       if(File.exists?(search_dir))
16:         $:.unshift(search_dir)  
17:         require local_name  
18:       else
19:         load_from_gem(gem_name, local_name, gem_version)
20:       end
21:     rescue LoadError
22:       load_from_gem(gem_name, local_name, gem_version)
23:     end
24:   end

Sets up the ActiveSupport autoload path

[Source]

    # File lib/loader_helper.rb, line 56
56:   def self.setup_load_path
57:     # set up the load path to talia
58:     root_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
59:     Kernel.const_set(:TALIA_CODE_ROOT, root_dir) unless(defined?(TALIA_CODE_ROOT))
60:     lib_dir = File.join(root_dir, 'lib')
61:     ActiveSupport::Dependencies.load_paths << lib_dir unless(ActiveSupport::Dependencies.load_paths.include?(lib_dir))
62:   end

[Source]

    # File lib/loader_helper.rb, line 26
26:   def self.start_dir
27:     @start_dir ||= begin
28:       # adding talia_core subdirectory to the ruby loadpath  
29:       file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
30:       this_dir = File.dirname(File.expand_path(file))
31:       $: << this_dir
32:       $: << this_dir + '/talia_core/'
33:       this_dir
34:     end
35:   end

[Validate]