Derelict
Provides a Ruby API to control Vagrant where Vagrant is installed
via the Installer package on Mac OS X.
Currently a work-in-progress.
Why?
Vagrant was historically available as a gem, naturally providing a
Ruby API to control Vagrant in other Ruby libraries and applications.
However, since version 1.1.0, Vagrant is distributed exclusively
using an Installer package. Derelict is a Ruby library that wraps
the Vagrant binary, shelling out and parsing the results of each
command.
Installation
Add this line to your application's Gemfile:
gem "derelict"
And then execute:
$ bundle
Or install it yourself as:
$ gem install derelict
Usage
Some examples of common operations using Derelict:
require "derelict"
Derelict.instance.connect("/path/to/project").vm(:default).exists?
Advanced
require "derelict"
instance = Derelict.instance("/path/to/vagrant")
instance = Derelict.instance
result = instance.execute('--version')
print "success" if result.success?
print result.stdout
connection = instance.connect("/path/to/project")
result = connection.execute(:up)
result.success?
vm = connection.vm(:web)
vm.exists?
vm.state
vm.running?
vm.up!
vm.halt!
vm.destroy!
vm.reload!
vm.suspend!
vm.resume!
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am "Add some feature"
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request