Module: Squall

Extended by:
Squall
Included in:
Squall
Defined in:
lib/squall.rb,
lib/squall/disk.rb,
lib/squall/user.rb,
lib/squall/role.rb,
lib/squall/payment.rb,
lib/squall/network.rb,
lib/squall/template.rb,
lib/squall/whitelist.rb,
lib/squall/statistic.rb,
lib/squall/user_group.rb,
lib/squall/hypervisor.rb,
lib/squall/ip_address.rb,
lib/squall/transaction.rb,
lib/squall/support/base.rb,
lib/squall/network_zone.rb,
lib/squall/firewall_rule.rb,
lib/squall/support/config.rb,
lib/squall/hypervisor_zone.rb,
lib/squall/support/version.rb,
lib/squall/data_store_zone.rb,
lib/squall/ip_address_join.rb,
lib/squall/virtual_machine.rb,
lib/squall/support/exception.rb

Defined Under Namespace

Classes: Base, Config, DataStoreZone, Disk, FirewallRule, Hypervisor, HypervisorZone, IpAddress, IpAddressJoin, Network, NetworkZone, NoConfig, Payment, Role, Statistic, Template, Transaction, User, UserGroup, VirtualMachine, Whitelist

Constant Summary

VERSION =
'1.3.0'

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) configuration

Config



35
36
37
# File 'lib/squall.rb', line 35

def configuration
  @configuration
end

- (Object) configuration_file

Config



38
39
40
# File 'lib/squall.rb', line 38

def configuration_file
  @configuration_file
end

Instance Method Details

- (Object) config { ... }

Configures Squall.

Examples:

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

Yields:

  • Yields Squall.configuration if a block is given.

Returns:

  • a Hash.



56
57
58
59
# File 'lib/squall.rb', line 56

def config
  yield self.configuration if block_given?
  self.configuration.config
end

- (void) config_file(file = File.expand_path("~/.squall.yml"))

This method returns an undefined value.

Load the config from a YAML file.

Examples:

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

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

Parameters:

  • file (defaults to: File.expand_path("~/.squall.yml"))

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

Raises:

  • ArgumentError if the config file does not exist.



76
77
78
79
80
81
82
83
84
85
86
# 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

- (Object) reset_config

Reset the config (aka, clear it)

Returns:

  • an instance of Squall::Config.



91
92
93
# File 'lib/squall.rb', line 91

def reset_config
  self.configuration = Squall::Config.new
end