class Swagcov::Dotfile
Constants
- DEFAULT_CONFIG_FILE_NAME
Attributes
dotfile[R]
Public Class Methods
new(pathname: Rails.root.join(DEFAULT_CONFIG_FILE_NAME))
click to toggle source
# File lib/swagcov/dotfile.rb, line 10 def initialize pathname: Rails.root.join(DEFAULT_CONFIG_FILE_NAME) raise BadConfigurationError, "Missing config file (#{DEFAULT_CONFIG_FILE_NAME})" unless pathname.exist? @dotfile = YAML.load_file(pathname) raise BadConfigurationError, "Invalid config file (#{DEFAULT_CONFIG_FILE_NAME})" unless valid? end
Public Instance Methods
doc_paths()
click to toggle source
# File lib/swagcov/dotfile.rb, line 25 def doc_paths dotfile.dig("docs", "paths") end
ignore_path?(path)
click to toggle source
# File lib/swagcov/dotfile.rb, line 17 def ignore_path? path ignored_regex&.match?(path) end
only_path_mismatch?(path)
click to toggle source
# File lib/swagcov/dotfile.rb, line 21 def only_path_mismatch? path only_regex && !only_regex.match?(path) end
Private Instance Methods
ignored_regex()
click to toggle source
# File lib/swagcov/dotfile.rb, line 33 def ignored_regex @ignored_regex ||= path_config_regex(dotfile.dig("routes", "paths", "ignore")) end
only_regex()
click to toggle source
# File lib/swagcov/dotfile.rb, line 37 def only_regex @only_regex ||= path_config_regex(dotfile.dig("routes", "paths", "only")) end
path_config_regex(path_config)
click to toggle source
# File lib/swagcov/dotfile.rb, line 41 def path_config_regex path_config return unless path_config config = path_config.map { |path| path.first == "^" ? path : "^#{path}$" } /#{config.join('|')}/ end
valid?()
click to toggle source
# File lib/swagcov/dotfile.rb, line 49 def valid? dotfile && doc_paths end