class ManifestDestiny::Config
Public Class Methods
new(root, &block)
click to toggle source
# File lib/manifest-destiny.rb, line 17 def initialize(root, &block) @cache = [] @watch = [] @network = [] @fallback = {} @root = root instance_eval(&block) if block_given? end
Public Instance Methods
cache(*names)
click to toggle source
# File lib/manifest-destiny.rb, line 30 def cache(*names) add(@cache, names) end
cache_path(*patterns)
click to toggle source
# File lib/manifest-destiny.rb, line 26 def cache_path(*patterns) add_path(@cache, patterns) end
fallback(hash = {})
click to toggle source
# File lib/manifest-destiny.rb, line 46 def fallback(hash = {}) @fallback.merge!(hash) end
network(*names)
click to toggle source
# File lib/manifest-destiny.rb, line 42 def network(*names) @network.concat(names) end
root()
click to toggle source
# File lib/manifest-destiny.rb, line 50 def root @root end
watch(*names)
click to toggle source
# File lib/manifest-destiny.rb, line 38 def watch(*names) add(@watch, names) end
watch_path(*patterns)
click to toggle source
# File lib/manifest-destiny.rb, line 34 def watch_path(*patterns) add_path(@watch, patterns) end
Private Instance Methods
add(collection, names)
click to toggle source
# File lib/manifest-destiny.rb, line 64 def add(collection, names) flat_names = names.map do |n| if (n =~ Regexp.new(root.to_s)) == 0 n.split(root).second else n end end collection.concat(flat_names) end
add_path(collection, patterns)
click to toggle source
# File lib/manifest-destiny.rb, line 56 def add_path(collection, patterns) patterns.each do |pattern| Dir[File.join(@root, pattern)].each do |file| collection << file.split(root).second end end end