class Guard::Compat::Test::Template::Session
Public Class Methods
new(path, content)
click to toggle source
# File lib/guard/compat/test/template.rb, line 18 def initialize(path, content) @watches = {} @current = nil instance_eval(content, path, 1) end
Public Instance Methods
guard(name, _options = {}) { || ... }
click to toggle source
# File lib/guard/compat/test/template.rb, line 31 def guard(name, _options = {}) @current = name @watches[@current] = [] yield @current = nil end
match(file)
click to toggle source
# File lib/guard/compat/test/template.rb, line 24 def match(file) _watches.map do |expr, block| next unless (match = file.match(expr)) block.nil? ? [file] : block.call([file] + match.captures) end.flatten.compact.uniq end
watch(expr, &block)
click to toggle source
# File lib/guard/compat/test/template.rb, line 38 def watch(expr, &block) @watches[@current] << [expr, block] end
Private Instance Methods
_watches()
click to toggle source
# File lib/guard/compat/test/template.rb, line 44 def _watches keys = @watches.keys fail ArgumentError, 'no watches!' if keys.empty? fail MultipleGuardNotImplemented if keys.size > 1 key = keys.first fail GlobalWatchesNotImplemented if key.nil? @watches[key] end