Columnization of text, using text-reform

Ok, I got text-hyphen and text-reform installed[1], and I looked at
the test case for text-reform. Yes, that’s a great way to start
learning stuff.

I also found a way to adapt it to my uses![2] This is a major
victory. Except…

I have no idea how to break it free from test/unit

It has to do with these two things, I’m sure of it. I know they set
up the r. in the r.format statements… but I don’t know what’s going
on, what they’re called or how to learn more about them. =)

attr_reader :r
@r = Text::Reform.new

[1] http://rubyforge.org/frs/?group_id=294
[2] Register4Less.com Parking Page for jrandomhacker.info

The working script is:

$LOAD_PATH.unshift “…/lib” if FILE == $0

require ‘test/unit’
require ‘text/reform’

class Test__Text_Reform < Test::Unit::TestCase

attr_reader :r
def setup
@r = Text::Reform.new
end

def test_abiglongtext

filename1 = “This is a long filename”
description1 = “desc”
filename2 = “Filename”
description2 = “This is a long description”
filename3 = “This is a long filename”
description3 = “This is a particularly long description”

output = “”
output << “------------------------\n”
output << r.format(“[[[[[[[[[[[ [[[[[[[[[[[”, filename1, description1)
output << “------------------------\n”
output << r.format(“[[[[[[[[[[[ [[[[[[[[[[[”, filename2, description2)
output << “------------------------\n”
output << r.format(“[[[[[[[[[[[ [[[[[[[[[[[”, filename3, description3)
output << “------------------------\n”

puts output

end

end

On 5/14/06, Sy Ali [email protected] wrote:

I have no idea how to break it free from test/unit

Hmm… maybe I need to do some more exploring… I can’t run this script
outside of the test suite. Bleh…

On 5/14/06, Sy Ali [email protected] wrote:

On 5/14/06, Sy Ali [email protected] wrote:

I have no idea how to break it free from test/unit

Hmm… maybe I need to do some more exploring… I can’t run this script
outside of the test suite. Bleh…

Ok, I got it. The remote and local gems were failing to install, and
my playing was using the live reform.rb as a fallback. To install it,
I had to get the tarball and do

ruby install.rb --no-ri

Now back to my original problem. =)

I’m playing with this ‘classes’ stuff:
http://www.rubycentral.com/book/tut_classes.html

The examples aren’t quite working as-expected… but I’m muddling through
it all.

On 5/14/06, Sy Ali [email protected] wrote:

I’m playing with this ‘classes’ stuff:
http://www.rubycentral.com/book/tut_classes.html

The examples aren’t quite working as-expected… but I’m muddling through it all.

Ok, I figured it out. I’m not sure why it works or what’s going on,
but I’ll leave that for later. :wink:

require ‘reform.rb’
r = Text::Reform.new

filename1 = “This is a long filename”
description1 = “desc”
filename2 = “Filename”
description2 = “This is a long description”
filename3 = “This is a long filename”
description3 = “This is a particularly long description”

output = “”
output << “------------------------\n”
output << r.format(“[[[[[[[[[[[ [[[[[[[[[[[”, filename1, description1)
output << “------------------------\n”
output << r.format(“[[[[[[[[[[[ [[[[[[[[[[[”, filename2, description2)
output << “------------------------\n”
output << r.format(“[[[[[[[[[[[ [[[[[[[[[[[”, filename3, description3)
output << “------------------------\n”

puts output