vagrant-ghost 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00e6088d25f9a6bb0f8263c070bc193e1cb6de56
4
- data.tar.gz: 7280630cbdd5046a72a6c09d65d8fce5671e5955
3
+ metadata.gz: 9afd17339bc082e2e0a359c4f11156557cac95aa
4
+ data.tar.gz: 9bae581d4c37e661ac2d82614e7d89a8d8c44115
5
5
  SHA512:
6
- metadata.gz: a0947cc9714545dcc268d7c387f46a8c57ad86fa45e4408522c7d807fef878c85bf820cd1cde34530434670f9cc38ef8a32ba3cf8708dcebd8525f653211ad2c
7
- data.tar.gz: ddf2b6047cbdb3268bfde3ddf62df23c0c6518b336a9dbad3db932a4b832d93dd4824333f561bc706dc0d79d632b265f6ef3b4a48c50f77dc92813c08ee4842d
6
+ metadata.gz: 6a96421c35a2b16aaa5d54ded9bb1d45f290e6833726d324b5cffd56a76ab6c1385158b897e53843d2f78634a971f50a257101fc287d745f4c251e46f0b765e7
7
+ data.tar.gz: 72cfaccb79fb6cf51e5430a346ea7fd67b1c6e5f15f2e461e15bd46fea57824225366691b55d5f2e0da3e55873e5d8821505aef087e2d4e3a13dc80f57891aac
data/README.md CHANGED
@@ -22,12 +22,15 @@ At the moment, the only things you need, are the hostname and a :private_network
22
22
 
23
23
  config.vm.network :private_network, ip: "192.168.3.10"
24
24
  config.vm.hostname = "www.testing.de"
25
- config.hostsupdater.aliases = ["alias.testing.de", "alias2.somedomain.com"]
25
+ config.ghost.aliases = ["alias.testing.de", "alias2.somedomain.com"]
26
26
 
27
27
  This ip and the hostname will be used for the entry in the /etc/hosts file.
28
28
 
29
29
  ## Changelog
30
30
 
31
+ ### 0.1.2
32
+ * Make the CLI command scan a local hosts setup files (`/config/hosts` and `/aliases`) to rebuild the hosts map
33
+
31
34
  ### 0.1.1
32
35
  * Update the CLI to a "primary" command
33
36
  * Make sure help doesn't try to fire a host update
@@ -24,9 +24,32 @@ module VagrantPlugins
24
24
 
25
25
  def getHostnames
26
26
  hostnames = Array(@machine.config.vm.hostname)
27
+
28
+ # Regenerate hostsfile
29
+ paths = Dir[File.join( 'config', '**', 'hosts' )]
30
+ hosts = paths.map do |path|
31
+ lines = File.readlines(path).map(&:chomp)
32
+ lines.grep(/\A[^#]/)
33
+ end.flatten.uniq
34
+
35
+ # Pull in managed aliases
36
+ local = Dir[File.join( '**', 'aliases' )]
37
+ local_hosts = local.map do |path|
38
+ lines = File.readlines(path).map(&:chomp)
39
+ lines.grep(/\A[^#]/)
40
+ end.flatten.uniq
41
+
42
+ # Merge our lists together
43
+ aliases = ( hosts << local_hosts ).flatten!
44
+
45
+ # Concat with the local hostname
46
+ hostnames.concat( aliases )
47
+
48
+ # Update the achine configuration
27
49
  if @machine.config.ghost.aliases
28
- hostnames.concat(@machine.config.ghost.aliases)
50
+ @machine.config.ghost.aliases = aliases
29
51
  end
52
+
30
53
  return hostnames
31
54
  end
32
55
 
@@ -8,12 +8,29 @@ module VagrantPlugins
8
8
  end
9
9
 
10
10
  def execute
11
- cmd, cmd_args, argv, options = parse_args
12
- cmd && cmd_args or return nil
11
+ options = {}
12
+ options[:provider] = @env.default_provider
13
+
14
+ opts = OptionParser.new do |o|
15
+ o.banner = 'Usage: vagrant ghost'
16
+ o.separator ''
17
+
18
+ o.on('-h', '--help', 'Print this help') do
19
+ safe_puts(opts.help)
20
+ return
21
+ end
22
+
23
+ o.on('--provider provider', String, 'Update machines with the specific provider.') do |provider|
24
+ options[:provider] = provider
25
+ end
26
+ end
27
+
28
+ argv = parse_options(opts)
29
+ return if !argv
13
30
 
14
31
  @ui = @env.ui
15
32
 
16
- with_target_vms(argv, options) do |machine|
33
+ with_target_vms(argv, reverse: true) do |machine|
17
34
  @machine = machine
18
35
 
19
36
  # Always remove hosts to make sure old entries don't stick around
@@ -42,39 +59,6 @@ module VagrantPlugins
42
59
  false
43
60
  end
44
61
 
45
- private
46
-
47
- def parse_args
48
- options = {}
49
- opts = OptionParser.new do |o|
50
- o.banner = 'Usage: vagrant ghost [vm-name]'
51
- o.separator ''
52
-
53
- o.on('-h', '--help', 'Print this help') do
54
- safe_puts(opts.help)
55
- end
56
-
57
- o.on('--provider provider', String, 'Update machines with the specific provider.') do |provider|
58
- options[:provider] = provider
59
- end
60
- end
61
-
62
- argv = split_main_and_subcommand(@argv.dup)
63
- exec_args, cmd, cmd_args = argv[0], argv[1], argv[2]
64
-
65
- # show help
66
- if !cmd || exec_args.any? { |a| a == '-h' || a == '--help' }
67
- safe_puts(opts.help)
68
- return nil
69
- end
70
-
71
- options[:provider] ||= @env.default_provider
72
-
73
- # remove extra "--" arge added by Vagrant
74
- cmd_args.delete_if { |a| a == '--' }
75
-
76
- return cmd, cmd_args, parse_options(opts), options
77
- end
78
62
  end
79
63
  end
80
64
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Ghost
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-ghost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John P Bloch
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-03-13 00:00:00.000000000 Z
12
+ date: 2015-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler