You will note, if you look at this code, that I write very unsophisticated text parsers.

I did use pattern-matching in this at least briefly, and I wrote some RSpec matchers that made testing this code easier.

2
Share
Share on Mastodon
Share on Twitter
Share on Facebook
Share on Linkedin
Lucian Ghinda

@noelrap this sounds good. I might take inspiration from it as I kinda want to be able to parse a Gemfile and extract a list of source codes as they are defined at rubygems.

And the first step was just to parse the Gemfile

0
1y
Noel Rappin

My original hope was actually to instance_eval the gemfile, which is what bundler does, but with my own handler to capture the information for the sort. But I decided that would be harder, especially for managing comments.

By far the goofiest code in the existing gem is the code that pulls a `group` or `source` from an inline gem so it can normalize it with blocks — that would probably have been easier with instance_eval, because Ruby would have parsed it.

1
1y
Replies