Sha256: 2f676a885923085a0c992b34b51ebce252736072694603326e63f8f50e7a7e29

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

require "parallel"

module Miteru
  class Configuration
    # @return [Boolean]
    attr_accessor :auto_download

    # @return [Boolean]
    attr_accessor :ayashige

    # @return [Boolean]
    attr_accessor :directory_traveling

    # @return [String]
    attr_accessor :download_to

    # @return [Boolean]
    attr_accessor :post_to_slack

    # @return [Integer]
    attr_accessor :size

    # @return [Integer]
    attr_accessor :threads

    # @return [Boolean]
    attr_accessor :verbose

    attr_reader :valid_extensions

    def initialize
      @auto_download = false
      @ayashige = false
      @directory_traveling = false
      @download_to = "/tmp"
      @post_to_slack = false
      @size = 100
      @threads = Parallel.processor_count
      @verbose = false

      @valid_extensions = [".zip", ".rar", ".7z", ".tar", ".gz"].freeze
    end

    def auto_download?
      @auto_download
    end

    def ayashige?
      @ayashige
    end

    def directory_traveling?
      @directory_traveling
    end

    def post_to_slack?
      @post_to_slack
    end

    def verbose?
      @verbose
    end
  end

  class << self
    # @return [Miteru::Configuration] Miteru's current configuration
    def configuration
      @configuration ||= Configuration.new
    end

    # Set Miteru's configuration
    # @param config [Miteru::Configuration]
    attr_writer :configuration

    # Modify Miteru's current configuration
    # @yieldparam [Miteru::Configuration] config current Miteru config
    def configure
      yield configuration
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
miteru-0.14.4 lib/miteru/configuration.rb
miteru-0.14.3 lib/miteru/configuration.rb