itamae-plugin-recipe-anyenv 0.3.0 → 0.3.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 558700ae936f294120b68c59e71f5f4be14bb7cc
|
4
|
+
data.tar.gz: 0a9a9915c9e27459353a801b6e40c9584edb1f40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4ab5ba6b37be5d254fad601b018bfcd6ea7f0f429bed6c1c8073b964e30bff49788d7bef897d308681f6bde7ecb7b8ae26b3feb20832e5440236e072f1c25db
|
7
|
+
data.tar.gz: 0543020a986d7af6159a7ce58152cb568c866d0fdad0d59061747abd6ee09023530788b5162f3637f39225d8338c943da80494cba44bf2b2275348c09fbc4fe5
|
@@ -1,7 +1,24 @@
|
|
1
|
-
DEFAULT_RBENV_ROOT =
|
1
|
+
DEFAULT_RBENV_ROOT = '/usr/local/anyenv'.freeze
|
2
|
+
|
3
|
+
def run(attributes, username = nil)
|
4
|
+
init(username)
|
5
|
+
|
6
|
+
clone_anyenv
|
7
|
+
clone_anyenv_update
|
8
|
+
|
9
|
+
install_envs(attributes)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def init(username)
|
15
|
+
@username = username
|
16
|
+
@anyenv_root_path = anyenv_root(username)
|
17
|
+
@init_cmd = anyenv_init(@anyenv_root_path)
|
18
|
+
end
|
2
19
|
|
3
20
|
def scheme
|
4
|
-
scheme ||= node[:anyenv][:scheme] ||
|
21
|
+
@scheme ||= node[:anyenv][:scheme] || 'git'
|
5
22
|
end
|
6
23
|
|
7
24
|
def anyenv_root(username)
|
@@ -21,7 +38,7 @@ def anyenv_user_root(username)
|
|
21
38
|
return node[:anyenv][:users][username][:anyenv_root]
|
22
39
|
end
|
23
40
|
case node[:platform]
|
24
|
-
when
|
41
|
+
when 'darwin'
|
25
42
|
"/Users/#{username}/.anyenv"
|
26
43
|
else
|
27
44
|
"/home/#{username}/.anyenv"
|
@@ -29,50 +46,65 @@ def anyenv_user_root(username)
|
|
29
46
|
end
|
30
47
|
|
31
48
|
def anyenv_init(root_path)
|
32
|
-
init_str = %
|
33
|
-
init_str << %
|
34
|
-
init_str << %
|
35
|
-
init_str
|
49
|
+
init_str = %(export ANYENV_ROOT="#{root_path}"; )
|
50
|
+
init_str << %(export PATH="#{root_path}/bin:${PATH}"; )
|
51
|
+
init_str << %(eval "$(anyenv init -)"; )
|
36
52
|
end
|
37
53
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
user username if username
|
44
|
-
repository "#{scheme}://github.com/riywo/anyenv.git"
|
54
|
+
def clone_repository(install_path, repo_path)
|
55
|
+
git install_path do
|
56
|
+
user @username if @username
|
57
|
+
repository repo_path if repo_path
|
58
|
+
not_if "test -d #{install_path}"
|
45
59
|
end
|
60
|
+
end
|
46
61
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
62
|
+
def clone_anyenv
|
63
|
+
repo_path = "#{scheme}://github.com/riywo/anyenv.git"
|
64
|
+
clone_repository(@anyenv_root_path, repo_path)
|
65
|
+
end
|
51
66
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
67
|
+
def clone_anyenv_update
|
68
|
+
install_path = "#{@anyenv_root_path}/plugins/anyenv-update"
|
69
|
+
repo_path = "#{scheme}://github.com/znz/anyenv-update.git"
|
70
|
+
clone_repository(install_path, repo_path)
|
71
|
+
end
|
72
|
+
|
73
|
+
def install_envs(attributes)
|
74
|
+
attributes[:install_versions].each do |envs|
|
75
|
+
envs.each do |env, vers|
|
76
|
+
install_env(env)
|
59
77
|
|
60
|
-
|
61
|
-
|
62
|
-
execute "#{env} install #{ver}" do
|
63
|
-
user username if username
|
64
|
-
command "#{init_cmd} #{env} install #{ver}"
|
65
|
-
not_if "#{init_cmd} #{env} versions | grep #{ver}"
|
78
|
+
vers.each do |ver|
|
79
|
+
install_env_version(env, ver)
|
66
80
|
end
|
81
|
+
|
82
|
+
global_version(env, vers.first)
|
67
83
|
end
|
68
84
|
end
|
85
|
+
end
|
69
86
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
87
|
+
def install_env(envname)
|
88
|
+
execute "install #{envname}" do
|
89
|
+
user @username if @username
|
90
|
+
command "#{@init_cmd} anyenv install #{envname}"
|
91
|
+
not_if "#{@init_cmd} type #{envname}"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def install_env_version(envname, version)
|
96
|
+
execute "#{envname} install #{version}" do
|
97
|
+
user @username if @username
|
98
|
+
command "#{@init_cmd} #{envname} install #{version}"
|
99
|
+
not_if "#{@init_cmd} #{envname} versions | grep #{version}"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def global_version(envname, version)
|
104
|
+
execute "#{envname} global #{version}" do
|
105
|
+
user @username if @username
|
106
|
+
command "#{@init_cmd} #{envname} global #{version}; " \
|
107
|
+
"#{@init_cmd} #{envname} rehash"
|
108
|
+
not_if "#{@init_cmd} #{envname} global | grep #{version}"
|
77
109
|
end
|
78
110
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itamae-plugin-recipe-anyenv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Surume
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: itamae
|