I'm trying to get the ruby version of the (Un)comment command running on my box, and I'm getting the following error:
/Users/wneuman/Library/Dev/TextMate/comment.rb:1: undefined method `extname' for File:Class (NameError)
You say that the script requires Ruby 1.8, and I should be fine there as I've got 1.8.1 installed...
Of course, the amount of Ruby I know would fit handily in my back pocket -- even if I had stuffed my back pocket full of marbles. handkercheifs, and gum wrappers beforehand, so I might just be doing something stupid here. Any ideas on how to fix this?
William D. Neumann
---
"There's just so many extra children, we could just feed the children to these tigers. We don't need them, we're not doing anything with them.
Tigers are noble and sleek; children are loud and messy."
-- Neko Case
Think of XML as Lisp for COBOL programmers.
-- Tony-A (some guy on /.)
It sounds like you need a .bashrc file in your home dir. For some reason, TextMate seems to look there instead of .bash_profile.
It would need to contain:
PATH=/usr/local/bin:$PATH
or wherever your updated (non-apple) version of ruby lives..
On Dec 22, 2004, at 11:17 AM, William D. Neumann wrote:
I'm trying to get the ruby version of the (Un)comment command running on my box, and I'm getting the following error:
/Users/wneuman/Library/Dev/TextMate/comment.rb:1: undefined method `extname' for File:Class (NameError)
You say that the script requires Ruby 1.8, and I should be fine there as I've got 1.8.1 installed...
Of course, the amount of Ruby I know would fit handily in my back pocket -- even if I had stuffed my back pocket full of marbles. handkercheifs, and gum wrappers beforehand, so I might just be doing something stupid here. Any ideas on how to fix this?
William D. Neumann
"There's just so many extra children, we could just feed the children to these tigers. We don't need them, we're not doing anything with them.
Tigers are noble and sleek; children are loud and messy."
-- Neko Case
Think of XML as Lisp for COBOL programmers.
-- Tony-A (some guy on /.) _______________________________________________ textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/mailman/listinfo/textmate
If Ruby 1.8 isn't installed in /usr/bin, you'll need to specify the full path to it. Ruby's default install location is /usr/local, so I'd guess that you need:
/usr/local/bin/ruby -s ...
Or, you could try pasting this compatibility code in at the top of the file:
require 'rbconfig'
major = Config::CONFIG['MAJOR'].to_i minor = Config::CONFIG['MINOR'].to_i
# Check for Ruby less than 1.7 if (major < 2) and (minor < 7) then class File def File.extname(str) m = /.*./.match(File.basename(str)) if m != nil; then "." + m.post_match ; else "" ; end end end end
Chris
On Dec 22, 2004, at 9:17 AM, William D. Neumann wrote:
I'm trying to get the ruby version of the (Un)comment command running on my box, and I'm getting the following error:
/Users/wneuman/Library/Dev/TextMate/comment.rb:1: undefined method `extname' for File:Class (NameError)
You say that the script requires Ruby 1.8, and I should be fine there as I've got 1.8.1 installed...
Of course, the amount of Ruby I know would fit handily in my back pocket -- even if I had stuffed my back pocket full of marbles. handkercheifs, and gum wrappers beforehand, so I might just be doing something stupid here. Any ideas on how to fix this?
William D. Neumann
"There's just so many extra children, we could just feed the children to these tigers. We don't need them, we're not doing anything with them.
Tigers are noble and sleek; children are loud and messy."
-- Neko Case
Think of XML as Lisp for COBOL programmers.
-- Tony-A (some guy on /.) _______________________________________________ textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/mailman/listinfo/textmate
On Wed, 22 Dec 2004, Chris Thomas wrote:
If Ruby 1.8 isn't installed in /usr/bin, you'll need to specify the full path to it. Ruby's default install location is /usr/local, so I'd guess that you need:
/usr/local/bin/ruby -s ...
OK, that fixed the first problem... The ruby in /usr/bin was v1.6.8, and TextMate was using that version instead of the 1.8.1 installed via Fink. However, now that I'm using the correct version, I'm having new, exciting issues...
/Users/wneuman/Library/Dev/TextMate/comment.rb:23: invalid regular expression; there's no previous pattern, to which '*' would define cardinality at 6: /^\s*(*(.*)*)/ (RegexpError)
Im guessing that this problem is stemming from the OCaml comment delimiters being "(*" and "*)", which seem to be messing up the regexp created in line 24 of the script. I'm guessing that they're not being escaped when comment_expr is created, however, escaping them up when they're defined in line 16 (either manually or via Regexp.escape) wraps the block with escaped delimiters "(*" and "*)" -- this also breaks uncommenting.
Any Ruby speakers have a fix for this?
William D. Neumann
---
"There's just so many extra children, we could just feed the children to these tigers. We don't need them, we're not doing anything with them.
Tigers are noble and sleek; children are loud and messy."
-- Neko Case
Think of XML as Lisp for COBOL programmers.
-- Tony-A (some guy on /.)
On Dec 22, 2004, at 11:15 AM, William D. Neumann wrote:
On Wed, 22 Dec 2004, Chris Thomas wrote:
If Ruby 1.8 isn't installed in /usr/bin, you'll need to specify the full path to it. Ruby's default install location is /usr/local, so I'd guess that you need:
/usr/local/bin/ruby -s ...
OK, that fixed the first problem... The ruby in /usr/bin was v1.6.8, and TextMate was using that version instead of the 1.8.1 installed via Fink. However, now that I'm using the correct version, I'm having new, exciting issues...
/Users/wneuman/Library/Dev/TextMate/comment.rb:23: invalid regular expression; there's no previous pattern, to which '*' would define cardinality at 6: /^\s*(*(.*)*)/ (RegexpError)
Im guessing that this problem is stemming from the OCaml comment delimiters being "(*" and "*)", which seem to be messing up the regexp created in line 24 of the script. I'm guessing that they're not being escaped when comment_expr is created, however, escaping them up when they're defined in line 16 (either manually or via Regexp.escape) wraps the block with escaped delimiters "(*" and "*)" -- this also breaks uncommenting.
Any Ruby speakers have a fix for this?
Replace the line:
comment_expr = /^\s*#{regexp_quoted_comments[0]}(.*)#{regexp_quoted_comments[1]}/
With:
# Quote any regexp characters regexp_quoted_comments = comment_strings.map {|string| Regexp.quote(string)}
comment_expr = /^\s*#{regexp_quoted_comments[0]}(.*)#{regexp_quoted_comments[1]}/
Chris
On Wed, 22 Dec 2004, Chris Thomas wrote:
Replace the line:
comment_expr = /^\s*#{regexp_quoted_comments[0]}(.*)#{regexp_quoted_comments[1]}/
With:
# Quote any regexp characters regexp_quoted_comments = comment_strings.map {|string| Regexp.quote(string)}
comment_expr = /^\s*#{regexp_quoted_comments[0]}(.*)#{regexp_quoted_comments[1]}/
Works like a charm. Thanks.
William D. Neumann
---
"There's just so many extra children, we could just feed the children to these tigers. We don't need them, we're not doing anything with them.
Tigers are noble and sleek; children are loud and messy."
-- Neko Case
Think of XML as Lisp for COBOL programmers.
-- Tony-A (some guy on /.)