wwtd 0.1.8 → 0.1.9

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: 902e3bea674a41f89c7265296c4370f04ced88e5
4
- data.tar.gz: 0d5de8487adefaa0fe776e19513326fcd2f055bd
3
+ metadata.gz: a8fc6e436ea91aa67fd00cc6285d866e4e5350ae
4
+ data.tar.gz: 36e0bc7cc2f324b60772f343c889f66a6f1cfef4
5
5
  SHA512:
6
- metadata.gz: 225fa6f7e3d78d6e86279a28ca31f71fae88e0bd6e8c82760d6a0be619037fdc67e9176ca7b44acb5c5a1246c6427531584786b464b0180c766c83aaff682043
7
- data.tar.gz: 299e85348fd2dc56e71088f7378c6dc8ed39cbead8a257790c1c2afa251d5edcee44501507d5dcaf2b899e2f8dabaf1e6fb8af9517bd22940f3bd09f329ac8bf
6
+ metadata.gz: 220f889c7096aea1267d3122bff57a6dbd4f5c35e7d30e847c96472ebf1cf284a168ffc2097b9b18e078fbe8c3fc22bc98a92f52f41642eb3096be5741b5a87b
7
+ data.tar.gz: 31c06c72b004f3ad9e9efa5eaa7f7314ce45e86c78de4bcdf39c128cb419e3dd5364f57764a7d874b8267c5d2ffc0651119fc8bf074a33e46f0061dcc25a3e44
Binary file
data.tar.gz.sig CHANGED
@@ -1,3 +1 @@
1
- ^�jJB,_RBFk ��aM�����XDg#��8U,ST�`y7ޣ���#@.����oq����(ɚ��R�9�Ґ|�Ś�
2
- �5��yg�* ����j����NP�� ��+�~>ż��K*
3
- ��(i��Ax�0p��ţ�8�+�:��?��5�~tJ�_>��^�^�[)e��MZ"<^�g`1/�# !EC��Ua�x��M��gdPF�~�El+{j�hr`�7�АfE>)�筼i��Wq)�M�o�Z
1
+ '��<��D8���#x�Yxl|�ʐ��/|T��}�*x 2/��q8K�-��H1��b��rįN<7���Oi�:Bz�E�����8ٓ��;�$�� y7-�0�I�BFA|��9�K$\[?�7)p�������>������rU�%2��Ί����Ufm�?ئ""W�7���""R�F;�S'W500F;�����1�zl����VT�|G(�lR�ܲ{���fN�6��i�GV��r�x7�Bl�Hw���
@@ -130,26 +130,106 @@ module WWTD
130
130
  end
131
131
 
132
132
  with_clean_env do
133
- rvm = "rvm #{ruby_version(config["rvm"])} do " if config["rvm"]
133
+ switch_ruby = switch_ruby(config["rvm"])
134
134
 
135
135
  if wants_bundle
136
136
  flock("#{lock}/#{config["rvm"] || "rvm"}") do
137
137
  default_bundler_args = "--deployment --path #{Dir.pwd}/vendor/bundle" if committed?("#{gemfile || DEFAULT_GEMFILE}.lock")
138
- bundle_command = "#{rvm}bundle install #{config["bundler_args"] || default_bundler_args}"
138
+ bundle_command = "#{switch_ruby}bundle install #{config["bundler_args"] || default_bundler_args}"
139
139
  return false unless sh "#{bundle_command.strip} --quiet"
140
140
  end
141
141
  end
142
142
 
143
143
  default_command = (wants_bundle ? "bundle exec rake" : "rake")
144
144
  command = config["script"] || default_command
145
- command = "#{rvm}#{command}"
145
+ command = "#{switch_ruby}#{command}"
146
146
 
147
147
  sh(command)
148
148
  end
149
149
  end
150
150
 
151
+ def switch_ruby(version)
152
+ return unless version
153
+ version = normalize_ruby_version(version)
154
+ if rvm_executable
155
+ "rvm #{version} do "
156
+ else
157
+ if rbenv_executable
158
+ switch_path(version, "rbenv")
159
+ elsif chruby?
160
+ switch_path(version, "chruby")
161
+ else
162
+ "false # could not find ruby version changer # "
163
+ end
164
+ end
165
+ end
166
+
167
+ def switch_path(version, changer)
168
+ prefix = extract_jruby_rbenv_options!(version)
169
+ if bin_path = send("#{changer}_bin_path", version)
170
+ "#{prefix}PATH=#{bin_path}:$PATH "
171
+ else
172
+ "false # could not find #{version} in #{changer} # "
173
+ end
174
+ end
175
+
176
+ def chruby?
177
+ ENV["RUBY_ROOT"] # chruby is a shell function not available from inside ruby
178
+ end
179
+
180
+ def rvm_executable
181
+ cache_command("which rvm")
182
+ end
183
+
184
+ def rbenv_executable
185
+ cache_command("which rbenv")
186
+ end
187
+
188
+ def cache_command(command)
189
+ cache(command) do
190
+ if result = capture(command)
191
+ result.strip
192
+ end
193
+ end
194
+ end
195
+
196
+ def chruby_bin_path(version)
197
+ found_version_path = Dir.glob("#{ENV['RUBY_ROOT']}/../*").detect { |p| File.basename(p).include?(version) }
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"
206
+ end
207
+
208
+ def cache(key)
209
+ @cache ||= {}
210
+ if @cache.key?(key)
211
+ @cache[key]
212
+ else
213
+ @cache[key] = yield
214
+ end
215
+ end
216
+
217
+ # set ruby-opts for jruby flavors
218
+ def extract_jruby_rbenv_options!(version)
219
+ if version.sub!("-d19", "")
220
+ "JRUBY_OPTS=--1.9 "
221
+ elsif version.sub!("-d18", "")
222
+ "JRUBY_OPTS=--1.8 "
223
+ end
224
+ end
225
+
226
+ def capture(command)
227
+ result = `#{command}`
228
+ $?.success? ? result : nil
229
+ end
230
+
151
231
  # Taken from https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/script/rvm.rb
152
- def ruby_version(rvm)
232
+ def normalize_ruby_version(rvm)
153
233
  rvm.to_s.
154
234
  gsub(/-(\d{2})mode$/, '-d\1').
155
235
  gsub(/^rbx$/, 'rbx-weekly-d18').
@@ -1,3 +1,3 @@
1
1
  module WWTD
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wwtd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
@@ -29,7 +29,7 @@ cert_chain:
29
29
  y0kCSWmK6D+x/SbfS6r7Ke07MRqziJdB9GuE1+0cIRuFh8EQ+LN6HXCKM5pon/GU
30
30
  ycwMXfl0
31
31
  -----END CERTIFICATE-----
32
- date: 2013-11-11 00:00:00.000000000 Z
32
+ date: 2013-11-13 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: parallel
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  version: '0'
77
77
  requirements: []
78
78
  rubyforge_project:
79
- rubygems_version: 2.0.6
79
+ rubygems_version: 2.0.3
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Travis simulator so you do not need to wait for the build
metadata.gz.sig CHANGED
Binary file