class Goodcheck::Commands::Pattern

Attributes

config_path[R]
home_path[R]
ids[R]
stderr[R]
stdout[R]

Public Class Methods

new(stdout:, stderr:, path:, ids:, home_path:) click to toggle source
# File lib/goodcheck/commands/pattern.rb, line 14
def initialize(stdout:, stderr:, path:, ids:, home_path:)
  @stdout = stdout
  @stderr = stderr
  @config_path = path
  @ids = ids
  @home_path = home_path
end

Public Instance Methods

run() click to toggle source
# File lib/goodcheck/commands/pattern.rb, line 22
def run
  handle_config_errors stderr do
    load_config!(cache_path: cache_dir_path, force_download: true)

    config.rules.each do |rule|
      if ids.empty? || ids.any? {|pat| pat == rule.id || rule.id.start_with?("#{pat}.") }
        stdout.puts "#{rule.id}:"
        rule.triggers.each do |trigger|
          trigger.patterns.each do |pattern|
            stdout.puts "  - #{pattern.regexp.inspect}"
          end
        end
      end
    end
  end

  EXIT_SUCCESS
end