Sha256: ca146205288927adaf1044da8fcb9e71094f254f0a2f6acb5e19ce338091b2f0

Contents?: true

Size: 1.03 KB

Versions: 8

Compression:

Stored size: 1.03 KB

Contents

module Goodcheck
  module Commands
    class Pattern
      attr_reader :stdout
      attr_reader :stderr
      attr_reader :config_path
      attr_reader :ids
      attr_reader :home_path

      include ConfigLoading
      include HomePath
      include ExitStatus

      def initialize(stdout:, stderr:, path:, ids:, home_path:)
        @stdout = stdout
        @stderr = stderr
        @config_path = path
        @ids = ids
        @home_path = home_path
      end

      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
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
goodcheck-3.1.0 lib/goodcheck/commands/pattern.rb
goodcheck-3.0.3 lib/goodcheck/commands/pattern.rb
goodcheck-3.0.2 lib/goodcheck/commands/pattern.rb
goodcheck-3.0.1 lib/goodcheck/commands/pattern.rb
goodcheck-3.0.0 lib/goodcheck/commands/pattern.rb
goodcheck-2.7.0 lib/goodcheck/commands/pattern.rb
goodcheck-2.6.1 lib/goodcheck/commands/pattern.rb
goodcheck-2.6.0 lib/goodcheck/commands/pattern.rb