Module: WarpDrive
- Extended by:
- WarpDrive
- Included in:
- WarpDrive
- Defined in:
- lib/warp_drive/path.rb,
lib/warp_drive/configure.rb,
lib/warp_drive/boot/procs.rb,
lib/warp_drive/boot/workers.rb,
lib/warp_drive/boot/method_list.rb
Defined Under Namespace
Constant Summary collapse
- RAILS_INIT_METHODS =
%w{ install_gem_spec_stubs set_load_path require_frameworks set_autoload_paths add_plugin_load_paths load_environment preload_frameworks initialize_encoding initialize_database initialize_cache initialize_framework_caches initialize_logger initialize_framework_logging initialize_dependency_mechanism initialize_whiny_nils initialize_time_zone initialize_i18n initialize_framework_settings initialize_framework_views initialize_metal add_support_load_paths check_for_unbuilt_gems load_plugins add_gem_load_paths load_gems check_gem_dependencies gems_dependencies_loaded load_application_initializers after_initialize initialize_database_middleware prepare_dispatcher initialize_routing load_observers load_view_paths load_application_classes disable_dependency_loading }
Class Method Summary collapse
-
.configure {|configatron.warp_drive| ... } ⇒ Object
Use this method in your Rakefile to configure the resulting Warp Drive gem.
Instance Method Summary collapse
-
#initialize_database ⇒ Object
:nodoc:.
-
#initialize_database_middleware ⇒ Object
:nodoc:.
-
#initialize_dependency_mechanism ⇒ Object
:nodoc:.
-
#initialize_routing ⇒ Object
:nodoc:.
-
#load_application_initializers ⇒ Object
:nodoc:.
-
#load_assets ⇒ Object
:nodoc:.
-
#load_gems ⇒ Object
:nodoc:.
-
#load_plugins ⇒ Object
— RAILS — #.
-
#load_rake_tasks ⇒ Object
— Non-RAILS — #.
-
#load_view_paths ⇒ Object
:nodoc:.
-
#method_missing(sym, *args) ⇒ Object
:nodoc:.
-
#set_load_path ⇒ Object
:nodoc:.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
:nodoc:
118 119 120 |
# File 'lib/warp_drive/boot/workers.rb', line 118 def method_missing(sym, *args) # :nodoc: # puts "Tried to call WarpDrive.#{sym} but it doesn't exist!" end |
Class Method Details
.configure {|configatron.warp_drive| ... } ⇒ Object
Use this method in your Rakefile to configure the resulting Warp Drive gem.
Example:
WarpDrive.configure do |config|
# Define your gem spec settings here:
config.gem.version = "1.2.3"
config.gem.email = '[email protected]'
config.gem.homepage = 'http://www.example.com'
# Add your gem dependencies here:
config.dependencies = {'warp_drive' => '>=0.1.0'}
end
18 19 20 |
# File 'lib/warp_drive/configure.rb', line 18 def configure yield configatron.warp_drive end |
Instance Method Details
#initialize_database ⇒ Object
:nodoc:
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/warp_drive/boot/workers.rb', line 60 def initialize_database # :nodoc: Rails.configuration.instance_eval do def database_configuration # :nodoc: require 'erb' db_opts = {} [WarpDrive::Path.config.database.yml.to_s, File.join(RAILS_ROOT, 'config', 'database.yml')].each do |yml_path| if File.exists?(yml_path) opts = YAML::load(ERB.new(File.read(yml_path)).result) db_opts.recursive_merge!(opts) if opts end end db_opts end # database_configuration end # Rails.configuration.instance_eval end |
#initialize_database_middleware ⇒ Object
:nodoc:
86 87 88 |
# File 'lib/warp_drive/boot/workers.rb', line 86 def initialize_database_middleware # :nodoc: require File.join(File.dirname(__FILE__), 'migration_override') end |
#initialize_dependency_mechanism ⇒ Object
:nodoc:
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/warp_drive/boot/workers.rb', line 44 def initialize_dependency_mechanism # :nodoc: ActiveSupport::Dependencies.class_eval do class << self alias_method :require_or_load_without_warp_drive, :require_or_load def require_or_load_with_warp_drive(file_name, const_path = nil) # :nodoc: sr_file_name = file_name.gsub(RAILS_ROOT, WarpDrive::ROOT) require_or_load_without_warp_drive(sr_file_name, const_path) if File.exists?(sr_file_name) require_or_load_without_warp_drive(file_name, const_path) end alias_method :require_or_load, :require_or_load_with_warp_drive end end end |
#initialize_routing ⇒ Object
:nodoc:
34 35 36 |
# File 'lib/warp_drive/boot/workers.rb', line 34 def initialize_routing # :nodoc: ActionController::Routing::Routes.add_configuration_file(WarpDrive::Path.config.routes.rb.to_s) end |
#load_application_initializers ⇒ Object
:nodoc:
79 80 81 82 83 84 |
# File 'lib/warp_drive/boot/workers.rb', line 79 def load_application_initializers # :nodoc: Dir[File.join(WarpDrive::Path.config.initializers.to_s, '**', '*.rb')].sort.each do |initializer| initializer = File.(initializer) load(initializer) end end |
#load_assets ⇒ Object
:nodoc:
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/warp_drive/boot/workers.rb', line 104 def load_assets # :nodoc: Dir.glob(File.join(WarpDrive::ROOT, 'public', '**', 'warp_drive', '**', '*.*')).sort.each do |f| f.match(/public\/(.*warp_drive)/) base_path = $1 rails_path = File.join(RAILS_ROOT, 'public', base_path) FileUtils.rm_rf(rails_path, :verbose => false) if File.exists?(rails_path) f.match(/(^.+public\/.*warp_drive)/) begin FileUtils.ln_sf($1, rails_path) rescue Exception => e end end end |
#load_gems ⇒ Object
:nodoc:
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/warp_drive/boot/workers.rb', line 17 def load_gems # :nodoc: begin require('gemtronics') sr_gem_path = WarpDrive::Path.config.gemtronics.rb Gemtronics.load(sr_gem_path) if File.exists?(sr_gem_path) local_path = File.join(RAILS_ROOT, 'config', 'gemtronics.rb') Gemtronics.load(local_path) if File.exists?(local_path) Gemtronics.require_gems(RAILS_ENV, :verbose => false) rescue Exception => e puts "Problems loading Gemtronics: #{e.}" puts "This probably means you aren't using Gemtronics." end end |
#load_plugins ⇒ Object
— RAILS — #
4 5 6 |
# File 'lib/warp_drive/boot/workers.rb', line 4 def load_plugins # :nodoc: Rails.configuration.plugin_paths << WarpDrive::Path.vendor.plugins.to_s end |
#load_rake_tasks ⇒ Object
— Non-RAILS — #
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/warp_drive/boot/workers.rb', line 92 def load_rake_tasks # :nodoc: require 'rake' Dir.glob(File.join(WarpDrive::Path.lib.tasks.to_s, '**', '*.*')).sort.each do |task| load File.(task) unless task.match(/\/private\//) end Dir.glob(File.join(WarpDrive::Path.vendor.plugins.to_s, '*')).sort.each do |plugin| Dir.glob(File.join(plugin, 'tasks', '**', '*.*')).sort.each do |task| load File.(task) unless task.match(/\/private\//) end end end |
#load_view_paths ⇒ Object
:nodoc:
38 39 40 41 42 |
# File 'lib/warp_drive/boot/workers.rb', line 38 def load_view_paths # :nodoc: ActionController::Base.view_paths = [ActionController::Base.view_paths, WarpDrive::Path.app.views.to_s].flatten ActionMailer::Base.view_paths = ActionController::Base.view_paths end |
#set_load_path ⇒ Object
:nodoc:
8 9 10 11 12 13 14 15 |
# File 'lib/warp_drive/boot/workers.rb', line 8 def set_load_path # :nodoc: Rails.configuration.load_paths = [Rails.configuration.load_paths, WarpDrive::Path.lib.to_s, WarpDrive::Path.app.to_s, WarpDrive::Path.app.models.to_s, WarpDrive::Path.app.controllers.to_s, WarpDrive::Path.app.helpers.to_s].flatten end |