vagrant-properties 0.5.1 → 0.5.2

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