Get rid of the PROJECT_ROOT constant.
This commit is contained in:
parent
d3f7fe267a
commit
cd82c8d7f8
|
@ -11,7 +11,7 @@ Vagrant::Config.run do |config|
|
||||||
config.ssh.forwarded_port_key = "ssh"
|
config.ssh.forwarded_port_key = "ssh"
|
||||||
config.ssh.max_tries = 10
|
config.ssh.max_tries = 10
|
||||||
config.ssh.timeout = 30
|
config.ssh.timeout = 30
|
||||||
config.ssh.private_key_path = File.join(PROJECT_ROOT, 'keys', 'vagrant')
|
config.ssh.private_key_path = File.expand_path("keys/vagrant", Vagrant.source_root)
|
||||||
config.ssh.forward_agent = false
|
config.ssh.forward_agent = false
|
||||||
|
|
||||||
config.vm.auto_port_range = (2200..2250)
|
config.vm.auto_port_range = (2200..2250)
|
||||||
|
|
|
@ -1,16 +1,24 @@
|
||||||
libdir = File.join(File.dirname(__FILE__), "vagrant")
|
|
||||||
PROJECT_ROOT = File.join(libdir, '..', "..") unless defined?(PROJECT_ROOT)
|
|
||||||
|
|
||||||
# First, load the various libs which Vagrant requires
|
# First, load the various libs which Vagrant requires
|
||||||
%w{tempfile json pathname logger virtualbox net/ssh archive/tar/minitar
|
%w{tempfile json pathname logger virtualbox net/ssh archive/tar/minitar
|
||||||
net/scp fileutils mario}.each do |lib|
|
net/scp fileutils mario}.each do |lib|
|
||||||
require lib
|
require lib
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module Vagrant
|
||||||
|
class << self
|
||||||
|
# The source root is the path to the root directory of
|
||||||
|
# the Vagrant gem.
|
||||||
|
def source_root
|
||||||
|
File.expand_path('../../', __FILE__)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Then load the glob loader, which will handle loading everything else
|
# Then load the glob loader, which will handle loading everything else
|
||||||
require File.expand_path("util/glob_loader", libdir)
|
require "vagrant/util/glob_loader"
|
||||||
|
|
||||||
# Load them up
|
# Load them up
|
||||||
|
libdir = File.expand_path("lib/vagrant", Vagrant.source_root)
|
||||||
Vagrant::GlobLoader.glob_require(libdir, %w{util util/stacked_proc_runner
|
Vagrant::GlobLoader.glob_require(libdir, %w{util util/stacked_proc_runner
|
||||||
downloaders/base config provisioners/base provisioners/chef systems/base
|
downloaders/base config provisioners/base provisioners/chef systems/base
|
||||||
commands/base commands/box action/exception_catcher hosts/base})
|
commands/base commands/box action/exception_catcher hosts/base})
|
||||||
|
|
|
@ -174,7 +174,7 @@ module Vagrant
|
||||||
# to load the Vagrantfile into that context.
|
# to load the Vagrantfile into that context.
|
||||||
def load_config!
|
def load_config!
|
||||||
# Prepare load paths for config files and append to config queue
|
# Prepare load paths for config files and append to config queue
|
||||||
config_queue = [File.join(PROJECT_ROOT, "config", "default.rb")]
|
config_queue = [File.expand_path("config/default.rb", Vagrant.source_root)]
|
||||||
config_queue << File.join(box.directory, ROOTFILE_NAME) if box
|
config_queue << File.join(box.directory, ROOTFILE_NAME) if box
|
||||||
config_queue << File.join(home_path, ROOTFILE_NAME) if home_path
|
config_queue << File.join(home_path, ROOTFILE_NAME) if home_path
|
||||||
config_queue << File.join(root_path, ROOTFILE_NAME) if root_path
|
config_queue << File.join(root_path, ROOTFILE_NAME) if root_path
|
||||||
|
|
|
@ -76,7 +76,7 @@ module Vagrant
|
||||||
#
|
#
|
||||||
# @return [String]
|
# @return [String]
|
||||||
def full_template_path
|
def full_template_path
|
||||||
File.join(PROJECT_ROOT, 'templates', "#{template}.erb").squeeze("/")
|
File.join(Vagrant.source_root, 'templates', "#{template}.erb").squeeze("/")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@ module Vagrant
|
||||||
#
|
#
|
||||||
# @return [Hash]
|
# @return [Hash]
|
||||||
def strings
|
def strings
|
||||||
@@strings ||= YAML.load_file(File.join(PROJECT_ROOT, "templates", "strings.yml"))
|
@@strings ||= YAML.load_file(File.join(Vagrant.source_root, "templates", "strings.yml"))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders the string with the given key and data parameters and returns
|
# Renders the string with the given key and data parameters and returns
|
||||||
|
|
|
@ -314,7 +314,7 @@ class EnvironmentTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "load from the project root" do
|
should "load from the project root" do
|
||||||
File.expects(:exist?).with(File.join(PROJECT_ROOT, "config", "default.rb")).once
|
File.expects(:exist?).with(File.join(Vagrant.source_root, "config", "default.rb")).once
|
||||||
@env.load_config!
|
@env.load_config!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -73,13 +73,13 @@ class TemplateRendererUtilTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "be the ERB file in the templates directory" do
|
should "be the ERB file in the templates directory" do
|
||||||
result = File.join(PROJECT_ROOT, "templates", "#{@template}.erb")
|
result = File.join(Vagrant.source_root, "templates", "#{@template}.erb")
|
||||||
assert_equal result, @r.full_template_path
|
assert_equal result, @r.full_template_path
|
||||||
end
|
end
|
||||||
|
|
||||||
should "remove duplicate path separators" do
|
should "remove duplicate path separators" do
|
||||||
@r.template = "foo///bar"
|
@r.template = "foo///bar"
|
||||||
result = File.join(PROJECT_ROOT, "templates", "foo", "bar.erb")
|
result = File.join(Vagrant.source_root, "templates", "foo", "bar.erb")
|
||||||
assert_equal result, @r.full_template_path
|
assert_equal result, @r.full_template_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ class TranslatorUtilTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "load the file initially, then never again unless reset" do
|
should "load the file initially, then never again unless reset" do
|
||||||
YAML.expects(:load_file).with(File.join(PROJECT_ROOT, "templates", "strings.yml")).once
|
YAML.expects(:load_file).with(File.join(Vagrant.source_root, "templates", "strings.yml")).once
|
||||||
@klass.strings
|
@klass.strings
|
||||||
@klass.strings
|
@klass.strings
|
||||||
@klass.strings
|
@klass.strings
|
||||||
|
@ -22,7 +22,7 @@ class TranslatorUtilTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "reload if reset! is called" do
|
should "reload if reset! is called" do
|
||||||
YAML.expects(:load_file).with(File.join(PROJECT_ROOT, "templates", "strings.yml")).twice
|
YAML.expects(:load_file).with(File.join(Vagrant.source_root, "templates", "strings.yml")).twice
|
||||||
@klass.strings
|
@klass.strings
|
||||||
@klass.reset!
|
@klass.reset!
|
||||||
@klass.strings
|
@klass.strings
|
||||||
|
|
Loading…
Reference in New Issue