Sha256: a2a2262866424151154221f2780b6722f78beade9d4f44ad353037ea3db75ab5

Contents?: true

Size: 636 Bytes

Versions: 8

Compression:

Stored size: 636 Bytes

Contents

require 'yaml'
require 'erb'

module Config
  module Sources
    class YAMLSource
      attr_accessor :path

      def initialize(path)
        @path = path.to_s
      end

      # returns a config hash from the YML file
      def load
        result = YAML.load(ERB.new(IO.read(@path)).result) if @path and File.exist?(@path)

        result || {}

        rescue Psych::SyntaxError => e
          raise "YAML syntax error occurred while parsing #{@path}. " \
                "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
                "Error: #{e.message}"
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
config-3.0.0 lib/config/sources/yaml_source.rb
config-2.2.3 lib/config/sources/yaml_source.rb
config-2.2.2 lib/config/sources/yaml_source.rb
config-2.2.1 lib/config/sources/yaml_source.rb
config-2.1.0 lib/config/sources/yaml_source.rb
config-2.0.0 lib/config/sources/yaml_source.rb
config-1.7.2 lib/config/sources/yaml_source.rb
config-1.7.1 lib/config/sources/yaml_source.rb