Skip to content

Commit c550d36

Browse files
authored
Merge pull request #32 from rvm/support_truffleruby
Add support for truffleruby
2 parents f5ad527 + 90c553c commit c550d36

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ matrix:
3131
env: WITH_RUBYGEMS=1.6.2
3232
- rvm: 2.5
3333
env: TEST_SUFFIX=-bundle
34+
- rvm: 2.5
35+
env: TEST_SUFFIX=-truffleruby
3436
- rvm: 1.8.7
3537
- rvm: 1.9.2
3638
- rvm: 1.9.3

bin/ruby_executable_hooks

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,14 @@ rescue LoadError
1212
warn "unable to load executable-hooks/hooks" if ENV.key?('ExecutableHooks_DEBUG')
1313
end unless $0.end_with?('/executable-hooks-uninstaller')
1414

15-
eval File.read($0), binding, $0
15+
content = File.read($0)
16+
17+
if
18+
(index = content.index("\n#!ruby\n")) && index > 0
19+
then
20+
skipped_content = content.slice!(0..index)
21+
start_line = skipped_content.count("\n") + 1
22+
eval content, binding, $0, start_line
23+
else
24+
eval content, binding, $0
25+
end

lib/executable-hooks/wrapper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def install_from(full_gem_path)
3535
bindir = calculate_bindir(options)
3636
destination = calculate_destination(bindir)
3737

38-
if File.exist?(wrapper_path) && !File.exist?(destination)
38+
if File.exist?(wrapper_path)
3939
FileUtils.mkdir_p(bindir) unless File.exist?(bindir)
4040
# exception based on Gem::Installer.generate_bin
4141
raise Gem::FilePermissionError.new(bindir) unless File.writable?(bindir)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
gem install executable-hooks-$(awk -F'"' '/VERSION/{print $2}' < lib/executable-hooks/version.rb).gem --development
2+
# match=/installed/
3+
4+
gem install haml -v "4.0.7" # match=/installed/
5+
haml_bin=$(which haml )
6+
head -n 1 $haml_bin # match=/ruby_executable_hooks/
7+
8+
## simulate truffleruby style binary with shell code mixed in
9+
## \043 - is a # ... somehow it breaks tf
10+
( head -n 1 $haml_bin; echo -e 'echo $HOME\n\043!ruby'; tail -n +2 $haml_bin ) > $haml_bin.new
11+
mv $haml_bin.new $haml_bin
12+
chmod +x $haml_bin
13+
14+
haml _4.0.7_ -v # match=/4.0.7/
15+
16+
gem uninstall -x haml -v 4.0.7 # match=/Successfully uninstalled/

0 commit comments

Comments
 (0)