This post originated from an RSS feed registered with Ruby Buzz
by Trans Onoma.
Original Post: To Hell With Oranges
Feed Title: TRANSONOMA
Feed URL: http://feeds.feedburner.com/transonoma
Feed Description: A Light Green Agile Programming and SciTech Blog
As some of you already know. I did a complete one-eighty on my last post. I was resigned to the fact that I would have to maintain two projects --the extension methods were just not meshing well with the additions modules. But then someone starts talking some smack about Facets on ruby-talk, and I'm like, "Damn it I'm going to make it work!" And so I did! :)
I took a two-prong approach. First, I went with my previous setup. I kept the libs separate under lib/facets/core and lib/facets/more, and created redirection files under lib/facet/ which tie back to both of these. 'facet/' is the require location that should generally be used. Don't use facets/core/ and facets/more/ directly. That way the facets/ directory (notice the plural) will remain independent of end-user requires and can be reorganized if need be without causing any backward incompatabilities. This works well, albeit it does create an additional level of indirection. (It's just too bad Windows doesn't support symlinks --those would be even better.)
The second tactic is in facets.rb itself. While this is an optional file, by requiring it you not only get a dozen or so common core extenions automatically, it also adds Facet's core/ and more/ lib paths to Ruby's lookup path. That way the initial 'facet/' prefix isn't even needed. Eg.
require 'facets' require 'functor'
It adds lib paths to the end of the lookup path so they won't interfer with any other library. If there is a name conflict you can always use the prefix to get at the facet.