Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [ANN] Joker -- Wildcards for Ruby

Reply
Thread Tools

[ANN] Joker -- Wildcards for Ruby

 
 
Fabian Streitel
Guest
Posts: n/a
 
      09-09-2009
[Note: parts of this message were removed to make it a legal post.]

Hi folks,
I'm proudly presenting:

# Joker #

http://karottenreibe.github.com/joker

Joker is a Wildcard implementation for Ruby.

## Features ##

* Behaves much like Regexp
* ` * ` and ` ? ` as wildcard characters
* ` \ ` for escaping
* `\a` matches `\a`, but not `a`
* Wildcards must always match whole string
* Wildcards can be case insensitive

Visit the website to see a small example etc.

Greetz!

 
Reply With Quote
 
 
 
 
James Edward Gray II
Guest
Posts: n/a
 
      09-09-2009
On Sep 9, 2009, at 12:55 PM, Fabian Streitel wrote:

> I'm proudly presenting:
>
> # Joker #
>
> http://karottenreibe.github.com/joker
>
> Joker is a Wildcard implementation for Ruby.
>
> ## Features ##
>
> * Behaves much like Regexp
> * ` * ` and ` ? ` as wildcard characters
> * ` \ ` for escaping
> * `\a` matches `\a`, but not `a`
> * Wildcards must always match whole string
> * Wildcards can be case insensitive


Can you suggest why someone would use this instead of a regular
expression?

James Edward Gray II


 
Reply With Quote
 
 
 
 
Fabian Streitel
Guest
Posts: n/a
 
      09-09-2009
[Note: parts of this message were removed to make it a legal post.]

because "non-computer people" ( might find wildcards more easily
understandable than regular expressions.

This is of course not meant as a replacement for regexps when you're
writing code but rather as a way to interface with people who don't
know about regexps

think directory listings, search queries etc.

Greetz!

2009/9/9 James Edward Gray II <(E-Mail Removed)>

> On Sep 9, 2009, at 12:55 PM, Fabian Streitel wrote:
>
>
> Can you suggest why someone would use this instead of a regular expression?
>
> James Edward Gray II
>
>
>


 
Reply With Quote
 
Fabian Streitel
Guest
Posts: n/a
 
      09-10-2009
[Note: parts of this message were removed to make it a legal post.]

> Note that these are known as "glob patterns" -- you might want to update
> your documentation accordingly (http://en.wikipedia.org/wiki/Glob_pattern)
>


Ah, thx, I've been searching for the correct name of these but couldn't find
it.
The only thing I've ever heard was "Wildcard".


>
> Also, your rdocs seem to be missing a few backslashes:
>
> * '?' matches a single character
> * '*' matches any number of characters, including 0
> (1) * '*' matches a literal '*'
> * '\?' matches a literal '?'
> (2) * '\' matches a literal '\'
>
> 1 should be: '\*' matches a literal '*'
> 2 should be: '\\' matches a literal '\'
>
> You could generalize by saying:
> * '\x' matches the literal character 'x', even if 'x' is a wildcard
> character.
>


I'll do that.


>
> You haven't implemented bracket expressions: '[cb]at*' should match
> 'catch' and 'batch' but not 'match'
>


I'll look into that.

Thanks for the feedback!

 
Reply With Quote
 
Fabian Streitel
Guest
Posts: n/a
 
      09-10-2009
[Note: parts of this message were removed to make it a legal post.]

Whoops overlooked one:

You could generalize by saying:
> * '\x' matches the literal character 'x', even if 'x' is a wildcard
> character.
>
>

That's exactly not what my implementation does. Since I had the library in
mind as
a way to interact with users who don't know about Regular Expressions, I
wanted
to keep it as simple as possible.

Thus, the Ruby String "fo\\o" fed to the Wildcard class would be equivalent
to /^fo\\o$/
but I'm not sure if that was a wise decision. The reasoning behind it was,
that users woudn't
have to type things like
C:\\foo\\bar\\goo
but rather only
C:\foo\bar\goo
since f b and g are no special characters.

Does that make sense? What do you think? Which approach to take or should
there be an option
and if so what's the wiser default?
Greetz!

 
Reply With Quote
 
Joel VanderWerf
Guest
Posts: n/a
 
      09-10-2009

Just a thought... ruby already has globbing functions in dir.c, but they
apparently work only on dirs. Maybe they could be abstracted in to a
library that works on strings or arrays of strings.

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

 
Reply With Quote
 
Fabian Streitel
Guest
Posts: n/a
 
      09-11-2009
[Note: parts of this message were removed to make it a legal post.]

>
> Just a thought... ruby already has globbing functions in dir.c, but they
> apparently work only on dirs. Maybe they could be abstracted in to a library
> that works on strings or arrays of strings.
>
>


Honestly: I have no idea what's going on in that file...
That's just too complicated C magic whuzzing around in there.

But a problem with that approach -- as far as I can tell -- is that
matching a glob against a string and matching it against the
file system are 2 different things. Especially since "/" or "\" have
special meaning in file systems and allow for splitting of the glob
string into small subsections, whose matching against files is much
easier.
Also dir.c has the special "**" glob, which doesn't make and sense
in string matching.

Greetz!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ANN] joker-1.0.0 Fabian Streitel Ruby 2 10-16-2009 03:21 PM
wildcards ? Martin Bilgrav Cisco 2 09-05-2005 06:24 PM
Batman Beyond: Return of Joker Uncut OAR? Dick Sidbury DVD Video 7 08-18-2004 07:18 PM
DataView filters with wildcards DotNetJunkies User ASP .Net 0 05-24-2004 09:25 PM
Negative Lookbehind and Wildcards Thomas F. O'Connell Perl 1 02-28-2004 01:50 PM



Advertisments