vagrant-properties 0.5.1 → 0.5.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 +4 -4
- data/lib/vagrant-properties.rb +7 -7
- data/lib/vagrant-properties/config.rb +70 -72
- data/lib/vagrant-properties/version.rb +2 -4
- data/vagrant-properties.gemspec +9 -9
- 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: 9cb358cc37a421e3a04011ebe339eefd85ae79ca
|
4
|
+
data.tar.gz: e192b7001d6d05b35d1c19de7ffb05dfbfc5b98b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b5d070ee404751309534ca71658d72625d47d0c4c1a1d80e33f04c703eb8592ed1df44cb59d170ba9eae2b24f3a76dac8bcc9fe27fe3c884c9b290494d5b596
|
7
|
+
data.tar.gz: 452f5503ca36a80194d7ee5b41f3203c88b717304ac698c9f6b0f83efbb0570db7ca17196b2e940cc8e9c0d109cc51f25ca2371bc16f699a45c22205a752a233
|
data/lib/vagrant-properties.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'vagrant-properties/version'
|
2
2
|
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
module VagrantProperties
|
4
|
+
class Plugin < Vagrant.plugin('2')
|
5
|
+
name 'Vagrant Properties'
|
6
|
+
|
7
|
+
config('properties') do
|
8
|
+
require File.expand_path('../vagrant-properties/config', __FILE__)
|
9
|
+
Config
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,103 +1,101 @@
|
|
1
1
|
require 'vagrant'
|
2
2
|
require 'yaml'
|
3
3
|
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
attr_writer :properties_path
|
4
|
+
module VagrantProperties
|
5
|
+
class Config < Vagrant.plugin('2', :config)
|
6
|
+
attr_writer :properties_path
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
class << self
|
14
|
-
def properties
|
15
|
-
@properties ||= build_properties
|
16
|
-
end
|
8
|
+
def named(key)
|
9
|
+
self.class.properties[key.to_sym]
|
10
|
+
end
|
17
11
|
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
class << self
|
13
|
+
def properties
|
14
|
+
@properties ||= build_properties
|
15
|
+
end
|
21
16
|
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
def repo_valide?(repo)
|
18
|
+
repo && repo.is_a?(String) && !repo.empty?
|
19
|
+
end
|
25
20
|
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
def domains_valid?(domains)
|
22
|
+
domains && domains.is_a?(Array) && !domains.empty?
|
23
|
+
end
|
29
24
|
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
def hostname_valid?(hostname)
|
26
|
+
hostname && hostname.is_a?(String) && !hostname.empty?
|
27
|
+
end
|
33
28
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
property['path'] = pull_project(property['repo'])
|
38
|
-
end
|
29
|
+
def ip_valid?(ip)
|
30
|
+
ip && ip.is_a?(String) && !ip.empty?
|
31
|
+
end
|
39
32
|
|
40
|
-
|
41
|
-
|
42
|
-
|
33
|
+
def build_properties
|
34
|
+
load_properties.each_with_object({}) do |(name, property), memo|
|
35
|
+
if repo_valide?(property['repo'])
|
36
|
+
property['path'] = pull_project(property['repo'])
|
37
|
+
end
|
43
38
|
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
if !domains_valid?(property['domains']) && hostname_valid?(property['hostname'])
|
40
|
+
property['domains'] = [property['hostname']]
|
41
|
+
end
|
47
42
|
|
48
|
-
|
49
|
-
|
43
|
+
if ip_valid?(property['ip']) && domains_valid?(property['domains'])
|
44
|
+
write_to_hosts(property['ip'], property['domains'])
|
50
45
|
end
|
51
|
-
end
|
52
46
|
|
53
|
-
|
54
|
-
|
47
|
+
keys = property.keys.inject([]) { |m, k| m << k.to_sym }
|
48
|
+
memo[name.to_sym] = Struct.new(*keys).new(*property.values)
|
55
49
|
end
|
50
|
+
end
|
56
51
|
|
57
|
-
|
58
|
-
|
59
|
-
|
52
|
+
def properties_path
|
53
|
+
@properties_path ||= 'vagrant_properties.yml'
|
54
|
+
end
|
60
55
|
|
61
|
-
|
62
|
-
|
56
|
+
def load_properties
|
57
|
+
YAML.load_file properties_path
|
58
|
+
end
|
63
59
|
|
64
|
-
|
65
|
-
|
60
|
+
def pull_project(repo)
|
61
|
+
matched = repo.match(path_matcher)
|
66
62
|
|
67
|
-
|
68
|
-
|
69
|
-
end
|
63
|
+
if ghq?
|
64
|
+
ghq_root = `ghq root`.chomp
|
70
65
|
|
71
|
-
|
72
|
-
|
73
|
-
else
|
74
|
-
path = "../#{matched[3]}"
|
75
|
-
git_clone path, repo
|
66
|
+
if ghq_root == "No help topic for 'root'"
|
67
|
+
raise StandardError.new '"ghq root" not found. please update ghq'
|
76
68
|
end
|
77
69
|
|
78
|
-
path
|
70
|
+
path = "#{ghq_root}/#{matched[1..3].join('/')}"
|
71
|
+
ghq_get path, repo
|
72
|
+
else
|
73
|
+
path = "../#{matched[3]}"
|
74
|
+
git_clone path, repo
|
79
75
|
end
|
80
76
|
|
81
|
-
|
82
|
-
|
83
|
-
echo "#{ip} #{domains.join(' ')}" | sudo tee -a /etc/hosts`
|
84
|
-
end
|
77
|
+
path
|
78
|
+
end
|
85
79
|
|
86
|
-
|
87
|
-
|
88
|
-
|
80
|
+
def write_to_hosts(ip, domains)
|
81
|
+
`test 0 -ne $(cat /etc/hosts | grep -q #{ip} ; echo $?) && \
|
82
|
+
echo "#{ip} #{domains.join(' ')}" | sudo tee -a /etc/hosts`
|
83
|
+
end
|
89
84
|
|
90
|
-
|
91
|
-
|
92
|
-
|
85
|
+
def path_matcher
|
86
|
+
%r|([\w\-\.]*)[:/]([\w\-]*)/([\w\-]*)\.git|
|
87
|
+
end
|
93
88
|
|
94
|
-
|
95
|
-
|
96
|
-
|
89
|
+
def ghq_get(path, repo)
|
90
|
+
`test ! -d #{path} && ghq get #{repo}`
|
91
|
+
end
|
97
92
|
|
98
|
-
|
99
|
-
|
100
|
-
|
93
|
+
def git_clone(path, repo)
|
94
|
+
`test ! -d #{path} && git clone #{repo} #{path}`
|
95
|
+
end
|
96
|
+
|
97
|
+
def ghq?
|
98
|
+
@ghq ||= `which ghq 1>/dev/null ; echo $?`.to_i == 0
|
101
99
|
end
|
102
100
|
end
|
103
101
|
end
|
data/vagrant-properties.gemspec
CHANGED
@@ -4,20 +4,20 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'vagrant-properties/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
-
spec.version =
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
7
|
+
spec.name = 'vagrant-properties'
|
8
|
+
spec.version = VagrantProperties::VERSION
|
9
|
+
spec.authors = ['linyows']
|
10
|
+
spec.email = ['linyows@gmail.com']
|
11
11
|
spec.summary = %q{Mnagement multiple machines.}
|
12
12
|
spec.description = %q{Mnagement multiple machines.}
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.homepage = 'https://github.com/linyows/vagrant-properties'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
23
|
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.5.
|
4
|
+
version: 0.5.2
|
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-
|
11
|
+
date: 2015-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|