Sha256: cc3ca14f0bfedd1abc1564ec7504db0c0abe20094db9879e0111fc189b0a3b25

Contents?: true

Size: 658 Bytes

Versions: 2

Compression:

Stored size: 658 Bytes

Contents

require 'yaml'
require 'erb'

module RailsConfig
  module Sources
    class YAMLSource
      attr_accessor :path

      def initialize(path)
        @path = path
      end

      # returns a config hash from the YML file
      def load
        if @path and File.exist?(@path.to_s)
          result = YAML.load(ERB.new(IO.read(@path.to_s)).result)
        end
        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

2 entries across 2 versions & 2 rubygems

Version Path
drtom_rails_config-0.5.0.beta1 lib/rails_config/sources/yaml_source.rb
rails_config-0.5.0.beta1 lib/rails_config/sources/yaml_source.rb