Class: Guard::RailsAssets
- Inherits:
-
Guard
- Object
- Guard
- Guard::RailsAssets
show all
- Defined in:
- lib/guard/rails-assets.rb
Defined Under Namespace
Classes: CliRunner, RailsRunner
Instance Method Summary
collapse
Constructor Details
#initialize(watchers = [], options = {}) ⇒ RailsAssets
Returns a new instance of RailsAssets.
6
7
8
9
10
11
|
# File 'lib/guard/rails-assets.rb', line 6
def initialize(watchers=[], options={})
super
@options = options || {}
@run_on = @options[:run_on] || [:start, :change]
@run_on = [@run_on] unless @run_on.respond_to?(:include?)
end
|
Instance Method Details
#compile_assets ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/guard/rails-assets.rb', line 31
def compile_assets
puts "Compiling rails assets with #{runner.class.name}."
result = runner.compile_assets
if result
Notifier::notify 'Assets compiled'
puts 'Assets compiled.'
else
Notifier::notify 'see the details in the terminal', :title => "Can't compile assets", :image => :failed
puts 'Failed to compile assets.'
end
end
|
#reload ⇒ Object
18
19
20
21
|
# File 'lib/guard/rails-assets.rb', line 18
def reload
runner.reload if runner.respond_to? :reload
compile_assets if run_for? :reload
end
|
#run_all ⇒ Object
23
24
25
|
# File 'lib/guard/rails-assets.rb', line 23
def run_all
compile_assets if run_for? :all
end
|
#run_for?(command) ⇒ Boolean
53
54
55
|
# File 'lib/guard/rails-assets.rb', line 53
def run_for? command
@run_on.include?(command)
end
|
#run_on_change(paths = []) ⇒ Object
27
28
29
|
# File 'lib/guard/rails-assets.rb', line 27
def run_on_change(paths=[])
compile_assets if run_for? :change
end
|
#runner ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/guard/rails-assets.rb', line 44
def runner
@runner ||= begin
runner_name = (@options[:runner] || :rails).to_s
require "guard/rails-assets/#{runner_name}_runner"
::Guard::RailsAssets.const_get(runner_name.capitalize + 'Runner').new(@options)
end
end
|
#start ⇒ Object
13
14
15
16
|
# File 'lib/guard/rails-assets.rb', line 13
def start
runner.start if runner.respond_to? :start
compile_assets if run_for? :start
end
|