Class: Guard::TestHelpers::Template::Session
- Inherits:
-
Object
- Object
- Guard::TestHelpers::Template::Session
show all
- Defined in:
- lib/guard/test_helpers.rb
Defined Under Namespace
Classes: GlobalWatchesNotImplemented, MultipleGuardNotImplemented
Instance Method Summary
collapse
Constructor Details
#initialize(path, content) ⇒ Session
Returns a new instance of Session.
28
29
30
31
32
|
# File 'lib/guard/test_helpers.rb', line 28
def initialize(path, content)
@watches = {}
@current = nil
instance_eval(content, path, 1)
end
|
Instance Method Details
#engine ⇒ Object
34
35
36
|
# File 'lib/guard/test_helpers.rb', line 34
def engine
@engine ||= Guard::Engine.new
end
|
#guard(name, _options = {}) ⇒ Object
46
47
48
49
50
51
|
# File 'lib/guard/test_helpers.rb', line 46
def guard(name, _options = {})
@current = name
@watches[@current] = []
yield
@current = nil
end
|
#match(file) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/guard/test_helpers.rb', line 38
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) ⇒ Object
53
54
55
|
# File 'lib/guard/test_helpers.rb', line 53
def watch(expr, &block)
@watches[@current] << [expr, block]
end
|