vgrnt 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +10 -0
- data/docs/DEVNOTES.md +2 -3
- data/lib/vgrnt/base.rb +13 -33
- data/lib/vgrnt/util/exec.rb +31 -0
- data/lib/vgrnt/util/logger.rb +23 -0
- data/lib/vgrnt/version.rb +1 -1
- data/spec/acceptance/app_spec.rb +17 -0
- data/spec/acceptance/support/acceptance_helper.rb +3 -0
- data/spec/unit/app_spec.rb +12 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8323a806adea255394c51d19b359c5ceb3f19be
|
4
|
+
data.tar.gz: e5f2a0f951de3281b168fdf4c773e450be3a40c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9b1c2561570adcb5348d37e6d6d697b3d595ed7b7aa4d86eac7417aeb73f0f4953076090e52b9d0711d5f95bade4c3be903d1f784a9675b3bda1eef41081f51
|
7
|
+
data.tar.gz: 284e2a10e4d795c60f62cd33c52173553b916eb3fdedfda8afede4ccee657245c5cc444c31f791e5bc86f77ebd34c63dabf2e35f18a088419d9c2858f1ff46db
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## [0.0.5](https://github.com/dergachev/vagrant/compare/v0.0.4...v0.0.5) (Dec 10, 2013)
|
2
|
+
|
3
|
+
FEATURES:
|
4
|
+
|
5
|
+
- Added 'vgrnt np' support.
|
6
|
+
|
7
|
+
IMPROVEMENTS:
|
8
|
+
|
9
|
+
- Refactored codebase a bit:
|
10
|
+
- Extracted shelling out logic into Vgrnt::Util::Exec
|
11
|
+
- Extracted logger helpers into Vgrnt::Util::Logger
|
12
|
+
- Improved Vgrnt::Util::Exec to allow capturing of stderr for testing
|
13
|
+
|
1
14
|
## [0.0.4](https://github.com/dergachev/vagrant/compare/v0.0.3...v0.0.4) (Dec 3, 2013)
|
2
15
|
|
3
16
|
BUGFIX:
|
data/README.md
CHANGED
@@ -77,6 +77,16 @@ vgrnt vboxmanage metrics query VM_ID
|
|
77
77
|
# => VBoxManage metrics query 0398e43a-d35f-4c84-bc81-6807f5d11262
|
78
78
|
```
|
79
79
|
|
80
|
+
### vgrnt np
|
81
|
+
|
82
|
+
Same as `VAGRANT_NO_PLUGINS=1 vagrant <args>`. Useful for speeding up any
|
83
|
+
command `vgrnt` doesn't support.
|
84
|
+
|
85
|
+
```
|
86
|
+
vgrnt np provision
|
87
|
+
# Executing "VAGRANT_NO_PLUGINS=1 vagrant provision"
|
88
|
+
```
|
89
|
+
|
80
90
|
## Installation
|
81
91
|
|
82
92
|
vgrnt *should not* be installed as a vagrant plugin. Instead, just install the gem:
|
data/docs/DEVNOTES.md
CHANGED
@@ -12,7 +12,7 @@ cd ~/code/vgrnt
|
|
12
12
|
|
13
13
|
# after making code changes, increment version number, build the gem locally
|
14
14
|
vim lib/vgrnt/version.rb +/VERSION # increment version counter, eg to 0.0.3
|
15
|
-
rake build # package the gem into ./pkg/vgrnt-0.0.3.gem
|
15
|
+
bundle exec rake build # package the gem into ./pkg/vgrnt-0.0.3.gem
|
16
16
|
|
17
17
|
# install and test the gem locally
|
18
18
|
gem uninstall vgrnt
|
@@ -24,8 +24,7 @@ vgrnt ssh -- ls /
|
|
24
24
|
vim CHANGELOG.md # add v0.0.3 details
|
25
25
|
git commit -m "Publishing v0.0.3" CHANGELOG.md lib/vgrnt/version.rb
|
26
26
|
|
27
|
-
rake release
|
28
|
-
git push --tags
|
27
|
+
bundle exec rake release
|
29
28
|
```
|
30
29
|
|
31
30
|
## Creating a gem
|
data/lib/vgrnt/base.rb
CHANGED
@@ -1,28 +1,12 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'open3'
|
3
|
+
require 'vgrnt/util/logger'
|
3
4
|
require 'vgrnt/util/virtualbox'
|
4
5
|
require 'vgrnt/util/vagrantfile'
|
6
|
+
require 'vgrnt/util/exec'
|
5
7
|
|
6
|
-
module Vgrnt
|
7
|
-
class Logger
|
8
|
-
|
9
|
-
def stdout(str)
|
10
|
-
$stdout.puts str unless str.empty?
|
11
|
-
end
|
12
|
-
|
13
|
-
def notice(str)
|
14
|
-
$stderr.puts str unless str.empty?
|
15
|
-
end
|
16
8
|
|
17
|
-
|
18
|
-
$stderr.puts str if !str.empty? && ENV['VAGRANT_LOG'] == 'debug'
|
19
|
-
end
|
20
|
-
|
21
|
-
def error(str)
|
22
|
-
# terminal codes for red
|
23
|
-
$stderr.puts "\e[31m" + str + "\e[0m" unless str.empty?
|
24
|
-
end
|
25
|
-
end
|
9
|
+
module Vgrnt
|
26
10
|
|
27
11
|
# Undoes the automatic removal of -- in Thor::Options.peek. Otherwise "vgrnt ssh precise -- ls /"
|
28
12
|
# is parsed as "precise ls /". TODO: is there a less hacky way to handle this?
|
@@ -32,12 +16,11 @@ module Vgrnt
|
|
32
16
|
end
|
33
17
|
end
|
34
18
|
|
35
|
-
|
36
19
|
class App < Thor
|
37
20
|
|
38
21
|
def initialize(*args)
|
39
22
|
super(*args)
|
40
|
-
@logger = Logger
|
23
|
+
@logger = Vgrnt::Util::Logger
|
41
24
|
end
|
42
25
|
|
43
26
|
desc "ssh [vm-name] [-- extra ssh args]", "Runs vagrant ssh without bootstrapping vagrant."
|
@@ -74,14 +57,7 @@ module Vgrnt
|
|
74
57
|
end
|
75
58
|
end
|
76
59
|
|
77
|
-
|
78
|
-
# - POpen3 ignores STDIN. Backticks buffer stdout. Kernel::exec breaks rspec.
|
79
|
-
# - getc instead of gets fixes the 1 line lag.
|
80
|
-
IO.popen(ssh_command) do |io|
|
81
|
-
while c = io.getc do
|
82
|
-
putc c
|
83
|
-
end
|
84
|
-
end
|
60
|
+
Vgrnt::Util::Exec.popen(ssh_command)
|
85
61
|
end
|
86
62
|
|
87
63
|
desc "ssh-config [vm-name]", "Store output of 'vagrant ssh-config' to .vgrnt-sshconfig"
|
@@ -114,6 +90,13 @@ module Vgrnt
|
|
114
90
|
end
|
115
91
|
end
|
116
92
|
|
93
|
+
desc "np [args]", "Executes 'VAGRANT_NO_PLUGINS=1 vagrant [args ...]'"
|
94
|
+
def np(*args)
|
95
|
+
command = (["VAGRANT_NO_PLUGINS=1", "vagrant" ] + args).join(" ")
|
96
|
+
Vgrnt::Util::Exec.popen(command)
|
97
|
+
end
|
98
|
+
|
99
|
+
|
117
100
|
# desc "provision", "Run vagrant provision like last time"
|
118
101
|
# def provision
|
119
102
|
# raise "Not implemented yet. Likely requires creating vagrant-vgrnt."
|
@@ -166,10 +149,7 @@ module Vgrnt
|
|
166
149
|
|
167
150
|
@logger.debug "Executing: #{command}"
|
168
151
|
#TODO: windows support (path to VBoxManage.exe")
|
169
|
-
|
170
|
-
@logger.stdout stdout.read
|
171
|
-
@logger.error stderr.read
|
172
|
-
end
|
152
|
+
Vgrnt::Util::Exec.popen(command)
|
173
153
|
end
|
174
154
|
end
|
175
155
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Vgrnt
|
2
|
+
module Util
|
3
|
+
module Exec
|
4
|
+
# used when wanting pass STDIN without buffering
|
5
|
+
def self.popen(command)
|
6
|
+
# Using IO.popen is important:
|
7
|
+
# - Open3.popen3 ignores STDIN. Backticks buffer stdout. Kernel::exec breaks rspec.
|
8
|
+
# - getc instead of gets fixes the 1 line lag.
|
9
|
+
IO.popen(command) do |io|
|
10
|
+
while c = io.getc do
|
11
|
+
putc c
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# used when we want to capture stdout, stderr separately and don't care about buffering on stdin
|
17
|
+
def self.popen3(command, logger = Vgrnt::Util::Logger)
|
18
|
+
Open3.popen3(command) do |stdin, stdout, stderr|
|
19
|
+
logger.stdout stdout.read
|
20
|
+
logger.error stderr.read
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.exec(command)
|
25
|
+
raise "NOT IMPLEMENTED"
|
26
|
+
# FIXME: stop using exec, it's too hard to test without stubbing
|
27
|
+
exec(command)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Vgrnt
|
2
|
+
module Util
|
3
|
+
class Logger
|
4
|
+
|
5
|
+
def self.stdout(str)
|
6
|
+
$stdout.puts str unless str.empty?
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.notice(str)
|
10
|
+
$stderr.puts str unless str.empty?
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.debug(str)
|
14
|
+
$stderr.puts str if !str.empty? && ENV['VAGRANT_LOG'] == 'debug'
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.error(str)
|
18
|
+
# terminal codes for red
|
19
|
+
$stderr.puts "\e[31m" + str + "\e[0m" unless str.empty?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/vgrnt/version.rb
CHANGED
data/spec/acceptance/app_spec.rb
CHANGED
@@ -16,6 +16,11 @@ describe Vgrnt::App do
|
|
16
16
|
output = vagrant_stdout { Vgrnt::App.start(%w{ssh -- whoami}) }
|
17
17
|
expect(output).to eq "vagrant\n"
|
18
18
|
end
|
19
|
+
|
20
|
+
it 'preserves stderr' do
|
21
|
+
output = vagrant_stderr { Vgrnt::App.start(%w{ssh -- grep --bob }) }
|
22
|
+
expect(output).to include "grep: unrecognized option '--bob'"
|
23
|
+
end
|
19
24
|
end
|
20
25
|
|
21
26
|
describe "#ssh-config", :slow do
|
@@ -26,6 +31,7 @@ describe Vgrnt::App do
|
|
26
31
|
it 'with default VM specified explicitly' do
|
27
32
|
expect( in_vagrant_env { File.exists? '.vgrnt-sshconfig' } ).to be_false
|
28
33
|
stderr = vagrant_stderr { Vgrnt::App.start(%w{ssh-config default}) }
|
34
|
+
expect(stderr).to include "Created ./.vgrnt-sshconfig with the following: Host default"
|
29
35
|
expect( in_vagrant_env { File.exists? '.vgrnt-sshconfig' } ).to be_true
|
30
36
|
end
|
31
37
|
|
@@ -68,6 +74,17 @@ describe Vgrnt::App do
|
|
68
74
|
expect(vgrnt_output).to include(vagrant_output)
|
69
75
|
end
|
70
76
|
end
|
77
|
+
|
78
|
+
describe "#np" do
|
79
|
+
it "'np status' is identical to 'vagrant status'", :slow do
|
80
|
+
# default saved (virtualbox)
|
81
|
+
vagrant_output = vagrant_stdout { puts `VAGRANT_NO_PLUGINS=1 vagrant status | grep '(virtualbox)$'` }
|
82
|
+
expect(vagrant_output).to match /default +running \(virtualbox\)/
|
83
|
+
|
84
|
+
vgrnt_output = vagrant_stdout { Vgrnt::App.start(%w{np status}) }
|
85
|
+
expect(vgrnt_output).to include(vagrant_output)
|
86
|
+
end
|
87
|
+
end
|
71
88
|
end
|
72
89
|
|
73
90
|
context "when running from ./spec/acceptance/fixtures/neveron" do
|
@@ -28,6 +28,9 @@ module AcceptanceExampleGroup
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def vagrant_stderr(&block)
|
31
|
+
# stubbing because IO.popen in Vgrnt::Util::Exec prevents stderr from being capturable.
|
32
|
+
Vgrnt::Util::Exec.stub(:popen) { |cmd| Vgrnt::Util::Exec.popen3(cmd) }
|
33
|
+
|
31
34
|
capture_in_vagrant_env(:stderr, &block)
|
32
35
|
end
|
33
36
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Vgrnt::App do
|
4
|
+
describe "#np" do
|
5
|
+
it 'executes correctly' do
|
6
|
+
Vgrnt::Util::Exec.stub(:popen) { |arg| arg }
|
7
|
+
output = Vgrnt::App.start(%w{np ssh default -- whoami})
|
8
|
+
expect(output).to eq "VAGRANT_NO_PLUGINS=1 vagrant ssh default -- whoami"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vgrnt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Dergachev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -85,6 +85,8 @@ files:
|
|
85
85
|
- docs/vboxmanage-irregular-commands.txt
|
86
86
|
- lib/vgrnt.rb
|
87
87
|
- lib/vgrnt/base.rb
|
88
|
+
- lib/vgrnt/util/exec.rb
|
89
|
+
- lib/vgrnt/util/logger.rb
|
88
90
|
- lib/vgrnt/util/vagrantfile.rb
|
89
91
|
- lib/vgrnt/util/virtualbox.rb
|
90
92
|
- lib/vgrnt/version.rb
|
@@ -95,6 +97,7 @@ files:
|
|
95
97
|
- spec/acceptance/support/acceptance_helper.rb
|
96
98
|
- spec/acceptance/util_spec.rb
|
97
99
|
- spec/spec_helper.rb
|
100
|
+
- spec/unit/app_spec.rb
|
98
101
|
- spec/unit/fixtures/util_vagrantfile/Vagrantfile-misc1
|
99
102
|
- spec/unit/fixtures/util_vagrantfile/Vagrantfile-multi
|
100
103
|
- spec/unit/fixtures/util_vagrantfile/Vagrantfile-plugins
|
@@ -133,6 +136,7 @@ test_files:
|
|
133
136
|
- spec/acceptance/support/acceptance_helper.rb
|
134
137
|
- spec/acceptance/util_spec.rb
|
135
138
|
- spec/spec_helper.rb
|
139
|
+
- spec/unit/app_spec.rb
|
136
140
|
- spec/unit/fixtures/util_vagrantfile/Vagrantfile-misc1
|
137
141
|
- spec/unit/fixtures/util_vagrantfile/Vagrantfile-multi
|
138
142
|
- spec/unit/fixtures/util_vagrantfile/Vagrantfile-plugins
|