unnali/rouge — pull request #24 by noprompt (2012-12-17 07:50:41+00:00)
Title: Reader fixes, refactoring, documentation, and improved error messages 

This sounds like a hell of a lot more than it really is but let me give you the run down.

I tweaked the handling of numbers to prioritize matching integers and floats. That is, before hexadecimal, binary, and octal numbers. While doing that I discovered the regex for octal numbers was incorrect, so it's been fixed. I also corrected a small mistake in which hexadecimal numbers were being converted to floats. Oh, and bad numbers throw an `NumberFormatError`.

As far as refactoring goes, I added a few utility functions to make the code more expressive. The utility functions and regex constants have been moved from the bottom to just under `private`. I feel like this style of organization is more or less in line with idiomatic Ruby. If you disagree, that's no biggie.

All of the utility methods in `Rouge::Reader` are documented with the exception of `slurp`.

Last of all I wanted to improve upon `Rouge::Reader#reader_raise`. There's still a bit more work to do in that department but here's the idea:

```clojure
; foo.rg
(puts
(+ 1 1.2.3))
```

```shell
$ bin/rouge foo.rg
./lib/rouge/reader.rb:169:in `reader_raise': Invalid number 1.2.3 (Rouge::Reader::NumberFormatError)
(+ 1 1.2.3))
^^^^^
on line 2 at char 7
# ...
```
I've always thought this style of error reporting was helpful. What do you think?