vagrant-host-path 1.0.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MDUzNjNmYzBmNzg3YjQ1MjBkNDAxZTI5Nzc3N2IwMWU5MDU5ZmE4ZQ==
5
+ data.tar.gz: !binary |-
6
+ NzMxN2I4MzBmYzMxZTQ0ZDMxZGY4ZDUwMmNlOGIzMzE5ZGZhNTdkNQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MmFlYTFkNWExMGM3MjFlMDk0NTYzYTc2M2YxNjJkNzIwYmIyNTZmMzYxOWE3
10
+ ZjNhNDM0NWExZmQ4ZjJkZjgwODYxYzhiYTVkMGVmMmZkMDdiNDY3MTJiNzY4
11
+ NzExMjQ4NjMzYjJjOGY2ZDA4MGNlYWMxYjQxYmEyYzkyNzA1NGQ=
12
+ data.tar.gz: !binary |-
13
+ NWU4ZjhlNzdhM2M0ZjdlNjBlZWJiNTQ3MjM2ZmIxOGUxZWVmNDNiOWRkNjNj
14
+ YTkwMTljNzg2ZDJmMTQ0YjNlYjZkY2U5YmM5YjZjOWRhNDFmOTEyYWNiYWM3
15
+ ZmQ3YzIwYWVmZDYwYTA0OTEwNDNmZjkyZjRlOTljOGUzYjU5MWM=
data/Gemfile CHANGED
@@ -1,4 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in vagrant-host-path.gemspec
4
3
  gemspec
4
+
5
+ group :development do
6
+ # We depend on Vagrant for development, but we don't add it as a
7
+ # gem dependency because we expect to be installed within the
8
+ # Vagrant environment itself using `vagrant plugin`.
9
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => "v1.2.7"
10
+ end
data/LICENSE.txt CHANGED
@@ -1,22 +1,22 @@
1
- Copyright (c) 2013 MOZGIII
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2013 MOZGIII
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Vagrant::HostPath
1
+ # Vagrant Host Path
2
2
 
3
3
  This plugin creates an environment variable (`VAGRANT_HOST_PATH` by default) with the path to the project's root dir on your host machine.
4
4
  You can just replace `/vagrant` prefix of any file in your VM with the value of `VAGRANT_HOST_PATH` and you'll get the path to that same file on the host.
@@ -38,13 +38,13 @@ And after that you can use the env var within your VM:
38
38
  Vagrant::Config.run do |config|
39
39
 
40
40
  # The environment key to set
41
- config.host-path.env_key = "VAGRANT_HOST_PATH"
41
+ config.host_path.env_key = "VAGRANT_HOST_PATH"
42
42
 
43
43
  # Temp file to save path to
44
- config.host-path.path_file = "/tmp/.vagrant-host-path"
44
+ config.host_path.path_file = "/tmp/.vagrant-host-path"
45
45
 
46
46
  # Profile script path
47
- config.host-path.profile_path = "/etc/profile.d/vagrant-host-path.sh"
47
+ config.host_path.profile_path = "/etc/profile.d/vagrant-host-path.sh"
48
48
  end
