Class: PolishGeeks::DevTools::Commands::Simplecov

Inherits:
Base
  • Object
show all
Defined in:
lib/polish_geeks/dev_tools/commands/simplecov.rb

Overview

Command wrapper for Simple code coverage analysing It informs us if we didn’t reach a proper code coverage level

Constant Summary collapse

NUMBER_REGEXP =

Regexp used to match float number from coverage

/(\d+[.]\d+)/

Constants inherited from Base

Base::TYPES

Instance Attribute Summary

Attributes inherited from Base

#output, #stored_output

Instance Method Summary collapse

Methods inherited from Base

#ensure_executable!

Instance Method Details

#error_messageString



37
38
39
40
# File 'lib/polish_geeks/dev_tools/commands/simplecov.rb', line 37

def error_message
  'SimpleCov coverage level needs to be ' \
    "#{threshold}%#{threshold == limit ? '' : ' or more'}, was #{to_f}%"
end

#executeString

Executes this command



22
23
24
# File 'lib/polish_geeks/dev_tools/commands/simplecov.rb', line 22

def execute
  @output = stored_output.rspec[*Validators::Simplecov::MATCH_REGEXP]
end

#labelString



32
33
34
# File 'lib/polish_geeks/dev_tools/commands/simplecov.rb', line 32

def label
  "SimpleCov covered #{to_f}%, required #{threshold}%"
end

#to_fFloat



16
17
18
# File 'lib/polish_geeks/dev_tools/commands/simplecov.rb', line 16

def to_f
  output[*NUMBER_REGEXP].to_f
end

#valid?Boolean



27
28
29
# File 'lib/polish_geeks/dev_tools/commands/simplecov.rb', line 27

def valid?
  to_f >= threshold
end