Sha256: 792f7babeff06765656781de638ffa3f43186974f9b82ada6746f30c8059f8ad

Contents?: true

Size: 657 Bytes

Versions: 4

Compression:

Stored size: 657 Bytes

Contents

require 'yaml'
require 'erubis'
require 'fileutils'
require 'pathname'

SPEC_ROOT = File.expand_path(File.dirname(__FILE__))

module KeymapTest
  class << self
    def config
      @config ||= read_config
    end

    private

    def config_file
      Pathname.new(ENV['KEYMAP_CONFIG'] || File.join(SPEC_ROOT, 'config.yml'))
    end

    def read_config
      unless config_file.exist?
        FileUtils.cp(File.join(SPEC_ROOT, 'config.example.yml'), config_file)
      end

      erb = Erubis::Eruby.new(config_file.read)
      expand_config(YAML.parse(erb.result(binding)).transform)
    end

    def expand_config(config)
      config
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
keymap-0.3.2 spec/support/config.rb
keymap-0.3.1 spec/support/config.rb
keymap-0.3.0 spec/support/config.rb
keymap-0.2.0 spec/support/config.rb