Module: VirtualBox
- Defined in:
- lib/virtual_box.rb,
lib/virtual_box/vm.rb,
lib/virtual_box/cli.rb,
lib/virtual_box/net.rb,
lib/virtual_box/dhcp.rb,
lib/virtual_box/vm/nic.rb,
lib/virtual_box/version.rb,
lib/virtual_box/vm/disk.rb,
lib/virtual_box/vm/board.rb,
lib/virtual_box/vm/io_bus.rb
Overview
VirtualBox version detection.
Defined Under Namespace
Class Method Summary collapse
-
.ose? ⇒ Boolean
True if the installed VirtualBox is the open-source edition.
-
.reset_version_info! ⇒ NilObject
Removes the cached information on the VirtualBox package version.
-
.run_command(args) ⇒ Hashie::Mash<Symbol, String>
Runs a command in a sub-shell, waiting until the command completes.
-
.version ⇒ Hash<Symbol, Object>, Boolean
Version information about the VirtualBox package installed on this machine.
Class Method Details
.ose? ⇒ Boolean
True if the installed VirtualBox is the open-source edition.
The open-source edition of VirtualBox has some limitations, such as no support for RDP and USB devices.
10 11 12 13 14 15 |
# File 'lib/virtual_box/version.rb', line 10 def self.ose? unless version.edition raise 'VirtualBox is not installed on this machine.' end version.edition == 'OSE' end |
.reset_version_info! ⇒ NilObject
Removes the cached information on the VirtualBox package version.
56 57 58 |
# File 'lib/virtual_box/version.rb', line 56 def self.reset_version_info! @version_info = nil end |
.run_command(args) ⇒ Hashie::Mash<Symbol, String>
Runs a command in a sub-shell, waiting until the command completes.
15 16 17 18 |
# File 'lib/virtual_box/cli.rb', line 15 def self.run_command(args) output = Kernel.`(Shellwords.shelljoin(args)) Hashie::Mash.new :status => $CHILD_STATUS.exitstatus, :output => output end |
.version ⇒ Hash<Symbol, Object>, Boolean
Version information about the VirtualBox package installed on this machine.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/virtual_box/version.rb', line 25 def self.version return @version_info unless @version_info.nil? cmd_result = run_command ['VBoxManage', '--version'] if cmd_result.status != 0 @version_info = Hashie::Mash.new return @version_info end output = cmd_result.output.strip if revision_offset = output.rindex('r') revision = output[revision_offset + 1, output.length].to_i output.slice! revision_offset..-1 else revision = nil end if edition_offset = output.rindex('_') edition = output[edition_offset + 1, output.length] output.slice! edition_offset..-1 else edition = '' end @version_info = Hashie::Mash.new :release => output, :svn => revision, :edition => edition end |