Class: Juggle::Jug

Inherits:
Object
  • Object
show all
Defined in:
lib/juggle/jug.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}, &blk) ⇒ Jug

Returns a new instance of Jug.



8
9
10
11
# File 'lib/juggle/jug.rb', line 8

def initialize(opts={}, &blk)
  self.ops, self.opts = [], opts
  instance_eval &blk
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/juggle/jug.rb', line 5

def name
  @name
end

#opsObject

Returns the value of attribute ops.



6
7
8
# File 'lib/juggle/jug.rb', line 6

def ops
  @ops
end

#optsObject

Returns the value of attribute opts.



5
6
7
# File 'lib/juggle/jug.rb', line 5

def opts
  @opts
end

Instance Method Details

#cache_keyObject



47
48
49
# File 'lib/juggle/jug.rb', line 47

def cache_key
  Digest::MD5.hexdigest manifest.map{|f| File.mtime(f)}.join
end

#closure(opts = {}, &blk) ⇒ Object



21
22
23
# File 'lib/juggle/jug.rb', line 21

def closure(opts={}, &blk)
  self.ops << Op::Closure.new(self, opts, &blk)
end

#coffee(path, opts = {}) ⇒ Object



25
26
27
# File 'lib/juggle/jug.rb', line 25

def coffee(path, opts={})
  self.ops << Op::Coffee.new(self, opts, path)
end

#compileObject



37
38
39
# File 'lib/juggle/jug.rb', line 37

def compile
  Juggle.compiler.compile render
end

#curl(path, opts = {}) ⇒ Object



17
18
19
# File 'lib/juggle/jug.rb', line 17

def curl(path, opts={})
  self.ops << Op::Remote.new(self, opts, path)
end

#file(path, opts = {}) ⇒ Object



13
14
15
# File 'lib/juggle/jug.rb', line 13

def file(path, opts={})
  self.ops << Op::File.new(self, opts, path)
end

#manifestObject



41
42
43
44
45
# File 'lib/juggle/jug.rb', line 41

def manifest
  ops.inject([]) do |files, op|
    files | op.manifest
  end
end

#renderObject



33
34
35
# File 'lib/juggle/jug.rb', line 33

def render
  ops.map {|op| op.render}.join("\n") + "\n"
end

#template(path, opts = {}) ⇒ Object



29
30
31
# File 'lib/juggle/jug.rb', line 29

def template(path, opts={})
  self.ops << Op::Template.new(self, opts, path)
end