# File lib/desert/manager.rb, line 4 def instance @instance ||= new end
# File lib/desert/manager.rb, line 17 def initialize @plugins = [] @plugins_in_registration = [] end
# File lib/desert/manager.rb, line 10 def method_missing(method_name, *args, &block) instance.__send__(method_name, *args, &block) end
# File lib/desert/manager.rb, line 111 def all_files Desert::Manager.load_paths.inject([]) do |all, load_path| all |= Dir["#{load_path}/**/*.rb"] all end end
# File lib/desert/manager.rb, line 91 def directory_on_load_path?(dir_suffix) Desert::Manager.load_paths.each do |path| return true if File.directory?(File.join(path, dir_suffix)) end return false end
# File lib/desert/manager.rb, line 80 def files_on_load_path(file) desert_file_exists = false files = [] load_paths.each do |path| full_path = File.join(path, file) full_path << '.rb' unless File.extname(full_path) == '.rb' files << full_path if File.exists?(full_path) end files end
# File lib/desert/manager.rb, line 63 def find_plugin(name_or_directory) name = File.basename(File.expand_path(name_or_directory)) plugins.find do |plugin| plugin.name == name end end
# File lib/desert/manager.rb, line 98 def layout_paths layout_paths = plugins.reverse.collect do |plugin| plugin.layouts_path end layout_paths end
# File lib/desert/manager.rb, line 26 def load_paths paths = [] plugin_paths.each do |component_root| paths << File.join(component_root, 'app') paths << File.join(component_root, 'app','models') paths << File.join(component_root, 'app','controllers') paths << File.join(component_root, 'app','helpers') paths << File.join(component_root, 'app','sweepers') paths << File.join(component_root, 'lib') end dependencies.load_paths.reverse_each do |path| paths << File.expand_path(path) end paths.uniq! paths end
# File lib/desert/manager.rb, line 70 def plugin_exists?(name_or_directory) !find_plugin(name_or_directory).nil? end
# File lib/desert/manager.rb, line 74 def plugin_path(name) plugin = find_plugin(name) return nil unless plugin plugin.path end
# File lib/desert/manager.rb, line 22 def plugins @plugins.dup end
# File lib/desert/manager.rb, line 43 def register_plugin(plugin_path) plugin = Plugin.new(plugin_path) @plugins_in_registration << plugin yield if block_given? dependencies.load_paths << plugin.models_path dependencies.load_paths << plugin.controllers_path dependencies.load_paths << plugin.helpers_path @plugins_in_registration.pop if existing_plugin = find_plugin(plugin.name) return existing_plugin end @plugins << plugin plugin end
# File lib/desert/manager.rb, line 105 def require_all_files all_files.each do |file| require file end end
# File lib/desert/manager.rb, line 119 def dependencies @dependencies ||= ActiveSupport.const_defined?(:Dependencies) ? ActiveSupport::Dependencies : Dependencies end
# File lib/desert/manager.rb, line 123 def plugin_paths plugins_and_app.collect { |plugin| plugin.path } end
# File lib/desert/manager.rb, line 127 def plugins_and_app plugins + @plugins_in_registration + [Plugin.new(RAILS_ROOT)] end