Sha256: d12d6378b9031297f8330d8931ce834b6f3d871cb9a27a009822f6dbf756a4a3

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

# This code is free software; you can redistribute it and/or modify it under
# the terms of the new BSD License.
#
# Copyright (c) 2010, Sebastian Staudt

module Rubikon

  module Config

    # A configuration provider loading various configuration file formats using
    # another provider depending on the extension of the configuration file.
    #
    # @author Sebastian Staudt
    # @since 0.5.0
    class AutoProvider

      # Load a configuration file with the corresponding provider detected
      # from the file extension
      #
      # @param [String] file The path of the config file to load
      # @return [Hash] The configuration values loaded from the file
      # @see YamlProvider
      def self.load_config(file)
        ext = File.extname(file)
        case ext
          when '.ini'
            IniProvider.load_config file
          when '.yaml', '.yml'
            YamlProvider.load_config file
          else
            raise UnsupportedConfigFormatError.new(ext)
        end
      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubikon-0.5.3 lib/rubikon/config/auto_provider.rb
rubikon-0.5.2 lib/rubikon/config/auto_provider.rb
rubikon-0.5.1 lib/rubikon/config/auto_provider.rb
rubikon-0.5.0 lib/rubikon/config/auto_provider.rb