- fix warnings generated by Ruby 1.8

- fix to work with ri 1.8
This commit is contained in:
ianmacd 2003-09-17 05:39:21 +00:00
parent 7f00e7f870
commit 1a7e456891

View File

@ -1,12 +1,12 @@
# ri completion for Ruby documentation by Ian Macdonald <ian@caliban.org> # ri completion for Ruby documentation by Ian Macdonald <ian@caliban.org>
# #
# $Id: ri,v 1.1 2002/04/22 07:47:13 ianmacd Exp $ # $Id: ri,v 1.2 2003/09/17 07:39:21 ianmacd Exp $
# #
ri_get_methods() ri_get_methods()
{ {
COMPREPLY=( "$( ri ${classes[@]} | ruby -ane 'if /^-/.../^-/ and \ COMPREPLY=( "$( ri ${classes[@]} | ruby -ane 'if /^-/.../^-/ and \
! /^-/ and ! /^ +(class|module): / then \ ! /^-/ and ! /^ +(class|module): / then \
print $_.strip.split(", ").grep(/^[^[]*$/).join("\n"); \ print $_.strip.split(/, /).grep(/^[^\[]*$/).join("\n"); \
end' | sort -u )" ) end' | sort -u )" )
COMPREPLY=( $( compgen $prefix -W '${COMPREPLY[@]}' -- $method ) ) COMPREPLY=( $( compgen $prefix -W '${COMPREPLY[@]}' -- $method ) )
} }
@ -30,8 +30,14 @@ _ri()
return 0 return 0
fi fi
classes=( $( ri | ruby -ne 'if /^I have/..$stdin.eof then \ if [ "$( ri -v 2>&1 )" = "ri 1.8a" ]; then
if /^ .*[A-Z]/ then print; end; end' ) ) classes=( $( ri | ruby -ne 'if /^'"'"'ri'"'"' has/..$stdin.eof then \
if /^ .*[A-Z]/ then print; end; end' ))
else
classes=( $( ri | ruby -ne 'if /^I have/..$stdin.eof then \
if /^ .*[A-Z]/ then print; end; end' ))
fi
if [[ "$cur" == [A-Z]* ]]; then if [[ "$cur" == [A-Z]* ]]; then
# we're completing on class # we're completing on class
COMPREPLY=( $( compgen -W '${classes[@]}' -- $cur ) ) COMPREPLY=( $( compgen -W '${classes[@]}' -- $cur ) )