Sha256: 2e5492b38eb156f8f4288e22a2ad034be2342b249ea16c767ba30b4cdc0579fa

Contents?: true

Size: 662 Bytes

Versions: 1

Compression:

Stored size: 662 Bytes

Contents

require 'yaml'

module Kryten

  module Config

    def base_path
      File.expand_path(File.join(ENV['BUNDLE_GEMFILE'], '..'))
    end

    def configure
      classname = self.name.split('::')
      classname = if classname.one?
                    classname.first.downcase
                  else
                    classname[0...-1].collect(&:downcase).join('-')
                  end
      file = File.open(File.join(self.base_path, "config/#{classname}.yml"))
      YAML.load(file)[classname]
    end

    def config entry=nil
      @config ||= configure
      if entry
        @config.fetch(entry)
      else
        @config
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kryten-0.3.6 lib/kryten/config.rb