Sha256: 8258e836b399c5b555d17d28c471c22c178808ef12a04c17fe4ea611552c9c47

Contents?: true

Size: 593 Bytes

Versions: 1

Compression:

Stored size: 593 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 {} if !@config
      @config
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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