Module: Bunch

Defined in:
lib/bunch/middleware.rb,
lib/bunch.rb,
lib/bunch/cli.rb,
lib/bunch/rack.rb,
lib/bunch/cache.rb,
lib/bunch/version.rb,
lib/bunch/ejs_node.rb,
lib/bunch/file_node.rb,
lib/bunch/jade_node.rb,
lib/bunch/null_node.rb,
lib/bunch/sass_node.rb,
lib/bunch/coffee_node.rb,
lib/bunch/abstract_node.rb,
lib/bunch/directory_node.rb

Overview

heavily inspired by Rack::URLMap

Defined Under Namespace

Modules: Cache Classes: AbstractNode, CLI, CoffeeNode, CompileError, DirectoryNode, EJSNode, FileNode, JadeNode, Middleware, NullNode, Rack, SassNode

Constant Summary collapse

IGNORED_PATTERNS =
[]
VERSION =
"0.2.2"

Class Method Summary collapse

Class Method Details

.content_for(path, options = {}) ⇒ Object



52
53
54
# File 'lib/bunch.rb', line 52

def content_for(path, options = {})
  tree_for(normalized_path(path), options).content
end

.load_ignores(path = '.') ⇒ Object



44
45
46
47
48
49
50
# File 'lib/bunch.rb', line 44

def load_ignores(path='.')
  fn = File.join(path, '.bunchignore')
  if File.exist?(fn)
    IGNORED_PATTERNS.concat File.readlines(fn).map { |f| Regexp.new(f.chomp) }
    IGNORED_PATTERNS.uniq!
  end
end

.tree_for(path, options) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/bunch.rb', line 56

def tree_for(path, options)
  node = case
    when IGNORED_PATTERNS.any? { |p| File.basename(path) =~ p }
      Bunch::NullNode.new(path)
    when File.directory?(path)
      Bunch::DirectoryNode.new(path)
    when path =~ /\.coffee$/
      Bunch::CoffeeNode.new(path)
    when path =~ /\.s(a|c)ss$/
      Bunch::SassNode.new(path)
    when path =~ /\.ejs$/
      Bunch::EJSNode.new(path)
    when path =~ /\.jade/
      Bunch::JadeNode.new(path)
    else
      Bunch::FileNode.new(path)
    end
  node.options = options
  node
end