Class: Guard::Motion::ResultsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/motion/results_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



4
5
6
# File 'lib/guard/motion/results_parser.rb', line 4

def errors
  @errors
end

#failuresObject (readonly)

Returns the value of attribute failures.



5
6
7
# File 'lib/guard/motion/results_parser.rb', line 5

def failures
  @failures
end

#specsObject (readonly)

Returns the value of attribute specs.



6
7
8
# File 'lib/guard/motion/results_parser.rb', line 6

def specs
  @specs
end

Instance Method Details

#parse(output) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/guard/motion/results_parser.rb', line 8

def parse(output)
  matched = false

  stats_regex = /(\d+) (tests|specifications),? \(?\d+ (assertions|requirements)\)?, (\d+) failures, (\d+) errors/
  stats_regex.match(output) do |m|
    matched = true

    @specs = m[1].to_i
    @failures = m[4].to_i
    @errors = m[5].to_i
  end

  matched
end

#success?Boolean



23
24
25
# File 'lib/guard/motion/results_parser.rb', line 23

def success?
  errors == 0 && failures == 0
end