Sha256: 7d76b1b7e740463bdf1132c4b4c01d933a2b98257883a9396928edd520c23f0e

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

module Paraduct
  require "singleton"
  require "yaml"

  class Configuration
    include Singleton

    # @return [Pathname]
    def variables
      config_data[:variables]
    end

    # @return [String, Array<String>]
    def script
      config_data[:script]
    end

    # @return [Integer]
    def max_threads
      config_data[:max_threads] || 4
    end

    def rsync_option
      config_data[:rsync_option] || {}
    end

    def exclude
      config_data[:exclude] || []
    end

    # @return [Pathname]
    def work_dir
      config_data[:work_dir]
    end

    def base_job_dir
      if work_dir.blank?
        root_dir
      else
        root_dir.join(work_dir)
      end
    end

    def enable_rsync?
      !work_dir.blank?
    end

    # @return [Pathname]
    def config_file
      root_dir.join(".paraduct.yml")
    end

    # @return [Pathname]
    def root_dir
      Pathname.pwd
    end

    private

    def config_data
      @config_data ||= YAML.load_file(config_file).with_indifferent_access
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
paraduct-1.0.0.beta4 lib/paraduct/configuration.rb
paraduct-1.0.0.beta3 lib/paraduct/configuration.rb
paraduct-1.0.0.beta2 lib/paraduct/configuration.rb
paraduct-1.0.0.beta1 lib/paraduct/configuration.rb