Fix for String.unindent() #47

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@sereneiconoclast

I noticed that calling unindent() doesn't do the right thing:

irb(main):001:0> require 'facets/string/unindent'
=> true
irb(main):002:0> " two\n four\n".unindent
=> "two\n four\n"

Note that there is only one space before 'four'; there should be two. With this change, I get the correct output.

I ran the whole test suite and got no failures.

Incidentally, figuring out how to run the tests took a while. It would be nice if Facets include a README-testing.txt file explaining that the tests use a framework called 'Lemon', and where to find it. Google helped me figure that out. The documentation on how to run Lemon tests was also out of date - this page:

https://github.com/rubyworks/lemon/wiki/Running-Tests

...advises running the 'lemon' command, when the real command appears to be called 'lemonade'. And 'lemonade' didn't work for me anyway, producing a LoadError: "no such file to load -- test/cli". I had to run "rubytest -r lemon test" (the docs say "ruby-test" but that was also incorrect). I installed using 'sudo gem install lemon' and got lemon 0.9.0 and rubytest 0.3.1. Let me know if something's wrong with my setup.

@trans
Member
trans commented Apr 27, 2012

I'm not getting this error. What platform and ruby version are you running?

Nonetheless I am willing to use, but I'm not too keen on the private helper method, #common_prefix. I think we can make a slightly different method that could be useful in general for essentially the same purpose. Something like indention(c=' '), which would return the common indention, based on c for each line of a string.

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment