From 646f0fa907842df77496ba85b9fe98afd97f893b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 16 Apr 2014 09:29:13 -0700 Subject: [PATCH] core: MachineIndex preserves the local data path for an env --- lib/vagrant/machine_index.rb | 16 ++++++++++++++-- test/unit/vagrant/machine_index_test.rb | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/machine_index.rb b/lib/vagrant/machine_index.rb index 02090210d..f81d606f3 100644 --- a/lib/vagrant/machine_index.rb +++ b/lib/vagrant/machine_index.rb @@ -332,6 +332,11 @@ module Vagrant # @return [String] attr_reader :id + # The path for the "local data" directory for the environment. + # + # @return [Pathname] + attr_accessor :local_data_path + # The name of the machine. # # @return [String] @@ -377,14 +382,19 @@ module Vagrant return if !raw @id = id + @local_data_path = raw["local_data_path"] @name = raw["name"] @provider = raw["provider"] @state = raw["state"] @vagrantfile_name = raw["vagrantfile_name"] - @vagrantfile_path = Pathname.new(raw["vagrantfile_path"]) + @vagrantfile_path = raw["vagrantfile_path"] # TODO(mitchellh): parse into a proper datetime @updated_at = raw["updated_at"] @extra_data = raw["extra_data"] || {} + + # Convert to proper types + @local_data_path = Pathname.new(@local_data_path) if @local_data_path + @vagrantfile_path = Pathname.new(@vagrantfile_path) if @vagrantfile_path end # Creates a {Vagrant::Environment} for this entry. @@ -395,6 +405,7 @@ module Vagrant Environment.new({ cwd: @vagrantfile_path, home_path: home_path, + local_data_path: @local_data_path, vagrantfile_name: @vagrantfile_name, }.merge(opts)) end @@ -403,11 +414,12 @@ module Vagrant # Converts to the structure used by the JSON def to_json_struct { + "local_data_path" => @local_data_path.to_s, "name" => @name, "provider" => @provider, "state" => @state, "vagrantfile_name" => @vagrantfile_name, - "vagrantfile_path" => @vagrantfile_path, + "vagrantfile_path" => @vagrantfile_path.to_s, "updated_at" => @updated_at, "extra_data" => @extra_data, } diff --git a/test/unit/vagrant/machine_index_test.rb b/test/unit/vagrant/machine_index_test.rb index 69a753052..6a7efaa72 100644 --- a/test/unit/vagrant/machine_index_test.rb +++ b/test/unit/vagrant/machine_index_test.rb @@ -76,6 +76,7 @@ describe Vagrant::MachineIndex do "bar" => { "name" => "default", "provider" => "vmware", + "local_data_path" => "/foo", "vagrantfile_path" => "/foo/bar/baz", "state" => "running", "updated_at" => "foo", @@ -108,6 +109,7 @@ describe Vagrant::MachineIndex do expect(result.id).to eq("bar") expect(result.name).to eq("default") expect(result.provider).to eq("vmware") + expect(result.local_data_path).to eq(Pathname.new("/foo")) expect(result.vagrantfile_path).to eq(Pathname.new("/foo/bar/baz")) expect(result.state).to eq("running") expect(result.updated_at).to eq("foo")