[ANN] CrossCase-0.01

Hi,

I’d like to announce the first release of the ‘CrossCase’ module: a
mixin which auto-generates under_barred aliases for class or instance
methods with names which follow the camelCased naming conventions, and
vice-versa. E.g., in a class which mixes in CrossCase, defining the
#foo_bar method will also create an alias for that method called
#fooBar.

For example:

require 'crosscase’
class MyClass
include CrossCase

  def underbarred_method; ...; end
  def camelCasedMethod; ...; end

end

obj = MyClass::new
obj.underbarredMethod
obj.camel_cased_method

-or-

class MyClass
def underbarred_method; …; end
def camelCasedMethod; …; end
end

require 'crosscase’
MyClass.extend( CrossCase )
obj = MyClass::new
obj.underbarredMethod
obj.camel_cased_method

I wrote this module because I prefer camelCased method names, but also
wish to respect the preferences of my fellow Rubyists for whom such
practices are an abomination. And I’m too lazy to type

alias :twinkle_twinkle :twinkleTwinkle

for every method. It’s all about laziness. Or perhaps I’m catering to
my hubris. Or both; I’ll shut up now.

The project page is at:

http://www.deveiate.org/code/CrossCase.shtml

and may be downloaded from:

http://www.deveiate.org/code/CrossCase-0.01.tar.gz

This module requires Ruby >= 1.8.0; it has not been tested with 1.6.8 +
Ruby-shim, but that may also work as well. Suggestions, bug reports,
and comments welcomed.

···


Michael Granger ged@FaerieMUD.org
Rubymage, Believer, Architect
The FaerieMUD Consortium http://www.FaerieMUD.org/

Michael Granger wrote:

Hi,

I’d like to announce the first release of the ‘CrossCase’ module: a
mixin which auto-generates under_barred aliases for class or instance
methods with names which follow the camelCased naming conventions, and
vice-versa. E.g., in a class which mixes in CrossCase, defining the
#foo_bar method will also create an alias for that method called
#fooBar.

For example:

require ‘crosscase’

Wait - shouldn’t it be “require ‘crossCase’” then?

KIDDING!

Dan

Cool!
Can you also make a module that turns hungarian notation into
human-readable code?

···

On Sat, Jul 26, 2003 at 05:08:57AM +0900, Michael Granger wrote:

Hi,

I’d like to announce the first release of the ‘CrossCase’ module: a
mixin which auto-generates under_barred aliases for class or instance
methods with names which follow the camelCased naming conventions, and
vice-versa. E.g., in a class which mixes in CrossCase, defining the
#foo_bar method will also create an alias for that method called
#fooBar.

For example:

require ‘crosscase’
class MyClass
include CrossCase

def underbarred_method; ...; end
def camelCasedMethod; ...; end

end

obj = MyClass::new
obj.underbarredMethod
obj.camel_cased_method

-or-

class MyClass
def underbarred_method; …; end
def camelCasedMethod; …; end
end

require ‘crosscase’
MyClass.extend( CrossCase )
obj = MyClass::new
obj.underbarredMethod
obj.camel_cased_method

I wrote this module because I prefer camelCased method names, but also
wish to respect the preferences of my fellow Rubyists for whom such
practices are an abomination. And I’m too lazy to type

alias :twinkle_twinkle :twinkleTwinkle

for every method. It’s all about laziness. Or perhaps I’m catering to
my hubris. Or both; I’ll shut up now.

The project page is at:

http://www.deveiate.org/code/CrossCase.shtml

and may be downloaded from:

http://www.deveiate.org/code/CrossCase-0.01.tar.gz

This module requires Ruby >= 1.8.0; it has not been tested with 1.6.8 +
Ruby-shim, but that may also work as well. Suggestions, bug reports,
and comments welcomed.

Michael Granger ged@FaerieMUD.org
Rubymage, Believer, Architect
The FaerieMUD Consortium http://www.FaerieMUD.org/


Daniel Carrera | OpenPGP fingerprint:
Mathematics Dept. | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88
UMD, College Park | http://www.math.umd.edu/~dcarrera/pgp.html

I did something like this when I was working with a Ruby version of
FIT. The FIT tests had to be cross platform (we had teams doing a Java
version), so all the FIT tests used cammelCaseStyle names. I wrote a
module called JavaNames that when mixed-in to a class would allow the
namesLikeThis to automatically try names_like_this. I made the base FIT
fixture include JavaNames, so all derived fixture automatically
supported tests with Ruby-style names or with Java-Style names. I
didn’t write aliases, I just revectored using method_missing
(performance wasn’t an issue for me).

···

On Fri, 2003-07-25 at 16:08, Michael Granger wrote:

Hi,

I’d like to announce the first release of the ‘CrossCase’ module: a
mixin which auto-generates under_barred aliases for class or instance
methods with names which follow the camelCased naming conventions, and
vice-versa.


– Jim Weirich jweirich@one.net http://onestepback.org

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)