Sha256: 1503fd7d1a60d8115c3522eb696604bdfeefb17709a06a3d532e2a013e17194d

Contents?: true

Size: 956 Bytes

Versions: 2

Compression:

Stored size: 956 Bytes

Contents

require 'json'

module Pra
  class Config
    def initialize(initial_config = {})
      @initial_config = initial_config
    end

    def self.load_config
      return self.new(self.parse_config_file)
    end

    def self.parse_config_file
      self.json_parse(self.read_config_file)
    end

    def self.read_config_file
      file = File.open(self.config_path, "r")
      contents = file.read
      file.close
      return contents
    end

    def self.config_path
      return File.join(self.users_home_directory, '.pra.json')
    end

    def self.error_log_path
      return File.join(self.users_home_directory, '.pra.errors.log')
    end

    def self.users_home_directory
      return ENV['HOME']
    end

    def self.json_parse(content)
      return JSON.parse(content)
    end

    def pull_sources
      @initial_config["pull_sources"]
    end

    def assignee_blacklist
      Array(@initial_config["assignee_blacklist"])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pra-1.6.0 lib/pra/config.rb
pra-1.5.1 lib/pra/config.rb