49
49
  ```
50
50
 
@@ -1,25 +1,38 @@
1
- module Vagrant
1
+ module VagrantPlugins
2
2
  module HostPath
3
- class Config < Vagrant::Config::Base
4
- attr_writer :env_key
5
- attr_writer :path_file
6
- attr_writer :profile_path
7
- attr_writer :temp_upload_path
3
+ class Config < Vagrant.plugin(2, :config)
4
+ # The name of environment variable to set.
5
+ #
6
+ # @return [String]
7
+ attr_accessor :env_key
8
8
 
9
- def env_key
10
- @env_key || "VAGRANT_HOST_PATH"
11
- end
9
+ # The path to the tmp file used to store the actual host path.
10
+ #
11
+ # @return [String]
12
+ attr_accessor :path_file
12
13
 
13
- def path_file
14
- @path_file || "/tmp/.vagrant-host-path"
15
- end
14
+ # The path to a profile file (typically inside of a /etc/profile.d/ dir).
15
+ #
16
+ # @return [String]
17
+ attr_accessor :profile_path
16
18
 
17
- def profile_path
18
- @profile_path || "/etc/profile.d/vagrant-host-path.sh"
19
+ # The path to the tmp file used to upload profile path.
20
+ #
21
+ # @return [String]
22
+ attr_accessor :temp_upload_path
23
+
24
+ def initialize
25
+ @env_key = UNSET_VALUE
26
+ @path_file = UNSET_VALUE
27
+ @profile_path = UNSET_VALUE
28
+ @temp_upload_path = UNSET_VALUE
19
29
  end
20
-
21
- def temp_upload_path
22
- @temp_upload_path || "/tmp/vagrant-host-path-profile.sh"
30
+
31
+ def finalize!
32
+ @env_key = "VAGRANT_HOST_PATH" if @env_key == UNSET_VALUE
33
+ @path_file = "/tmp/.vagrant-host-path" if @path_file == UNSET_VALUE
34
+ @profile_path = "/etc/profile.d/vagrant-host-path.sh" if @profile_path == UNSET_VALUE
35
+ @temp_upload_path = "/tmp/vagrant-host-path-profile.sh" if @temp_upload_path == UNSET_VALUE
23
36
  end
24
37
  end
25
38
  end
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module HostPath
3
+ module Logic
4
+ def put_path_file(config, cwd)
5
+ sudo("echo \"#{cwd.to_s}\" > \"#{config.path_file}\"")
6
+ end
7
+
8
+ def put_profile_file(config)
9
+ sudo("echo \"#{escape_shell(profile_file(config))}\" > \"#{config.profile_path}\"")
10
+ end
11
+
12
+ def profile_file(config)
13
+ "[ -f \"#{config.path_file}\" ] && export #{config.env_key}=\`cat \"#{config.path_file}\"\`"
14
+ end
15
+
16
+ def escape_shell(content)
17
+ content.gsub(/["`\\]/, '\\\\\0')
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,34 +1,34 @@
1
- module Vagrant
1
+ require "vagrant-host-path/logic"
2
+
3
+ module VagrantPlugins
2
4
  module HostPath
3
5
  class Middleware
6
+ include Logic
7
+
4
8
  def initialize(app, env)
5
9
  @app = app
6
10
  end
7
11
 
8
12
  def call(env)
9
- setup env[:vm] if env[:vm].state == :running
13
+ @machine = env[:machine]
14
+ setup
10
15
  @app.call(env)
11
16
  end
12
17
 
13
18
  protected
14
19
 
15
- def setup(vm)
16
- put_path_file(vm)
17
- put_profile_file(vm)
18
- vm.ui.success "Host Path set!"
19
- end
20
-
21
- def put_path_file(vm)
22
- vm.channel.sudo("echo \"#{vm.env.cwd.to_s}\" > \"#{vm.config.host_path.path_file}\"")
20
+ def sudo(command)
21
+ @machine.communicate.sudo(command)
23
22
  end
24
23
 
25
- def put_profile_file(vm)
26
- content = profile_file(vm.config.host_path)
27
- vm.channel.sudo("echo \"#{content.gsub(/["`\\]/, '\\\\\0')}\" > \"#{vm.config.host_path.profile_path}\"")
24
+ def config
25
+ @machine.config.host_path
28
26
  end
29
27
 
30
- def profile_file(config)
31
- "[ -f \"#{config.path_file}\" ] && export #{config.env_key}=\`cat \"#{config.path_file}\"\`"
28
+ def setup
29
+ put_path_file(config, @machine.env.cwd)
30
+ put_profile_file(config)
31
+ @machine.ui.success "Host Path set!"
32
32
  end
33
33
  end
34
34
  end
@@ -0,0 +1,38 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "This Vagrant plugin must be run within Vagrant."
5
+ end
6
+
7
+ # This is a sanity check to make sure no one is attempting to install
8
+ # this into an early Vagrant version.
9
+ if Vagrant::VERSION < "1.2.0"
10
+ raise "This Vagrant plugin is only compatible with Vagrant 1.2+"
11
+ end
12
+
13
+ module VagrantPlugins
14
+ module HostPath
15
+ class Plugin < Vagrant.plugin("2")
16
+ name "HostPath"
17
+ description <<-DESC
18
+ This plugin adds path to /vagrant dir as it is on the host to
19
+ the VM environment.
20
+ DESC
21
+
22
+ config(:host_path) do
23
+ require_relative "config"
24
+ Config
25
+ end
26
+
27
+ action_hook(:set_host_path_on_up, :machine_action_up) do |hook|
28
+ require_relative "middleware"
29
+ hook.append(Middleware)
30
+ end
31
+
32
+ action_hook(:set_host_path_on_reload, :machine_action_reload) do |hook|
33
+ require_relative "middleware"
34
+ hook.append(Middleware)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,5 +1,5 @@
1
- module Vagrant
1
+ module VagrantPlugins
2
2
  module HostPath
3
- VERSION = "1.0.1"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -1,6 +1,2 @@
1
1
  require "vagrant-host-path/version"
2
- require "vagrant-host-path/config"
3
- require "vagrant-host-path/middleware"
4
-
5
- Vagrant.config_keys.register(:host_path) { Vagrant::HostPath::Config }
6
- Vagrant.actions[:start].use Vagrant::HostPath::Middleware
2
+ require "vagrant-host-path/plugin"
@@ -1,21 +1,23 @@
1
- # -*- encoding: utf-8 -*-
1
+ # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'vagrant-host-path/version'
5
5
 
6
- Gem::Specification.new do |gem|
7
- gem.name = "vagrant-host-path"
8
- gem.version = Vagrant::HostPath::VERSION
9
- gem.authors = ["MOZGIII"]
10
- gem.email = ["mike-n@narod.ru"]
11
- gem.description = %q{Vagrant plugin that stores the host path to your project in the environment variable in the VM.}
12
- gem.summary = %q{The host path to your project in the environment variable in the VM for Vagrant.}
13
- gem.homepage = "https://github.com/MOZGIII/vagrant-host-path"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-host-path"
8
+ spec.version = VagrantPlugins::HostPath::VERSION
9
+ spec.authors = ["MOZGIII"]
10
+ spec.email = ["mike-n@narod.ru"]
11
+ spec.description = %q{Vagrant plugin that stores the host path to your project in the environment variable in the VM.}
12
+ spec.summary = %q{The host path to your project in the environment variable in the VM for Vagrant.}
13
+ spec.homepage = "https://github.com/MOZGIII/vagrant-host-path"
14
+ spec.license = "MIT"
14
15
 
15
- gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
- gem.require_paths = ["lib"]
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
19
20
 
20
- gem.add_dependency "vagrant", "~> 1.0.7"
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
21
23
  end
metadata CHANGED
@@ -1,32 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-host-path
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - MOZGIII
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-07 00:00:00.000000000 Z
11
+ date: 2013-09-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: vagrant
14
+ name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 1.0.7
22
- type: :runtime
19
+ version: '1.3'
20
+ type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 1.0.7
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
30
41
  description: Vagrant plugin that stores the host path to your project in the environment
31
42
  variable in the VM.
32
43
  email:
@@ -42,33 +53,34 @@ files:
42
53
  - Rakefile
43
54
  - lib/vagrant-host-path.rb
44
55
  - lib/vagrant-host-path/config.rb
56
+ - lib/vagrant-host-path/logic.rb
45
57
  - lib/vagrant-host-path/middleware.rb
58
+ - lib/vagrant-host-path/plugin.rb
46
59
  - lib/vagrant-host-path/version.rb
47
- - lib/vagrant_init.rb
48
60
  - vagrant-host-path.gemspec
49
61
  homepage: https://github.com/MOZGIII/vagrant-host-path
50
- licenses: []
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
51
65
  post_install_message:
52
66
  rdoc_options: []
53
67
  require_paths:
54
68
  - lib
55
69
  required_ruby_version: !ruby/object:Gem::Requirement
56
- none: false
57
70
  requirements:
58
71
  - - ! '>='
59
72
  - !ruby/object:Gem::Version
60
73
  version: '0'
61
74
  required_rubygems_version: !ruby/object:Gem::Requirement
62
- none: false
63
75
  requirements:
64
76
  - - ! '>='
65
77
  - !ruby/object:Gem::Version
66
78
  version: '0'
67
79
  requirements: []
68
80
  rubyforge_project:
69
- rubygems_version: 1.8.24
81
+ rubygems_version: 2.0.7
70
82
  signing_key:
71
- specification_version: 3
83
+ specification_version: 4
72
84
  summary: The host path to your project in the environment variable in the VM for Vagrant.
73
85
  test_files: []
74
86
  has_rdoc:
data/lib/vagrant_init.rb DELETED
@@ -1 +0,0 @@
1
- require "vagrant-host-path"