vagrant-scp 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/lib/vagrant/scp/commands/scp.rb +42 -31
- data/lib/vagrant/scp/version.rb +1 -1
- metadata +14 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9300b6362864078cc341ff6b5dc43b92b4e8c8ea
|
4
|
+
data.tar.gz: 2e0970ff029e60d36aa41a2f6a152f90de951411
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d64aa17b0df115359d9c6a30867d0dab9ba83e6f91fffbb0f5ae1b395cc276412b3c0353c5ef926d655ec4480d0150614abeaf316afb0284e8109391e7bd7452
|
7
|
+
data.tar.gz: b775d9b17a115fea49828f4692b5fff49983c56d8250cf14c016a5a32f47814020db1fecaa6a85768abd917a9f2dd738c964bc77064f79a03183e690f891ffa1
|
data/.gitignore
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'net/scp'
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module Scp
|
3
5
|
module Command
|
@@ -9,45 +11,28 @@ module VagrantPlugins
|
|
9
11
|
end
|
10
12
|
|
11
13
|
def execute
|
12
|
-
|
13
|
-
|
14
|
-
return if file_2.nil?
|
15
|
-
# Extract host info
|
16
|
-
# We want to get the name of the vm, from a [host_1]:file_1 [host_2]:file_2 description
|
17
|
-
host = [file_1, file_2].map{|file_spec| file_spec.match(/^([^:]*):/)[1] rescue nil}.compact.first
|
18
|
-
# The default machine name for Vagrant is 'default'
|
19
|
-
host = 'default' if (host.nil? || host == 0 )
|
14
|
+
@file_1, @file_2 = parse_args()
|
15
|
+
return if @file_2.nil?
|
20
16
|
|
21
|
-
# Get the info about the target VM
|
22
17
|
with_target_vms(host) do |machine|
|
23
|
-
ssh_info = machine.ssh_info
|
24
|
-
raise Vagrant::Errors::SSHNotReady if ssh_info.nil?
|
25
|
-
if file_1.include? ':'
|
26
|
-
source_files = "#{ssh_info[:username]}@#{ssh_info[:host]}:#{file_1.split(':').last}"
|
27
|
-
target_files = file_2
|
28
|
-
else
|
29
|
-
source_files = file_1
|
30
|
-
target_files = "#{ssh_info[:username]}@#{ssh_info[:host]}:#{file_2.split(':').last}"
|
31
|
-
end
|
18
|
+
@ssh_info = machine.ssh_info
|
19
|
+
raise Vagrant::Errors::SSHNotReady if @ssh_info.nil?
|
32
20
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
"-i '#{ssh_info[:private_key_path][0]}'",
|
41
|
-
source_files,
|
42
|
-
target_files
|
43
|
-
].join(' ')
|
44
|
-
system(command)
|
21
|
+
Net::SCP.send net_ssh_command,
|
22
|
+
@ssh_info[:host],
|
23
|
+
@ssh_info[:username],
|
24
|
+
source_files,
|
25
|
+
target_files,
|
26
|
+
:recursive => true,
|
27
|
+
:ssh => {:port => @ssh_info[:port], :keys => @ssh_info[:private_key_path]}
|
45
28
|
end
|
46
29
|
end
|
47
30
|
|
31
|
+
private
|
32
|
+
|
48
33
|
def parse_args
|
49
34
|
opts = OptionParser.new do |o|
|
50
|
-
o.banner =
|
35
|
+
o.banner = "Usage: vagrant scp <local_path> [vm_name]:<remote_path> \n"
|
51
36
|
o.banner += " vagrant scp [vm_name]:<remote_path> <local_path>"
|
52
37
|
o.separator ""
|
53
38
|
o.separator "Options:"
|
@@ -59,6 +44,32 @@ module VagrantPlugins
|
|
59
44
|
return nil, nil
|
60
45
|
end
|
61
46
|
|
47
|
+
def host
|
48
|
+
host = [@file_1, @file_2].map{|file_spec| file_spec.match(/^([^:]*):/)[1] rescue nil}.compact.first
|
49
|
+
host = 'default' if (host.nil? || host == 0 )
|
50
|
+
host
|
51
|
+
end
|
52
|
+
|
53
|
+
def net_ssh_command
|
54
|
+
@file_1.include?(':') ? :download! : :upload!
|
55
|
+
end
|
56
|
+
|
57
|
+
def source_files
|
58
|
+
format_file_path(@file_1)
|
59
|
+
end
|
60
|
+
|
61
|
+
def target_files
|
62
|
+
format_file_path(@file_2)
|
63
|
+
end
|
64
|
+
|
65
|
+
def format_file_path(filepath)
|
66
|
+
if @file_1.include?(':')
|
67
|
+
filepath.split(':').last.gsub("~", "/home/#{@ssh_info[:username]}")
|
68
|
+
else
|
69
|
+
filepath
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
62
73
|
end
|
63
74
|
|
64
75
|
end
|
data/lib/vagrant/scp/version.rb
CHANGED
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-scp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Invernizzi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: log4r
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: net-scp
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.1'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.1'
|
69
69
|
description: Copy files to a Vagrant VM via SCP.
|
@@ -73,7 +73,7 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- .gitignore
|
76
|
+
- ".gitignore"
|
77
77
|
- Gemfile
|
78
78
|
- LICENSE.txt
|
79
79
|
- README.md
|
@@ -94,19 +94,18 @@ require_paths:
|
|
94
94
|
- lib
|
95
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
|
-
- -
|
97
|
+
- - ">="
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.4.6
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Copy files to a Vagrant VM via SCP.
|
111
111
|
test_files: []
|
112
|
-
has_rdoc:
|