Class: Guard::Less
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::Less
- Defined in:
- lib/guard/less.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Less
constructor
A new instance of Less.
- #run(paths) ⇒ Object
-
#run_all ⇒ Object
Call with Ctrl-/ signal This method should be principally used for long action like running all specs/tests/…
-
#run_on_changes(paths) ⇒ Object
Call on file(s) modifications.
- #start ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Less
Returns a new instance of Less.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/guard/less.rb', line 8 def initialize( = {}) defaults = { all_after_change: true, all_on_start: true, output: nil, import_paths: [], compress: false, patterns: [], yuicompress: false } super(defaults.merge()) end |
Instance Method Details
#run(paths) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/guard/less.rb', line 40 def run(paths) directories = nested_directory_map(paths) directories.each do |destination, stylesheets| stylesheets.each do |lessfile| # Skip partials basename = File.basename(lessfile) next if basename[0, 1] == '_' cssfile = File.join(destination, basename.gsub(/\.less$/, '.css')) # Just in case if cssfile == lessfile Compat::UI.info "Guard::Less: Skipping #{lessfile} since output and source are the same" elsif mtime(cssfile) >= mtime_including_imports(lessfile) Compat::UI.info "Guard::Less: Skipping #{lessfile} because #{cssfile} is already up-to-date" else Compat::UI.info "Guard::Less: #{lessfile} -> #{cssfile}\n" FileUtils.mkdir_p(File.(destination)) compile(lessfile, cssfile) end end end end |
#run_all ⇒ Object
Call with Ctrl-/ signal This method should be principally used for long action like running all specs/tests/…
28 29 30 31 32 33 |
# File 'lib/guard/less.rb', line 28 def run_all Compat::UI.info 'Guard::Less: compiling all files' files = Dir.glob('**/*.*') paths = Compat.matching_files(self, files).uniq run(paths) end |
#run_on_changes(paths) ⇒ Object
Call on file(s) modifications
36 37 38 |
# File 'lib/guard/less.rb', line 36 def run_on_changes(paths) [:all_after_change] ? run_all : run(paths) end |
#start ⇒ Object
21 22 23 24 |
# File 'lib/guard/less.rb', line 21 def start Compat::UI.info "Guard::Less #{LessVersion::VERSION} is on the job!" run_all if [:all_on_start] end |