Class: Kaisoku::Commands::WatchCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/kaisoku/commands/watch_command.rb

Instance Method Summary collapse

Constructor Details

#initialize(paths, options) ⇒ WatchCommand

Returns a new instance of WatchCommand.



6
7
8
9
10
# File 'lib/kaisoku/commands/watch_command.rb', line 6

def initialize(paths, options)
  @paths = paths
  @options = options
  @context = RuntimeContext.new(options)
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/kaisoku/commands/watch_command.rb', line 12

def call
  watcher = watcher_class.new(
    configuration: @context.configuration,
    paths: @paths.empty? ? Watcher::DEFAULT_PATHS : @paths,
    interval: @options[:interval] || 0.2
  )

  puts "watching #{watcher.paths.join(', ')}"
  WatchSession.new(watcher: watcher, debounce: 0.05, runner: runner).start
end