Sha256: 49c7963e000a81e9a49ba13a24f45d049684d073b1d8eac56ca9f9b987a4d459

Contents?: true

Size: 754 Bytes

Versions: 6

Compression:

Stored size: 754 Bytes

Contents

require 'yaml'
require 'papa/helper/output'

module Papa
  module Helper
    class Config
      def self.read
        return @config if defined?(@config)
        exit_on_config_not_exists unless config_exists?
        @config = YAML.load_file(config_path)
      end

      def self.config_path
        "#{Dir.home}/.papa.config.yml"
      end

      def self.config_exists?
        File.exists?(config_path)
      end

      def self.exit_on_config_not_exists
        message = 'Cannot find config file.'
        Helper::Output.failure message
        info = <<-INFO
Make sure you have a valid config file in #{config_path}.
See README.md for more details.
        INFO
        Helper::Output.failure_info info
        exit 1
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
papa-1.2.0 lib/papa/helper/config.rb
papa-1.1.0 lib/papa/helper/config.rb
papa-1.0.0 lib/papa/helper/config.rb
papa-0.7.2 lib/papa/helper/config.rb
papa-0.7.1 lib/papa/helper/config.rb
papa-0.7.0 lib/papa/helper/config.rb