Split Pry dependent code from general functionality
Hi, had a lot of fun playing with this lib today! I basically wanted a "cat" for source code. Coderay has a binary, but it and the lib in general seem unmaintained. Looking at theirs, it didn't seem like it'd be much work, so I did it. Then I remembered this lib and figured I'd add syntax highlighting. It went really well, and I'm happy with the result :)
Because it expects Pry to be in place, I did have to do a few hacks, to get it to work:
- I can't load toplevel
pry-theme.rbbecause it usesPry.config.hooks, and requires all the other files, several of which depend on Pry. - Because I can't load it, I have to require the files individually https://github.com/JoshCheek/dotfiles/blob/2e31fece8735897972ec71de2e794806d66aa444/bin/cc#L160-170 which means checking each to see if they depend on pry. This feels really fragile to me. My codebases, at least, tend to have a lot of churn in things like what files and classes exist internally, so it's my most apprehensive part.
- The toplevel
PryTheme.createis in thispry-theme.rb, so I have to copy it into my code before loading plugins https://github.com/JoshCheek/dotfiles/blob/2e31fece8735897972ec71de2e794806d66aa444/bin/cc#L172-177 - I can load ThemeList, but had to check and make sure no code was going to call
activate_theme_intelligently - Because theme loading happens in
pry-theme.rbandwhen_started_hook.rb, I couldn't use that code, so had to locate the files via Rubygems https://github.com/JoshCheek/dotfiles/blob/2e31fece8735897972ec71de2e794806d66aa444/bin/cc#L179-182 - Because
preview.rbuses Pry helpers for formatting output, I had to write my own preview code https://github.com/JoshCheek/dotfiles/blob/2e31fece8735897972ec71de2e794806d66aa444/bin/cc#L223-262
Anyway, figured I'd bring it up. The lib seems like a great idea, and there's no reason it can't be generally available as a theming library for anything using Coderay on the console, just need to move a few things around to separate the idea of Coderay theming from Pry integration. Thanks for making this, btw :)
Hello! I just logged in and noticed this issue (for some reason I didn't get the email notification). This is some neat hackery :)
The idea seems sensible, but like you said, CodeRay isn't maintained: for some unknown reason Ruby people tend to use Pygments. Thanks for the detailed description, by the way.
I'm not closing this issue, but I'm letting you know that currently I don't think I'll be able to work on this due to the combination these two things: lack of time & lack of interest in such a library.
P.S. It may be unmaintained, but korny, the guy who develops it, is nice and usually responds to issues :)