Class: Guard::Cogs

Inherits:
Plugin
  • Object
show all
Defined in:
lib/guard/cogs.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Cogs

Returns a new instance of Cogs.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/guard/cogs.rb', line 8

def initialize(options = {})
  super

  @compile = options[:compile]
  @dest = options[:dest] || '.'

  if options[:sprockets].nil?
    @sprockets = ::Sprockets::Environment.new
    @sprockets.cache = {}
    if options[:minify] == true
      begin
        require 'uglifier'
        @sprockets.js_compressor = ::Uglifier.new
      rescue LoadError
        throw 'Uglifier cannot be loaded. Please include "uglifier" in your Gemfile.'
      end
      begin
        require 'yui/compressor'
        @sprockets.css_compressor = ::YUI::CssCompressor.new
      rescue LoadError
        throw 'YUI Compressor cannot be loaded. Please include "yui/compressor" in your Gemfile.'
      end
    end
  else
    @sprockets = options[:sprockets]
  end

  asset_paths = options[:asset_paths] ? Array(options[:asset_paths]) : ['.']
  asset_paths.each {|p| @sprockets.append_path(p)}
end

Instance Method Details

#run_allObject



44
45
46
# File 'lib/guard/cogs.rb', line 44

def run_all
  run_sprockets
end

#run_on_modifications(paths) ⇒ Object



48
49
50
# File 'lib/guard/cogs.rb', line 48

def run_on_modifications(paths)
  run_sprockets(paths)
end

#startObject



39
40
41
42
# File 'lib/guard/cogs.rb', line 39

def start
   UI.info 'Starting guard-cogs'
   run_sprockets
end