22 Aug 2009 » Facets 2.7 is a Significant Release

Facets 2.7 is most significant release of Facets since 2.4. Rather then trickle-release these changes over the course of the 2.6.x series, I made the decision to let 2.7 have them all at once. In so doing this release nearly completes the process of trimming down the MORE library to its essentials. Over 40 high-level libraries have been spun-off as separate gems and/or deprecated. No doubt this is a big change for Facets, and the transition may be a bit bumpy over the short-term, but I am certain that in the long-run everyone involved will be better served. To help, I have listed the effected libraries and the alternate gems available to take their place.

A few other changes have also been made in the release that may also effect your code. In particular you should note that #class_extension has been renamed to #class_extend (require 'facets/class_extend'). In addition we have added a few new core methods such as Exception#raised? and Symbol#thrown?.

Spun-Off Projects

These libraries have been deprecated from Facets entirely, but are available as separate gems (or soon will be).

LIBRARY               GEM
-------------------   -------------------------
overload.rb           overload
binreadable.rb        binaryio
downloader.rb         downloader
xoxo.rb               xoxo
bicrypt.rb            bicrypt
typecast.rb           typecast
association.rb        association
syncarray.rb          sync
synchash.rb           sync
paramix.rb            paramix
crypt.rb              crypt3
lrucache.rb           lrucache
net/smtp_tls.rb       smtp_tls
advisable.rb          advisable
buildable.rb          buildable
memoizer.rb           memoizer
harray.rb             sparray
sparse_array.rb       sparray
iteration.rb          iteration
interval.rb           stick
infinity.rb           stick
pool.rb               pool
linkedlist.rb         linkedlist
semaphore.rb          semaphore
pqueue.rb             pqueue
censor.rb             language
macther.rb            language
basex.rb              radix
minitar.rb            archive-tar-minitar, folio

Spun-Off But Still Available

These libraries have been spun-off into stand-alone gems, but remain available via Facets too. Ultimately some of these will be removed from Facets too (in particular the ansi libraries).

LIBRARY               GEM
-------------------   -------------------------
ansicode.rb           ansi
progressbar.rb        ansi
logger.rb             ansi
tracepoint.rb         tracepoint
dictionary.rb         dictionary
recorder.rb           recorder
ostructable.rb        ostructable, openhash
openobject.rb         openhash
opencollection.rb     openhash
opencascade.rb        openhash
openhash.rb           openhash
openmodule.rb         openmodule
fileable.rb           fileable
expirable.rb          expirable
enumerablepass.rb     enumargs

Deprecations Without Current Replacement

The libraries have been deprecated but do not yet have replacements. Separate gems for these are planned though.

* bbcode.rb
* ini.rb
* settings.rb
* xmlhash.rb

Deprecations Merged Into CORE

These libraries have been deprecated because their functionality was merged into the CORE library and/or made available in some another way.

* 1stclassmethod.rb   #method! and #instance_method! are now part of CORE.
* elementor.rb        #per has been added to CORE.
* elementwise.rb      #ewise has been added to CORE.
* consoleutils.rb     #ask is in CORE, for the rest see Ansi or Clio project.
* attr.rb             Added Module#attr_setter to CORE, and separated the rest in MORE.

General Deprecations

These libraries have simply been deprecated because they were found lacking in some significant fashion.

* nilstatus.rb        Poved rather useless, not to mention trivial.
* heap.rb             Heap was just an alias for PQueue anyway. Use 'pqueue' instead.
* dependency.rb       Other solutions exist that are much better (like Advisable).
* classmethods.rb     #class_extend solution is more robust.
* ziputils.rb         Have a look at Folio (gem install folio) for replacement.
* unheritable.rb      Implementation is trivial and usefulness questionable.
* instantise.rb       Replaced by instance_function.rb.

In addition to all this we've also taken some time to ensure Ruby Facets is more compatible with Ruby 1.9 --indeed, at this point, it should be very close to fully compatibility. In the process of doing this, btw, it has become clear that Ruby 1.9 picked up a good number of methods already supported by Facets (some with the same exact names and some with changed names). There's no way to know if Facets had any influence in these additions to 1.9, but at the very least we can be sure that Facets contributed to "airing the field" that led to their addition. That's a great thing, as it means Facets is directly contributing to Ruby's future. I hope that will continue.


21 Jul 2009 » New Website with Jekyll

The old Ruby Facets website was a static 100% XML/XSLT site. When I originally created the site, I though XML/XSLT suredly was the pinnicale and proper way to build a modern site --for no other reason that XSL is a pain in the ass! Well, we all know the ultimate outcome of this story. XML/XSLT is turning out to be an exmplar of over engineering by academics.

The new Facets website runs of Jekyll, a static site generator supoprted by GitHub. (another good site tool is Shunman)


10 Oct 2008 » I Spy String#margin

Perhaps you've come across that occasional need to assign a string that was more pictorial in character than textual. [ Pun intended :-) ] You've tried Ruby's various built-in string constructors, including those groovy HERE documents, you even tried letting the HERE text butt up against column zero. Ick! In the end you either had line after line of str << "....", counted "\n"s or said, "Heck wit it!". And loaded from a file. Well, no longer! Facets contains a great little String method called #margin. It works like this:

  x = %Q{
        | This
        |     is
        |       margin controlled!
        }.margin

Of course you can use HERE documents if you prefer.

  x = <<-HERE.margin
        | This
        |     is
        |       margin controlled!
        HERE

If you dislike the particular deliminator '|', or actually need to start lines with that character, then just pick another.

  x = %Q{ This
        -     is
        -       margin controlled too!
        }.margin

The trick? It uses the first non-whitespace character on the 2nd line(tm). Clever, eh?

But wait. There's more! #margin also takes a parameter, with which you can specify the number of extra spaces to insert in place of the deliminator. So even if you need to push some ascii art text over 30 characters, there's no need for all that whitespace. Just specify the number.

Hope you've enjoyed this Spotlight. Now you too can produce nice and readable margin controlled strings in your code too with ease!


04 Apr 2008 » I Spy Integer#times_collect

The method #collect, or its alias #map if your prefer, is one of the most useful methods in Rubyland. You see it all the time. Unfortunately it isn't applicable to a number of common variants of iteration. One of these is Integer#times. So Facets provided just such a method.

  require 'facets/integer/times_collect'

  bottles = 99.times_collect { |i|
    "Bottle of Beer No. #{i}"
  }

This is also aliased as times_map. But if either of these method names strikes you as too long then you might find this alternate (required separately) more convenient:

  require 'facets/integer/of'

  bottles = 99.of { |i|
    "Bottle of Beer No. #{i}"
  }

Take one down, pass it around!


01 Jan 2008 » How Facets Was Born

As programmers are wont to do, I started collecting reusable pieces of Ruby long ago. At first it was just a small function here, a useful module there. Eventually the collection became sizable and I called it TomsLib. As time wore on and my library grew, I started to feel it worth a general release and I had renamed it Raspberry Lib. But sometime shortly thereafter I hit upon the idea of atomicityof the core extensions. And that's how the name Facets came about -- it's all about the little things. Of course, that name took a while to decide upon too. The library was almost called "Atomix & Trix"!

Facets has eveolved considerably over the years --and lessons were learned. Probably the biggest lesson was the 2.0 release, where the idea of atomicity was eroded and and alternate means of library requiring was attempted. Both were rectified by 2.4.

Much has changed since those first days. But time has been good to Facets. Today, Facets is a more solid and leaner library than ever before and will continue in the fashion for version to come.