module Squall

Constants

VERSION

Attributes

configuration[RW]
configuration_file[RW]

Public Instance Methods

config() { |configuration| ... } click to toggle source

Public: Configures Squall.

Yields Squall.configuration if a block is given.

Example

Squall.config do |c|
  c.base_uri 'http://onapp.myserver.com'
  c.username 'myuser'
  c.password 'mypass'
  c.debug    true
end

Returns a Hash.

# File lib/squall.rb, line 56
def config
  yield self.configuration if block_given?
  self.configuration.config
end
config_file(file = File.expand_path("~/.squall.yml")) click to toggle source

Public: Load the config from a YAML file.

file - Path to the YAML file, defaults to `~/.squall.yml`

Raises ArgumentError if the config file does not exist.

Example

# Load default config file at `~/.squall.yml`:
Squall.config_file

# Load custom config file:
Squall.config_file '/path/to/squall.yml'

Returns nothing.

# File lib/squall.rb, line 76
def config_file(file = File.expand_path("~/.squall.yml"))
  if File.exists?(file)
    self.configuration_file = file
  else
    raise ArgumentError, "Config file doesn't exist '#{file}'"
  end

  config do |c|
    YAML::load_file(file).each { |k, v| c.send(k, v) }
  end
end
reset_config() click to toggle source

Public: Reset the config (aka, clear it)

Returns an instance of Squall::Config.

# File lib/squall.rb, line 91
def reset_config
  self.configuration = Squall::Config.new
end