Starting on the `vagrant gem` command.

This commit is contained in:
Mitchell Hashimoto 2012-02-06 22:13:19 -05:00
parent fd54cf0809
commit d19f7a44e5
4 changed files with 24 additions and 1 deletions

View File

@ -136,6 +136,7 @@ I18n.load_path << File.expand_path("templates/locales/en.yml", Vagrant.source_ro
# Register the built-in commands
Vagrant.commands.register(:box) { Vagrant::Command::Box }
Vagrant.commands.register(:destroy) { Vagrant::Command::Destroy }
Vagrant.commands.register(:gem) { Vagrant::Command::Gem }
Vagrant.commands.register(:halt) { Vagrant::Command::Halt }
Vagrant.commands.register(:init) { Vagrant::Command::Init }
Vagrant.commands.register(:package) { Vagrant::Command::Package }

View File

@ -8,6 +8,7 @@ module Vagrant
autoload :BoxRepackage, 'vagrant/command/box_repackage'
autoload :BoxList, 'vagrant/command/box_list'
autoload :Destroy, 'vagrant/command/destroy'
autoload :Gem, 'vagrant/command/gem'
autoload :Halt, 'vagrant/command/halt'
autoload :Init, 'vagrant/command/init'
autoload :Package, 'vagrant/command/package'

View File

@ -0,0 +1,17 @@
require "rubygems"
require "rubygems/gem_runner"
module Vagrant
module Command
class Gem < Base
def execute
# We just proxy the arguments onto a real RubyGems command
# but change `GEM_HOME` so that the gems are installed into
# our own private gem folder.
ENV["GEM_HOME"] = @env.gems_path.to_s
::Gem.clear_paths
::Gem::GemRunner.new.run(@argv.dup)
end
end
end
end

View File

@ -11,7 +11,7 @@ module Vagrant
# defined as basically a folder with a "Vagrantfile." This class allows
# access to the VMs, CLI, etc. all in the scope of this environment.
class Environment
HOME_SUBDIRS = ["tmp", "boxes"]
HOME_SUBDIRS = ["tmp", "boxes", "gems"]
DEFAULT_VM = :default
DEFAULT_HOME = "~/.vagrant.d"
@ -34,6 +34,9 @@ module Vagrant
# The directory where boxes are stored.
attr_reader :boxes_path
# The path where the plugins are stored (gems)
attr_reader :gems_path
# The path to the default private key
attr_reader :default_private_key_path
@ -80,6 +83,7 @@ module Vagrant
setup_home_path
@tmp_path = @home_path.join("tmp")
@boxes_path = @home_path.join("boxes")
@gems_path = @home_path.join("gems")
# Setup the default private key
@default_private_key_path = @home_path.join("insecure_private_key")