<commit_before>require_relative 'sqs_config'

module Delayed
  class Worker

    class << self
      attr_accessor :config, :sqs, :delay, :timeout, :expires_in, :aws_config

      def configure
        yield(config)

        self.default_queue_name = if !config.default_queue_name.nil? && config.default_queue_name.length != 0
                        config.default_queue_name
                      else
                        'default'
                      end
        self.delay = config.delay_seconds || 0
        self.timeout = config.visibility_timeout || 5.minutes
        self.expires_in = config.message_retention_period || 4.days
      end

      def config
        @config ||= SqsConfig.new
      end
    end
  end

  module Backend
    module Sqs      
      if Object.const_defined?(:Rails) and Rails.const_defined?(:Railtie)
        class Railtie < Rails::Railtie

          # configure our gem after Rails completely boots so that we have
          # access to any config/initializers that were run
          config.after_initialize do
            AWS::Rails.setup

            Delayed::Worker.sqs = AWS::SQS.new
            Delayed::Worker.configure {}
          end
        end
      elsif Object.const_defined?(:AWS) && AWS.respond_to?(:config) && !(AWS.config.access_key_id.nil? || AWS.config.secret_access_key.nil?)
        # Use config in AWS.config if it is defined well enough for our sqs-y purposes.
        Delayed::Worker.sqs = AWS::SQS.new
        Delayed::Worker.configure {}
      else
        path = Pathname.new(Delayed::Worker.config.aws_config)

        if File.exists?(path)
          cfg = YAML::load(File.read(path))

          unless cfg.keys[0]
            raise "AWS Yaml configuration file is missing a section"
          end

          AWS.config(cfg.keys[0])
        end

        Delayed::Worker.sqs = AWS::SQS.new
        Delayed::Worker.configure {}
      end      
    end
  end
end


<commit_msg>pithier code<commit_after>require_relative 'sqs_config'

module Delayed
  class Worker

    class << self
      attr_accessor :config, :sqs, :delay, :timeout, :expires_in, :aws_config

      def configure
        yield(config)

        self.default_queue_name = if !config.default_queue_name.nil? && config.default_queue_name.length != 0
                        config.default_queue_name
                      else
                        'default'
                      end
        self.delay = config.delay_seconds || 0
        self.timeout = config.visibility_timeout || 5.minutes
        self.expires_in = config.message_retention_period || 4.days
      end

      def config
        @config ||= SqsConfig.new
      end
    end
  end

  module Backend
    module Sqs      
      if Object.const_defined?(:Rails) and Rails.const_defined?(:Railtie)
        class Railtie < Rails::Railtie

          # configure our gem after Rails completely boots so that we have
          # access to any config/initializers that were run
          config.after_initialize do
            AWS::Rails.setup

            Delayed::Worker.sqs = AWS::SQS.new
            Delayed::Worker.configure {}
          end
        end
      elsif defined?(AWS.config) && AWS.config.access_key_id && AWS.config.secret_access_key
        # Use config in AWS.config if it is defined well enough for our sqs-y purposes.
        Delayed::Worker.sqs = AWS::SQS.new
        Delayed::Worker.configure {}
      else
        path = Pathname.new(Delayed::Worker.config.aws_config)

        if File.exists?(path)
          cfg = YAML::load(File.read(path))

          unless cfg.keys[0]
            raise "AWS Yaml configuration file is missing a section"
          end

          AWS.config(cfg.keys[0])
        end

        Delayed::Worker.sqs = AWS::SQS.new
        Delayed::Worker.configure {}
      end      
    end
  end
end



{'fraction_non_alphanumeric': 0.0873077925462601, 'fraction_numerical': 0.003127443315089914, 'mean_word_length': 1.9275362318840579, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '944123', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1087, 'n_words': 262}