Sha256: 3c589e31fcd7653a6f4a8ad9c4f93ed1466a93ec83706494d4270ae40a20c334

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

require 'singleton'

module Churn
  
  # responsible for storing the churn configuration
  class ChurnOptions
    include Singleton 
    DEFAULT_CHURN_DIRECTORY = "tmp/churn"
    DEFAULT_MINIMUM_CHURN_COUNT = 5

    attr_accessor :data_directory, :minimum_churn_count, :ignore_files, :start_date
    
    def initialize()
      @data_directory      = DEFAULT_CHURN_DIRECTORY
      @minimum_churn_count = DEFAULT_MINIMUM_CHURN_COUNT
      @ignore_files        = ['/dev/null']
      @start_date          = '3 months ago'
    end

    def set_options(options = {})
      @data_directory      = options.fetch(:data_directory){ @data_directory } unless options[:data_directory]==''
      @minimum_churn_count = options.fetch(:minimum_churn_count){ @minimum_churn_count }.to_i
      @ignore_files        = (options.fetch(:ignore_files){ @ignore_files }).to_s.split(',').map(&:strip)
      @ignore_files << '/dev/null' unless @ignore_files.include?('/dev/null')
      @start_date          = options[:start_date] if options[:start_date].nil? || options[:start_date]!=''
      self
    end
        
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
churn-0.0.33 lib/churn_options.rb
churn-0.0.32 lib/churn_options.rb
churn-0.0.31 lib/churn_options.rb
churn-0.0.30 lib/churn_options.rb