Class: Fontcustom::Watcher

Inherits:
Object
  • Object
show all
Includes:
Utility
Defined in:
lib/fontcustom/watcher.rb

Instance Method Summary collapse

Methods included from Utility

#behavior, #destination_root, #line_break, #methodize_hash, #options, #project_root, #say_changed, #say_message, #say_status, #shell, shell, #source_paths, #symbolize_hash, #write_file

Constructor Details

#initialize(options, is_test = false) ⇒ Watcher

Returns a new instance of Watcher.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fontcustom/watcher.rb', line 8

def initialize(options, is_test = false)
  @base = Fontcustom::Base.new options
  @options = @base.options
  @is_test = is_test

  templates = @options[:templates].dup.map { |template| File.basename(template) }
  packaged = %w|preview css scss scss-rails|
  templates.delete_if { |template| packaged.include?(template) }

  create_listener(templates)
end

Instance Method Details

#watchObject



20
21
22
23
24
25
# File 'lib/fontcustom/watcher.rb', line 20

def watch
  compile unless @options[:skip_first]
  start
rescue SignalException # Catches Ctrl + C
  stop
end