Sha256: 128c82a2c1a1eecbdd39b282dca4fd2660fb20e0a161b43613aa170d0a0fb229

Contents?: true

Size: 596 Bytes

Versions: 1

Compression:

Stored size: 596 Bytes

Contents

require 'yaml'
require 'singleton'

module WhatsupGithub
  # Creates readable objects from confirurarion files
  class Config
    attr_reader :config
    include Singleton

    def initialize
      @file = '.whatsup.yml'
      @config = {}
    end

    def read(*options)
      unless File.exist?(@file)
        dist_file = File.expand_path("../template/#{@file}", __dir__)
        FileUtils.cp dist_file, @file
      end
      load_from_yaml.dig options.join ','
    end

    def load_from_yaml
      @config = YAML.load_file @file
      return {} unless @config
      @config
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whatsup_github-0.0.1 lib/whatsup_github/config-reader.rb