Module: VirtualBox

Defined in:
lib/fog/bin/virtual_box.rb

Overview

deviates from other bin stuff to accomodate gem

Class Method Summary collapse

Class Method Details

.[](service) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/bin/virtual_box.rb', line 13

def [](service)
  @@connections ||= Hash.new do |hash, key|
    hash[key] = case key
    when :compute
      Formatador.display_line("[yellow][WARN] VirtualBox[:compute] is deprecated, use Compute[:virtualbox] instead[/]")
      Fog::Compute.new(:provider => 'VirtualBox')
    else
      raise ArgumentError, "Unrecognized service: #{key.inspect}"
    end
  end
  @@connections[service]
end

.available?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fog/bin/virtual_box.rb', line 26

def available?
  availability = if Gem::Specification.respond_to?(:find_all_by_name)
    !Gem::Specification.find_all_by_name('virtualbox').empty? # newest rubygems
  else
    !Gem.source_index.find_name('virtualbox').empty? # legacy
  end
  if availability
    for service in services
      for collection in self.class_for(service).collections
        unless self.respond_to?(collection)
          self.class_eval <<-EOS, __FILE__, __LINE__
            def self.#{collection}
              self[:#{service}].#{collection}
            end
          EOS
        end
      end
    end
  end
  availability
end

.class_for(key) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/fog/bin/virtual_box.rb', line 4

def class_for(key)
  case key
  when :compute
    Fog::Compute::VirtualBox
  else
    raise ArgumentError, "Unrecognized service: #{key}"
  end
end

.collectionsObject



48
49
50
# File 'lib/fog/bin/virtual_box.rb', line 48

def collections
  services.map {|service| self[service].collections}.flatten.sort_by {|service| service.to_s}
end

.servicesObject



52
53
54
# File 'lib/fog/bin/virtual_box.rb', line 52

def services
  Fog::VirtualBox.services
end