Sha256: 59a9aadb34caf8701bedb4f3dbf4cfe3ea2b5e545615765fa59fe5364bdf3bdc

Contents?: true

Size: 559 Bytes

Versions: 1

Compression:

Stored size: 559 Bytes

Contents

require "yaml"

module RockConfig
  class YamlLoader
    def find_at(directory, file_name)
      path = full_path(directory, file_name)

      if readable?(path)
        return Config.new(load_yaml_from(path))
      end
    end

    private

    def full_path(directory, file_name)
      File.join(directory, full_name(file_name))
    end

    def full_name(file_name)
      "#{file_name}.yml"
    end

    def readable?(path)
      File.exists?(path) && File.readable?(path)
    end

    def load_yaml_from(path)
      YAML.load_file(path)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rock_config-0.0.1 lib/rock_config/yaml_loader.rb