Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > attributes ala java annotations or .Net attributes?

Reply
Thread Tools

attributes ala java annotations or .Net attributes?

 
 
Kyle Schmitt
Guest
Posts: n/a
 
      07-24-2007
Does ruby have attributes ala java annotations or .Net attributes?
I've never seen them in use, hence my wondering.
Right now I've got a pretty big test-suite written in ruby & watir,
and I've got alot of old code in it. It would be nice if I just was
able to put in something like an [obsolete]/<obsolete> tag, and have
it just ignored, or have a warning popup automatically to say "Your'e
using an obsolete method, get with it!", or to bip me on the head...

Is there anything like this?

Thanks,
Kyle

 
Reply With Quote
 
 
 
 
Trans
Guest
Posts: n/a
 
      07-24-2007


On Jul 24, 3:21 pm, "Kyle Schmitt" <(E-Mail Removed)> wrote:
> Does ruby have attributes ala java annotations or .Net attributes?
> I've never seen them in use, hence my wondering.
> Right now I've got a pretty big test-suite written in ruby & watir,
> and I've got alot of old code in it. It would be nice if I just was
> able to put in something like an [obsolete]/<obsolete> tag, and have
> it just ignored, or have a warning popup automatically to say "Your'e
> using an obsolete method, get with it!", or to bip me on the head...
>
> Is there anything like this?


Facets has an annotations system, but of course it's not an built-in
part of ruby. So it simply supplies a general way to tag you code.
It's up to you to actually make it do something. Basic example:

require 'facets/annotations'

class Y

ann , bsolete => true

def x
...
end
end

Y.ann(, bsolete) #=> true

So to use that to ignore methods, I suppose you'd want to use
ObjectSpect.each_object(Class) to loop through the classes and
undefine obsolete methods. For warnings, you could wrap them instead.

T.


 
Reply With Quote
 
 
 
 
Ben Bleything
Guest
Posts: n/a
 
      07-24-2007
On Wed, Jul 25, 2007, Kyle Schmitt wrote:
> Does ruby have attributes ala java annotations or .Net attributes?
> I've never seen them in use, hence my wondering.
> Right now I've got a pretty big test-suite written in ruby & watir,
> and I've got alot of old code in it. It would be nice if I just was
> able to put in something like an [obsolete]/<obsolete> tag, and have
> it just ignored, or have a warning popup automatically to say "Your'e
> using an obsolete method, get with it!", or to bip me on the head...


It's not exactly what you're looking for, but there's a library called
'deprecated' that can be used to achieve that sort of result:

http://rubyforge.org/projects/deprecated/

Ben

 
Reply With Quote
 
Kyle Schmitt
Guest
Posts: n/a
 
      07-24-2007
Hum. OK, thanks you two. Maybe if I'm lucky it'll end up in ruby 2.0

 
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
Java annotations and XML files G. Java 3 02-13-2007 07:38 PM
Function metadata (like Java annotations) in Python oripel Python 8 09-10-2006 04:10 PM
Nested exceptions (ala Java) Asfand Yar Qazi C++ 4 02-21-2006 08:31 AM
Java Annotations not working ??? chvid@acm.org Java 3 01-25-2005 10:25 AM
Any interest in lightweight coroutines in Java ala C# 2.0 iterators? Ken Sprague Java 4 10-28-2003 08:03 PM



Advertisments