Module: Autocuke::Handler

Defined in:
lib/autocuke/handler.rb

Instance Method Summary collapse

Instance Method Details

#file_deletedObject

Triggered after a file has been deleted. In text editors, the file is deleted and recreated rather than modified. If so, we’ll start watching the new file and trigger ‘file_modified`



22
23
24
25
26
27
28
29
# File 'lib/autocuke/handler.rb', line 22

def file_deleted
  if File.exists?(path)
    file_modified
    runtime.watch(path)
  else      
    stop!
  end
end

#file_modifiedObject

Triggered after a file has been modified



5
6
7
8
9
10
11
12
# File 'lib/autocuke/handler.rb', line 5

def file_modified
  return if runtime.current_file
  runtime.current_file = path
  local = path.sub(/.*#{runtime.options.root}\/?/, '')
  cmd   = "cd #{runtime.root}; bundle exec cucumber -p autocuke #{local}"
  puts "#{local} modified - re-cuking it."
  run_with_defer cmd      
end

#file_movedObject

Triggered after a file has been moved



15
16
17
# File 'lib/autocuke/handler.rb', line 15

def file_moved
  stop! unless File.exists?(path)
end

#unbindObject

Stop EM if the file doesn’t exist



32
33
34
# File 'lib/autocuke/handler.rb', line 32

def unbind
  stop! unless File.exists?(path)
end