vagrant-global-status 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +0 -1
- data/lib/vagrant-global-status/global_environment.rb +24 -1
- data/lib/vagrant-global-status/global_registry.rb +5 -4
- data/lib/vagrant-global-status/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c60040af18fe6b732917ef79ea068a1dfb6ba67
|
4
|
+
data.tar.gz: 449b04beafe85d42d4cbbfaba0ac05d1ea1eca9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d227394b75feaf8510e164b15d1127b683734b50041cfb83bfa449c1dded87ac2301cfdda2a37dbc7c3b99bef455969244ade2525c607b13ec0e67e45e1dd466
|
7
|
+
data.tar.gz: c8edcc1b07ba0636499f1c430109954146de45f2751967170046201dcb0971d7bd1bc7d8f7cce00780eff1e832c6956bbdb65db30b2678bfaac90a786141fe08
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## [0.1.4](https://github.com/fgrehm/vagrant-global-status/compare/v0.1.3...v0.1.4) (December 25, 2013)
|
2
|
+
|
3
|
+
- Display the time when the VM was created [GH-3]
|
4
|
+
- Display VM status with color [GH-12]
|
5
|
+
|
1
6
|
## [0.1.3](https://github.com/fgrehm/vagrant-global-status/compare/v0.1.2...v0.1.3) (December 17, 2013)
|
2
7
|
|
3
8
|
- Stop displaying non-running machines without -a option [GH-1]
|
data/README.md
CHANGED
@@ -39,7 +39,6 @@ used for development of a Vagrant plugin using Bundler.
|
|
39
39
|
## Current limitations / ideas for contributions
|
40
40
|
|
41
41
|
* Keeps track of active vagrant-lxc and VirtualBox VMs only
|
42
|
-
* Blows up if the `Vagrantfile` gets removed from the registered path
|
43
42
|
* Detect orphaned machines
|
44
43
|
|
45
44
|
## Contributing
|
@@ -8,6 +8,14 @@ module VagrantPlugins
|
|
8
8
|
def initialize(path, data)
|
9
9
|
@path = Pathname(path)
|
10
10
|
@machine_names = Array(data['machines']).map{|machine| machine['name']}
|
11
|
+
@created_at = {}
|
12
|
+
data['machines'].each do |machine|
|
13
|
+
ctime = machine['created_at']
|
14
|
+
if ctime =~ /[\d]+/
|
15
|
+
ctime = Time.at(ctime.to_i).to_s
|
16
|
+
end
|
17
|
+
@created_at.store(machine['name'], ctime)
|
18
|
+
end
|
11
19
|
end
|
12
20
|
|
13
21
|
# REFACTOR: Extract a machine class
|
@@ -17,11 +25,26 @@ module VagrantPlugins
|
|
17
25
|
matches = vagrant_status.scan(/(\w[\w-]+)\s+(\w[\w\s]+)\s+\((\w+)\)/)
|
18
26
|
matches.map do |vm, status, provider|
|
19
27
|
if all || (@machine_names.include?(vm) and status == "running")
|
20
|
-
|
28
|
+
provider = "(#{provider})"
|
29
|
+
" #{vm.ljust(12)} #{status_line(status, 12)} #{provider.ljust(14)} #{@created_at[vm]}"
|
21
30
|
end
|
22
31
|
end.compact.join("\n")
|
23
32
|
end
|
24
33
|
|
34
|
+
def status_line(status, length)
|
35
|
+
case status
|
36
|
+
when "running" then
|
37
|
+
color = 32 # green
|
38
|
+
when "not running", "poweroff" then
|
39
|
+
color = 33 # yellow
|
40
|
+
when "not created" then
|
41
|
+
color = 34 # blue
|
42
|
+
else
|
43
|
+
return status.ljust(length)
|
44
|
+
end
|
45
|
+
sprintf("\e[%dm%s\e[m", color, status.ljust(length))
|
46
|
+
end
|
47
|
+
|
25
48
|
def vagrant_status
|
26
49
|
return @vagrant_status if @vagrant_status
|
27
50
|
|
@@ -7,7 +7,8 @@ module VagrantPlugins
|
|
7
7
|
statefile = params.fetch(:home_path).join('machine-environments.json')
|
8
8
|
new(statefile).register(
|
9
9
|
params.fetch(:machine_name).to_s,
|
10
|
-
params.fetch(:root_path).to_s
|
10
|
+
params.fetch(:root_path).to_s,
|
11
|
+
Time.now.to_i.to_s
|
11
12
|
)
|
12
13
|
end
|
13
14
|
|
@@ -37,13 +38,13 @@ module VagrantPlugins
|
|
37
38
|
@environments.values
|
38
39
|
end
|
39
40
|
|
40
|
-
def register(machine_name, root_path)
|
41
|
+
def register(machine_name, root_path, created_at)
|
41
42
|
@current_state['environments'][root_path] ||= { 'machines' => [] }
|
42
43
|
|
43
44
|
global_environment = @current_state['environments'][root_path]
|
44
45
|
machine = { 'name' => machine_name }
|
45
46
|
unless global_environment['machines'].include?(machine)
|
46
|
-
global_environment['machines'] << {'name' => machine_name}
|
47
|
+
global_environment['machines'] << {'name' => machine_name, 'created_at' => created_at}
|
47
48
|
end
|
48
49
|
|
49
50
|
write_statefile
|
@@ -53,7 +54,7 @@ module VagrantPlugins
|
|
53
54
|
@current_state['environments'][root_path] ||= { 'machines' => [] }
|
54
55
|
|
55
56
|
global_environment = @current_state['environments'][root_path]
|
56
|
-
global_environment['machines'].
|
57
|
+
global_environment['machines'].delete_if {|machine| machine["name"] = machine_name }
|
57
58
|
|
58
59
|
write_statefile
|
59
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-global-status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabio Rehm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|