goto_string
by Max Muermann ([email protected])
http://rubyforge.org/projects/rails-oceania/

== DESCRIPTION:

goto_string is a small library that implements a substring matching and ranking algorithm. The matching and ranking is similar to that found in Quicksilver or TextMate

== FEATURES/PROBLEMS:

* Partial string matching
* The algorithm is not particularly performant

== SYNOPSIS:

require 'goto_string'

s = %w(goto_string is a small library that implements a substring matching and ranking algorithm. The matching and ranking is similar to that found in Quicksilver or TextMate)
GotoString::Matcher.match('string', s) #=> [["goto_string", "goto_string", 0.679259259259259, [["string", 5]]], ["substring", "substring", 0.461481481481481, [["s", 0], ["tring", 4]]]]

An array is returned which contains one entry for each match. Matches are ordered by rank.

Each match is itself an array, containing the following elements:

[ "original candidate", "matched string", rank, [["substring_1", offset], ["substring_2", offset], ... ] ]

You can optionally pass a block to the match method which will get each candidate passed to it. The return value of the block is what will be used for matching. This is so you can pass in arrays of complex objects as candidates:

GotoString::Matcher.match( "goto", Project.find(:all) ) do |p|
p.name
end

The resulting matches will contain a reference to the matched string (the project name) as well as the project (the original candidate)

== REQUIREMENTS:

* None

== INSTALL:

* sudo gem install goto_string

== LICENSE:

(The MIT License)

Copyright (c) 2007 FIX

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.