wwtd 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/wwtd.rb +35 -38
- data/lib/wwtd/tasks.rb +1 -6
- data/lib/wwtd/version.rb +1 -1
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31ec85abe62a348965669a72f3e66780513e4464
|
4
|
+
data.tar.gz: d385cb6dcc35c69d8a902144e11740487bfc3dcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d977fbdb37a688ef729aa6a44046f93dbc66f62dc5932564d37cebaff723d6e250dcc53cb7586307c472df1ff9592d4cfcb93f05998d068cdf0b11a2607570f6
|
7
|
+
data.tar.gz: 43c1c10ed25329f78fbd31a4f7cff1c5f5ab15139d77973a0144d312a3a69ffbff3c3e298bf20aff49804e0009f2a6c19ca451d59970dbd97d3b4039299f962f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/wwtd.rb
CHANGED
@@ -11,9 +11,10 @@ module WWTD
|
|
11
11
|
DEFAULT_GEMFILE = "Gemfile"
|
12
12
|
COMBINATORS = ["rvm", "gemfile", "env"]
|
13
13
|
UNDERSTOOD = ["rvm", "gemfile", "matrix", "script", "bundler_args"]
|
14
|
+
INFO_MAX_CHARACTERS = 30
|
14
15
|
|
15
16
|
class << self
|
16
|
-
def run(argv)
|
17
|
+
def run(argv=[])
|
17
18
|
options = parse_options(argv)
|
18
19
|
|
19
20
|
# Read actual .travis.yml
|
@@ -72,8 +73,12 @@ module WWTD
|
|
72
73
|
end
|
73
74
|
|
74
75
|
def config_info(matrix, config)
|
75
|
-
config = config.select { |k,v| matrix.map { |c| c[k] }.uniq.size > 1 }.sort
|
76
|
-
|
76
|
+
config = config.select { |k,v| matrix.map { |c| c[k] }.uniq.size > 1 }.sort # find non-unique values aka interesting
|
77
|
+
maximum_value_lengths = Hash[config.map { |k,v| [k, matrix.map { |h| h[k].to_s.size }.max ] }] # find maximum value length for each key so we can align
|
78
|
+
config.map do |k, v|
|
79
|
+
value = truncate(v, INFO_MAX_CHARACTERS).ljust([INFO_MAX_CHARACTERS, maximum_value_lengths[k]].min)
|
80
|
+
"#{k}: #{value}"
|
81
|
+
end.join(" ") # truncate values that are too long
|
77
82
|
end
|
78
83
|
|
79
84
|
def tint(color, string)
|
@@ -119,17 +124,17 @@ module WWTD
|
|
119
124
|
end
|
120
125
|
|
121
126
|
def run_config(config, lock)
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
127
|
+
with_clean_env do
|
128
|
+
Shellwords.split(config["env"] || "").each do |part|
|
129
|
+
name, value = part.split("=", 2)
|
130
|
+
ENV[name] = value
|
131
|
+
end
|
126
132
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
133
|
+
if gemfile = config["gemfile"]
|
134
|
+
ENV["BUNDLE_GEMFILE"] = gemfile
|
135
|
+
end
|
136
|
+
wants_bundle = gemfile || File.exist?(DEFAULT_GEMFILE)
|
131
137
|
|
132
|
-
with_clean_env do
|
133
138
|
switch_ruby = switch_ruby(config["rvm"])
|
134
139
|
|
135
140
|
if wants_bundle
|
@@ -154,29 +159,29 @@ module WWTD
|
|
154
159
|
if rvm_executable
|
155
160
|
"rvm #{version} do "
|
156
161
|
else
|
157
|
-
if
|
158
|
-
switch_path(
|
159
|
-
elsif
|
160
|
-
|
162
|
+
if ruby_root = ENV["RUBY_ROOT"] # chruby or RUBY_ROOT set
|
163
|
+
switch_path(File.dirname(ruby_root), version)
|
164
|
+
elsif rbenv_executable
|
165
|
+
rubies_root = cache_command("which rbenv").sub(%r{/(\.?rbenv)/.*}, "/\\1") + "/versions"
|
166
|
+
switch_path(rubies_root, version)
|
161
167
|
else
|
162
|
-
"false # could not find
|
168
|
+
"false # could not find rvm, rbenv or RUBY_ROOT # "
|
163
169
|
end
|
164
170
|
end
|
165
171
|
end
|
166
172
|
|
167
|
-
def switch_path(
|
168
|
-
|
169
|
-
if
|
170
|
-
"#{
|
173
|
+
def switch_path(rubies_root, version)
|
174
|
+
extract_jruby_rbenv_options!(version)
|
175
|
+
if ruby_root = ruby_root(rubies_root, version)
|
176
|
+
gem_home = Dir["#{ruby_root}/lib/ruby/gems/*"].first
|
177
|
+
ENV["PATH"] = "#{ruby_root}/bin:#{ENV["PATH"]}"
|
178
|
+
ENV["GEM_HOME"] = gem_home
|
179
|
+
""
|
171
180
|
else
|
172
|
-
"false # could not find #{version} in #{
|
181
|
+
"false # could not find #{version} in #{rubies_root} # "
|
173
182
|
end
|
174
183
|
end
|
175
184
|
|
176
|
-
def chruby?
|
177
|
-
ENV["RUBY_ROOT"] # chruby is a shell function not available from inside ruby
|
178
|
-
end
|
179
|
-
|
180
185
|
def rvm_executable
|
181
186
|
cache_command("which rvm")
|
182
187
|
end
|
@@ -193,16 +198,8 @@ module WWTD
|
|
193
198
|
end
|
194
199
|
end
|
195
200
|
|
196
|
-
def
|
197
|
-
|
198
|
-
"#{found_version_path}/bin" if found_version_path
|
199
|
-
end
|
200
|
-
|
201
|
-
def rbenv_bin_path(version)
|
202
|
-
known_version = capture("rbenv versions | grep #{version}")
|
203
|
-
known_version = known_version.split("\n").last[2..-1].split(" ")[0]
|
204
|
-
rbenv_root = rbenv_executable.sub(%r{/(\.?rbenv)/.*}, "/\\1")
|
205
|
-
"#{rbenv_root}/versions/#{known_version}/bin"
|
201
|
+
def ruby_root(root, version)
|
202
|
+
Dir.glob("#{root}/*").detect { |p| File.basename(p).start_with?(version) }
|
206
203
|
end
|
207
204
|
|
208
205
|
def cache(key)
|
@@ -217,9 +214,9 @@ module WWTD
|
|
217
214
|
# set ruby-opts for jruby flavors
|
218
215
|
def extract_jruby_rbenv_options!(version)
|
219
216
|
if version.sub!("-d19", "")
|
220
|
-
"JRUBY_OPTS
|
217
|
+
ENV["JRUBY_OPTS"] = "--1.9"
|
221
218
|
elsif version.sub!("-d18", "")
|
222
|
-
"JRUBY_OPTS
|
219
|
+
ENV["JRUBY_OPTS"] = "--1.8"
|
223
220
|
end
|
224
221
|
end
|
225
222
|
|
data/lib/wwtd/tasks.rb
CHANGED
data/lib/wwtd/version.rb
CHANGED
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|