Class: Swagcov::Coverage

Inherits:
Object
  • Object
show all
Defined in:
lib/swagcov/coverage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dotfile: Swagcov::Dotfile.new, routes: ::Rails.application.routes.routes) ⇒ Coverage

Returns a new instance of Coverage.



7
8
9
10
11
12
13
14
15
16
# File 'lib/swagcov/coverage.rb', line 7

def initialize dotfile: Swagcov::Dotfile.new, routes: ::Rails.application.routes.routes
  @total = 0
  @covered = 0
  @ignored = 0
  @routes_not_covered = []
  @routes_covered = []
  @routes_ignored = []
  @dotfile = dotfile
  @routes = routes
end

Instance Attribute Details

#coveredObject (readonly)

Returns the value of attribute covered.



5
6
7
# File 'lib/swagcov/coverage.rb', line 5

def covered
  @covered
end

#ignoredObject (readonly)

Returns the value of attribute ignored.



5
6
7
# File 'lib/swagcov/coverage.rb', line 5

def ignored
  @ignored
end

#routes_coveredObject (readonly)

Returns the value of attribute routes_covered.



5
6
7
# File 'lib/swagcov/coverage.rb', line 5

def routes_covered
  @routes_covered
end

#routes_ignoredObject (readonly)

Returns the value of attribute routes_ignored.



5
6
7
# File 'lib/swagcov/coverage.rb', line 5

def routes_ignored
  @routes_ignored
end

#routes_not_coveredObject (readonly)

Returns the value of attribute routes_not_covered.



5
6
7
# File 'lib/swagcov/coverage.rb', line 5

def routes_not_covered
  @routes_not_covered
end

#totalObject (readonly)

Returns the value of attribute total.



5
6
7
# File 'lib/swagcov/coverage.rb', line 5

def total
  @total
end

Instance Method Details

#reportObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/swagcov/coverage.rb', line 18

def report
  collect_coverage
  routes_output(@routes_covered, "green")
  routes_output(@routes_ignored, "yellow")
  routes_output(@routes_not_covered, "red")

  final_output

  @total - @covered
end