Sha256: e07eae457e6cc7ab1dbe57b17cbb96027b474b0d088e7078103d43e2d29cfb99

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

require 'yaml'

module CLIUtils
  #  ======================================================
  #  Configuration Class
  #
  #  Manages any configuration values and the flat YAML file
  #  into which they get stored.
  #  ======================================================
  module Configuration
    #  ====================================================
    #  Methods
    #  ====================================================
    #  ----------------------------------------------------
    #  included method
    #
    #  Hook called when this module gets mixed in; extends
    #  the includer with the methods defined here.
    #  @param k The includer
    #  @return Void
    #  ----------------------------------------------------
    def self.included(k)
      k.extend(self)
    end

    #  ----------------------------------------------------
    #  configuration method
    #
    #  Singleton method to return (or initialize, if needed)
    #  a Configurator.
    #  @return Configurator
    #  ----------------------------------------------------
    def configuration
      @configuration ||= Configurator.new('~/.default-cliutils')
    end

    #  ----------------------------------------------------
    #  load_configuration method
    #
    #  Initializes a Configurator with the passed filepath.
    #  @param path The path to the config file
    #  @return Void
    #  ----------------------------------------------------
    def load_configuration(path)
      @configuration = Configurator.new(path)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cliutils-1.0.2 lib/cliutils/configuration.rb
cliutils-1.0.1 lib/cliutils/configuration.rb
cliutils-1.0.0 lib/cliutils/configuration.rb