Class: Goodcheck::Trigger

Inherits:
Object
  • Object
show all
Defined in:
lib/goodcheck/trigger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(patterns:, globs:, passes:, fails:, negated:) ⇒ Trigger

Returns a new instance of Trigger.



9
10
11
12
13
14
15
16
17
# File 'lib/goodcheck/trigger.rb', line 9

def initialize(patterns:, globs:, passes:, fails:, negated:)
  @patterns = patterns
  @globs = globs
  @passes = passes
  @fails = fails
  @negated = negated
  @by_pattern = false
  @skips_fail_examples = false
end

Instance Attribute Details

#failsObject (readonly)

Returns the value of attribute fails.



6
7
8
# File 'lib/goodcheck/trigger.rb', line 6

def fails
  @fails
end

#globsObject (readonly)

Returns the value of attribute globs.



4
5
6
# File 'lib/goodcheck/trigger.rb', line 4

def globs
  @globs
end

#negatedObject (readonly)

Returns the value of attribute negated.



7
8
9
# File 'lib/goodcheck/trigger.rb', line 7

def negated
  @negated
end

#passesObject (readonly)

Returns the value of attribute passes.



5
6
7
# File 'lib/goodcheck/trigger.rb', line 5

def passes
  @passes
end

#patternsObject (readonly)

Returns the value of attribute patterns.



3
4
5
# File 'lib/goodcheck/trigger.rb', line 3

def patterns
  @patterns
end

Instance Method Details

#by_pattern!Object



19
20
21
22
# File 'lib/goodcheck/trigger.rb', line 19

def by_pattern!
  @by_pattern = true
  self
end

#by_pattern?Boolean

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/goodcheck/trigger.rb', line 24

def by_pattern?
  # True if the trigger is from `pattern` or `not` attribute (compatible mode.)
  @by_pattern
end

#fires_for?(path:) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/goodcheck/trigger.rb', line 42

def fires_for?(path:)
  globs.any? {|glob| glob.test(path) }
end

#negated?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/goodcheck/trigger.rb', line 38

def negated?
  @negated
end

#skips_fail_examples!(flag = true) ⇒ Object



29
30
31
32
# File 'lib/goodcheck/trigger.rb', line 29

def skips_fail_examples!(flag = true)
  @skips_fail_examples = flag
  self
end

#skips_fail_examples?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/goodcheck/trigger.rb', line 34

def skips_fail_examples?
  @skips_fail_examples
end