Stack-overflowing

I was going to work on my svn externals management⌥⌫riddance tool.

Then I realized I could quickly parse an unrelated binary file format to extract some unrelated strings to do some unrelated trivial thing.

After quickly succeeding with grep, I noticed I could implement a very elegant solution to my now-non-problem by traversing an array of strings in groups of three. And, simple enough, ActiveSupport’s in_groups_of came to mind. Ever so sadly, I needed traverse in steps of one. For the abstraction-impaired, that means instead of taking 0..2, 3..5, 6..8, and so on, I needed 0..2, 1..3, 2..4, etc.

I actually had in_groups_of_with_step lying around from before Rails implemented their version. But I don’t trust my old self, so I decided to write everything anew, with test cases, because this is the kind of thing that’s chock-full of annoying edge cases.

Which sent me on a research for non-puke-inducing ruby test frameworks. I kinda ran into protest and ended up gem install’ing protest shoulda bacon and decided I’d deal with the matter later.

As I got on with the actual coding, it soon was clear that this feature should be available to all Enumerables. And you’re thinking, like I did, piece of cake, just Enumerable.include MyModule. Right? Right, right?

Well, WRONG! Late inclusion will not affect classes that already included Enumerable. But I am not one to give in easily, so I set out to research a general solution.

And there was much ri, and irb and general REPL.

For those managing the stack at home, here is a simplified overview, so far:

  • module inclusion bonanza
  • test frameworks interlude
  • in_groups_of wankery
  • binary format fu
  • svn externals shennanigans

And that’s how I ended up on Stack Overflow.