Sha256: 248ad2e56c3634241c9107ed6616942a8da98ad8c6c9200bdbff75cb3df09486

Contents?: true

Size: 844 Bytes

Versions: 1

Compression:

Stored size: 844 Bytes

Contents

# frozen_string_literal: true

module NeetoCompliance
  class SidekiqQueuesVerifier < Base
    def local_copy
      "config/sidekiq.yml"
    end

    def queues
      @_queues ||= ["auth", "urgent", "default", "low"]
    end

    def valid?
      @errors = []
      @missing_queues = []
      sidekiq_yml = YAML.load(File.open(local_copy), aliases: true)
      local_queues = sidekiq_yml["queues"] || []
      queues.map do |queue|
        unless local_queues.include?(queue)
          @missing_queues << queue
          @errors << "Add #{queue} to queues in #{local_copy}"
        end
      end

      @errors.length == 0
    end

    def autofix_suggestion
      @errors.join("\n").yellow
    end

    def autofix_command
      "perl -p -i -e 's/queues:/queues:\n  - #{@missing_queues.join("\n  - ")}/g' config/sidekiq.yml"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
neeto-compliance-1.0.58 lib/neeto_compliance/verifiers/sidekiq_queues_verifier.rb