Module: Loquacious

### Home Classes Methods

### In Files

- lib/loquacious.rb
- lib/loquacious/configuration.rb
- lib/loquacious/undefined.rb

### Namespace

- CLASS Loquacious::Configuration
- CLASS Loquacious::Undefined

### Methods

- ::config
- ::config_for
- ::configuration
- ::configuration_for
- ::copy
- ::defaults
- ::defaults_for
- ::help
- ::help_for
- ::libpath
- ::path
- ::remove
- ::version

### Files

- History.txt
- README.rdoc

### Class/Module Index

Quicksearch

- Loquacious
- Loquacious::Configuration
- Loquacious::Configuration::DSL
- Loquacious::Configuration::Help
- Loquacious::Configuration::Iterator
- Loquacious::Undefined
- String

No matching classes.

# Loquacious

### Public Class Methods

config( name, &block ) click to toggle source
Alias for: configuration_for
config_for( name, &block ) click to toggle source
Alias for: configuration_for
configuration( name, &block ) click to toggle source
Alias for: configuration_for
configuration_for( name, &block ) click to toggle source

Returns the configuration associated with the given name. If a block is given, then it will be used to create the configuration.

The same name can be used multiple times with different configuration blocks. Each different block will be used to add to the configuration; i.e. the configurations are additive.

    # File lib/loquacious.rb, line 21
    def configuration_for( name, &block )
      ::Loquacious::Configuration.for(name, &block)
    end

Also aliased as: configuration, config_for, config
copy( config, &block ) click to toggle source

A helper method that will create a deep copy of a given Configuration object. This method accepts either a Configuration instance or a name that can be used to lookup the Configuration instance (via the "Loquacious.configuration_for" method).

    Loquacious.copy(config)
    Loquacious.copy('name')

Optionally a block can be given. It will be used to modify the returned copy with the given values. The Configuration object being copied is never modified by this method.

    Loquacious.copy(config) {
      foo 'bar'
      baz 'buz'
    }

    # File lib/loquacious.rb, line 128
    def copy( config, &block )
      config = Configuration.for(config) unless config.instance_of? Configuration
      return unless config

      rv = Configuration.new
      rv.merge!(config)

      # deep copy
      rv.__desc.each do |key,desc|
        value = rv.__send(key)
        next unless value.instance_of? Configuration
        rv.__send("#{key}=", ::Loquacious.copy(value))
      end

      rv.merge!(Configuration::DSL.evaluate(&block)) if block
      rv
    end

defaults( name, &block ) click to toggle source
Alias for: defaults_for
defaults_for( name, &block ) click to toggle source

Set the default properties for the configuration associated with the given name. A block must be provided to this method.

The same name can be used multiple times with different configuration blocks. Each block will add or modify the configuration; i.e. the configurations are additive.

    # File lib/loquacious.rb, line 35
    def defaults_for( name, &block )
      ::Loquacious::Configuration.defaults_for(name, &block)
    end

Also aliased as: defaults
help( name, opts = {} ) click to toggle source
Alias for: help_for
help_for( name, opts = {} ) click to toggle source

Returns a Help instance for the configuration associated with the given name. See the Help#initialize method for the options that can be used with this method.

    # File lib/loquacious.rb, line 44
    def help_for( name, opts = {} )
      ::Loquacious::Configuration.help_for(name, opts)
    end

Also aliased as: help
libpath( *args, &block ) click to toggle source

Returns the library path for the module. If any arguments are given, they will be joined to the end of the libray path using `File.join`.

    # File lib/loquacious.rb, line 59
    def libpath( *args, &block )
      rv =  args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
      if block
        begin
          $LOAD_PATH.unshift LIBPATH
          rv = block.call
        ensure
          $LOAD_PATH.shift
        end
      end
      return rv
    end

path( *args, &block ) click to toggle source

Returns the lpath for the module. If any arguments are given, they will be joined to the end of the path using `File.join`.

    # File lib/loquacious.rb, line 75
    def path( *args, &block )
      rv = args.empty? ? PATH : ::File.join(PATH, args.flatten)
      if block
        begin
          $LOAD_PATH.unshift PATH
          rv = block.call
        ensure
          $LOAD_PATH.shift
        end
      end
      return rv
    end

remove( *args ) click to toggle source

This is merely a convenience method to remove methods from the Loquacious::Configuration class. Some ruby gems add lots of crap to the Kernel module, and this interferes with the configuration system. The remove method should be used to anihilate unwanted methods from the configuration class as needed.

    Loquacious.remove :gem           # courtesy of rubygems
    Loquacious.remove :test, :file   # courtesy of rake
    Loquacious.remove :main          # courtesy of main
    Loquacious.remove :timeout       # courtesy of timeout

    # File lib/loquacious.rb, line 99
    def remove( *args )
      args.each { |name|
        name = name.to_s.delete('=')
        code =           undef_method :#{name} rescue nil          undef_method :#{name}= rescue nil
        Loquacious::Configuration.module_eval code
        Loquacious::Configuration::DSL.module_eval code
      }
    end

version() click to toggle source

Returns the version string for the library.

    # File lib/loquacious.rb, line 51
    def version
      @version ||= File.read(path('version.txt')).strip
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.