class Redoxed::Manager

Attributes

hook[R]
input[R]
model[R]
output[R]
source[R]

Public Class Methods

load(dir, file) click to toggle source
# File lib/redoxed/manager.rb, line 8
def load(dir, file)
  require File.join dir, file + '.rb'
  klass = nil
  [Redoxed, Object].each do |mod|
    klass   = mod.constants.find { |const| const.to_s.casecmp(file).zero? }
    klass ||= mod.constants.find { |const| const.to_s.downcase == 'redoxed' + file.downcase }
    klass   = mod.const_get klass if klass
    break if klass
  end
  i = klass.new
  i.setup if i.respond_to? :setup
  { file => klass }
rescue LoadError
  false
end
new() click to toggle source
# File lib/redoxed/manager.rb, line 26
def initialize
  @input  = {}
  @output = {}
  @source = {}
  @model  = {}
  @hook   = {}
end

Public Instance Methods

add_hook(name) click to toggle source
# File lib/redoxed/manager.rb, line 50
def add_hook(name)
  loader @hook, Config::HookDir, "hook", name
end
add_input(name) click to toggle source
# File lib/redoxed/manager.rb, line 34
def add_input(name)
  loader @input, Config::InputDir, "input", name
end
add_model(name) click to toggle source
# File lib/redoxed/manager.rb, line 46
def add_model(name)
  loader @model, Config::ModelDir, "model", name
end
add_output(name) click to toggle source
# File lib/redoxed/manager.rb, line 38
def add_output(name)
  loader @output, Config::OutputDir, "output", name
end
add_source(name) click to toggle source
# File lib/redoxed/manager.rb, line 42
def add_source(name)
  loader @source, Config::SourceDir, "source", name
end

Private Instance Methods

loader(hash, global_dir, local_dir, name) click to toggle source

if local version of file exists, load it, else load global - return falsy value if nothing loaded

# File lib/redoxed/manager.rb, line 57
def loader(hash, global_dir, local_dir, name)
  dir   = File.join(Config::Root, local_dir)
  map   = Manager.load(dir, name) if File.exist? File.join(dir, name + ".rb")
  map ||= Manager.load(global_dir, name)
  hash.merge!(map) if map
end