vagrant-properties 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 213da81f99531c415f04cc62bc1107a110c0cf3c
4
- data.tar.gz: d87a876a3f33e125876133a5bf00f4ba40f85e1d
3
+ metadata.gz: 74f0fcbbde803227a7a5dfd16a141a537ea6f31e
4
+ data.tar.gz: 79be3d53388dfb0a07c836817fd219decf0cd83f
5
5
  SHA512:
6
- metadata.gz: 18c2d7c0eac2b146e3840098d1d21364b470bc79b2cced1b28e61d46bff2086462f3070587f770ef9c82de54c32a598c4c7b6ab66885fa1361b98a12a81477c6
7
- data.tar.gz: 020a4b5acfb651bf839c0743b713f3800e172b701046da4919b367d1315b5c63fdb7cba21823d24860e7f0ad8e335d58ecb479fc755b73d33de08fecd992bd06
6
+ metadata.gz: d38245e83577471651c1c4c7d88ad2b0a676292320359ffbf1b8c521c2826bfca2ea0d4635ef74f64b305daad21681cc27647fd424999c9b6d40c13971b91f93
7
+ data.tar.gz: 4978f21a8187193fb25c08c797eee47a8457a0cbc813f887539ec437bfb90714a78325dfd2782c832f30fd498f52b58227abe9ded7c4c7a26ccb20960c208143
@@ -15,15 +15,34 @@ module VagrantPlugins
15
15
  @properties ||= build_properties
16
16
  end
17
17
 
18
+ def repo_valide?(repo)
19
+ repo && repo.is_a?(Array) && !repo.empty?
20
+ end
21
+
22
+ def domains_valid?(domains)
23
+ domains && domains.is_a?(Array) && !domains.empty?
24
+ end
25
+
26
+ def hostname_valid?(hostname)
27
+ hostname && hostname.is_a?(String) && !hostname.empty?
28
+ end
29
+
30
+ def ip_valid?(hostname)
31
+ ip && ip.is_a?(String) && !ip.empty?
32
+ end
33
+
18
34
  def build_properties
19
35
  load_properties.each_with_object({}) do |(name, property), memo|
20
- if property['repo'] && !property['repo'].empty?
36
+ if repo_valide?(property['repo'])
21
37
  property['path'] = pull_project(property['repo'])
22
38
  end
23
39
 
24
- if property['ip'] && property['hostname'] &&
25
- !property['ip'].empty? && !property['hostname'].empty?
26
- write_to_hosts(property['ip'], property['hostname'])
40
+ if !domains_valid?(property['domains']) && hostname_valid?(property['hostname'])
41
+ property['domains'] = [property['hostname']]
42
+ end
43
+
44
+ if ip_valid?(property['ip']) && domains_valid?(property['domains'])
45
+ write_to_hosts(property['ip'], property['domains'])
27
46
  end
28
47
 
29
48
  keys = property.keys.inject([]) { |m, k| m << k.to_sym }
@@ -59,9 +78,9 @@ module VagrantPlugins
59
78
  path
60
79
  end
61
80
 
62
- def write_to_hosts(ip, hostname)
81
+ def write_to_hosts(ip, domains)
63
82
  `test 0 -ne $(cat /etc/hosts | grep -q #{ip} ; echo $?) && \
64
- echo "#{ip} #{hostname}" | sudo tee -a /etc/hosts`
83
+ echo "#{ip} #{domains.join(' ')}" | sudo tee -a /etc/hosts`
65
84
  end
66
85
 
67
86
  def path_matcher
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Properties
3
- VERSION = '0.4.0'
3
+ VERSION = '0.5.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-properties
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - linyows
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-08 00:00:00.000000000 Z
11
+ date: 2015-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler