Class: Aspen::Actions::Watch
- Inherits:
-
Object
- Object
- Aspen::Actions::Watch
- Defined in:
- lib/aspen/actions/watch.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(options: {}) ⇒ Watch
constructor
A new instance of Watch.
Constructor Details
#initialize(options: {}) ⇒ Watch
Returns a new instance of Watch.
7 8 9 10 11 |
# File 'lib/aspen/actions/watch.rb', line 7 def initialize(options: {}) @options = @logger = .fetch(:logger) { Logger.new(STDOUT, level: :warn) } Listen.logger = @logger end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/aspen/actions/watch.rb', line 13 def call puts if using_database? listener = Listen.to('src/', only: /\.aspen$/) do |mod, add, _rem| Aspen::CLI::Commands::Build.new.call Aspen::Actions::Push.new.call rescue Aspen::Error => e puts e. end listener.start sleep rescue Interrupt => e # FIXME: The logger calls don't ever seem to work. @logger.info "Exiting..." puts "\nExiting..." listener.stop raise SystemExit end |