Class: Swagcov::Coverage
- Inherits:
-
Object
- Object
- Swagcov::Coverage
- Defined in:
- lib/swagcov/coverage.rb
Instance Method Summary collapse
- #collect ⇒ Object
-
#initialize(dotfile: ::Swagcov::Dotfile.new, routes: ::Swagcov.project_routes) ⇒ Coverage
constructor
A new instance of Coverage.
Constructor Details
#initialize(dotfile: ::Swagcov::Dotfile.new, routes: ::Swagcov.project_routes) ⇒ Coverage
Returns a new instance of Coverage.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/swagcov/coverage.rb', line 5 def initialize dotfile: ::Swagcov::Dotfile.new, routes: ::Swagcov.project_routes @dotfile = dotfile @openapi_files = ::Swagcov::OpenapiFiles.new(filepaths: @dotfile.docs_config) @routes = routes @rails_version = ::Rails::VERSION::STRING @data = { covered: [], ignored: [], uncovered: [], total_count: 0, covered_count: 0, ignored_count: 0, uncovered_count: 0 } end |
Instance Method Details
#collect ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/swagcov/coverage.rb', line 21 def collect @routes.each do |route| path = route_path(route) verb = route_verb(route) next if default_skipped_route?(route, path, verb) if dotfile.ignore_path?(path, verb: verb) update_data(:ignored, verb, path, "ignored") next end next if dotfile.only_path_mismatch?(path) @data[:total_count] += 1 if (response_keys = openapi_files.find_response_keys(path: path, route_verb: verb)) update_data(:covered, verb, path, response_keys.join(" ")) else update_data(:uncovered, verb, path, "none") end end @data end |