Class: Juggle::Jug
- Inherits:
-
Object
- Object
- Juggle::Jug
- Defined in:
- lib/juggle/jug.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#ops ⇒ Object
Returns the value of attribute ops.
-
#opts ⇒ Object
Returns the value of attribute opts.
Instance Method Summary collapse
- #cache_key ⇒ Object
- #closure(opts = {}, &blk) ⇒ Object
- #coffee(path, opts = {}) ⇒ Object
- #compile ⇒ Object
- #curl(path, opts = {}) ⇒ Object
- #file(path, opts = {}) ⇒ Object
-
#initialize(opts = {}, &blk) ⇒ Jug
constructor
A new instance of Jug.
- #manifest ⇒ Object
- #render ⇒ Object
- #template(path, opts = {}) ⇒ Object
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
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/juggle/jug.rb', line 5 def name @name end |
#ops ⇒ Object
Returns the value of attribute ops.
6 7 8 |
# File 'lib/juggle/jug.rb', line 6 def ops @ops end |
#opts ⇒ Object
Returns the value of attribute opts.
5 6 7 |
# File 'lib/juggle/jug.rb', line 5 def opts @opts end |
Instance Method Details
#cache_key ⇒ Object
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 |
#compile ⇒ Object
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 |
#manifest ⇒ Object
41 42 43 44 45 |
# File 'lib/juggle/jug.rb', line 41 def manifest ops.inject([]) do |files, op| files | op.manifest end end |
#render ⇒ Object
33 34 35 |
# File 'lib/juggle/jug.rb', line 33 def render ops.map {|op| op.render}.join("\n") + "\n" end |