class Expansions::Expansion

Attributes

copies[RW]
files_to_merge[RW]
globber[RW]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/expansions/expansion.rb, line 38
def initialize
  super
  initialize_hashes :files_to_merge,:copies

  @globber = Proc.new do |path, exclude|
    glob(path, exclude)
  end

end

Public Instance Methods

before(&block) click to toggle source
# File lib/expansions/expansion.rb, line 72
def before(&block)
  setup_items << block
end
cleanup(&block) click to toggle source
# File lib/expansions/expansion.rb, line 68
def cleanup(&block)
  cleanup_items << block
end
copy_to(target, &block) click to toggle source
# File lib/expansions/expansion.rb, line 48
def copy_to(target, &block)
  copy_proc = Proc.new do |key|
    Copy.new(CopyToTarget.new(key))
  end
  hash_process(target, copies, copy_proc, &block)
end
expand_items() click to toggle source
# File lib/expansions/expansion.rb, line 92
def expand_items
  copies.process_all_values_using do |copy|
    copy.run
  end
end
hash_process(target, hash, factory, &block) click to toggle source
# File lib/expansions/expansion.rb, line 86
def hash_process(target, hash, factory, &block)
  symbol = target.to_sym
  hash[symbol] = factory.call(target) unless hash.has_key?(symbol)
  hash[symbol].instance_eval(&block)
end
look_for_templates_in(path, options=Hash.new(nil)) click to toggle source
# File lib/expansions/expansion.rb, line 62
def look_for_templates_in(path, options=Hash.new(nil))
  exclude = options.fetch(:exclude, -> (file) { false })

  globber.call(path, exclude).process_all_items_using(TemplateVisitor.instance)
end
merge_items() click to toggle source
# File lib/expansions/expansion.rb, line 98
def merge_items
  files_to_merge.process_all_values_using do |merge| 
    merge.run
  end
end
merge_to(target, &block) click to toggle source
# File lib/expansions/expansion.rb, line 55
def merge_to(target, &block)
  merge_proc = Proc.new do |key|
    FileMerge.new(key)
  end
  hash_process(target, files_to_merge, merge_proc, &block)
end
run() click to toggle source
# File lib/expansions/expansion.rb, line 76
def run
  run_setup_items
  purge_targets
  expand_items
  merge_items
  run_cleanup
  fix_line_endings 
  mark_files_executable
end