Class: Fission::Config

Inherits:
Object show all
Defined in:
lib/fission/config.rb,
lib/fission.old/config.rb

Constant Summary collapse

CONF_FILE =

Public: Path to the Fission conf file (default: ~/.fissionrc).

File.expand_path '~/.fissionrc'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Public: Initializes a Config object. This also sets the default config attributes for 'vmrun_bin', 'vmrun_cmd', 'vm_dir', 'plist_file', and 'gui_bin'.

Examples

Fission::Config.new

Returns a new Config instance.


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fission/config.rb', line 19

def initialize
  @attributes = {}

  @attributes['vm_dir'] = File.expand_path('~/Documents/Virtual Machines.localized/')
  @attributes['lease_file'] = '/var/db/vmware/vmnet-dhcpd-vmnet8.leases'

  fusion_version = :unknown

  @attributes['vmrun_bin'] = %w{
    /Library/Application Support/VMware Fusion/vmrun
    /Applications/VMware Fusion.app/Contents/Library/vmrun
    /usr/local/bin/vmrun
  }.find { |path| File.exists?(path) }

  if fusion_version == :unknown
  end

  @attributes['plist_file'] = File.expand_path('~/Library/Preferences/com.vmware.fusion.plist')
  @attributes['gui_bin'] = File.expand_path('/Applications/VMware Fusion.app/Contents/MacOS/vmware')

  load_from_file

  @attributes['vmrun_cmd'] = "#{@attributes['vmrun_bin'].gsub(' ', '\ ')} -T fusion"
end

Instance Attribute Details

#attributesObject

Public: Gets/Sets the Hash of attributes.


5
6
7
# File 'lib/fission/config.rb', line 5

def attributes
  @attributes
end

Instance Method Details

#[](item) ⇒ Object

Public: Helper method to access config atributes. This is a shortcut for querying the config attributes.

item - The config item to query.

Examples

Fission.config['vmrun_bin']
# => '/foo/bar/vmrun'

Returns the value of the specified config item.


55
56
57
# File 'lib/fission/config.rb', line 55

def [](item)
  @attributes[item]
end