Xcode for Ruby, pt 2
A second issue with using Xcode for editing Ruby is that it by default does not correctly comment code in Ruby files. This again is easy to fix: Open the scripts menu, choose Edit User Scripts. Select Comments: Un/Comment Selection This will bring up a Perl script that Xcode uses to perform the comment/uncomment function. We need to modify this to recognize Ruby file types:
Replace:
# determine the type of file we have by looking for the #! line at the top
# careful--it might already be commented out!
my $commentString;
if ($fileString =~ m!^($perlCmt|$cCmt)?#!\s.?/perl|^($perlCmt|$cCmt)?#!\s.?#!\s.?/sh!) {
$commentString = $perlCmt;
} else {
$commentString = $cCmt;
}
with:
my $fileName = "%%%{PBXFilePath}%%%";
# determine the type of file we have by looking for the #! line at the top
# careful--it might already be commented out!
# Otherwise look at the file extension
my $commentString;
if ($fileString =~ m!^($perlCmt|$cCmt)?#!\s.?/perl|^($perlCmt|$cCmt)?#!\s.?/ruby|^($perlCmt|$cCmt)?#!\s.?/sh!
|| $fileName =~ m!.(rb|erb|rake|pl|sh)$!) {
$commentString = $perlCmt;
} else {
$commentString = $cCmt;
}
Tags: programming, ruby, xcode
Any idea if these workarounds will work in Xcode 4? I’ve edited the file types but they haven’t been picked up, and cannot find the files above.
No idea. I’ll be sure to write up what’s needed for Xcode 4 when I get it installed and figure out what’s needed.