What have you found for these years?

2011-02-27

Dir.glob bug in ruby??? gem tasks handler

I just found that Dir['**/*.rbc'] can't find all *.rbc files recursively.
I know that it won't work under shells, but in ruby it works somehow
It can find _some_ files recursively, but not all. I have no idea why,
probably I just misunderstand it, because this happens both in ruby
1.8.7 and 1.9.2. I didn't check jruby nor rubinius though.

I found this when I was implementing my own gem tasks handler.
Previously, I just used bones for being lazy, but when bones started
requiring little-plugger and loquacious, I was a bit unhappy about that.
(but the author is pretty kind to accept my patches)
And there's a large set of codes in bones, I feet a bit bloated, not
because it was really bloating, but I thought I didn't really need that much.

So I started to try different solutions when implementing ripl-rc.
First I tried tasks in bundler, but I really didn't like it. One reason is
it is using thor, and it's hard to customize it with rake. Another one
is it is still making me feel bloated and it doesn't provide what I
want which is provided in bones.

Then I started on my own. At first I feet my code was a lot cleaner,
but now I feel it is not right somehow. You see, my handler has already
grown to 100 lines, and the logic to handle files is really complicated!
Dir.glob didn't work right. (I now think bones suffers from this, too!)
To emulate .gitignore is not that easy as my thought at first.
I ended up with this really complex gemgem.rb, using Pathname to
walk thorough directories, expanding globs to regexps to ignore files.
You see, I have two recursions!! WTF?? This really should be as simple
as a glob or two! Or I am just too stupid to do it right.

What I want to say here is... this might be really a complicated problem,
no wonder hoe or bones and other gem tasks handler are so many
(actually I didn't really look into hoe, it's been quite a few years now)
lines of codes. It's just hard, not bloated, probably. See ramaze,
it has a ton of tasks code, too. What's wrong with it? This should
be built in rubygems, instead of people implementing it every where...

I wonder if I should file a bug in bones that the .gitignore emulation is
not correct. I found this by looking at `git diff` after running my
gemgem.rb, which acts more like .gitignore. Then it might replace
simple glob with recursions...

Man, I spent too much time doing those extra works!
I just want to do it right :(

[/rant|whining as always]

0 retries:

Post a Comment

Note: Only a member of this blog may post a comment.



All texts are licensed under CC Attribution 3.0