attributes ala java annotations or .Net attributes?

Discussion in 'Ruby' started by Kyle Schmitt, Jul 24, 2007.

  1. Kyle Schmitt

    Kyle Schmitt Guest

    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
     
    Kyle Schmitt, Jul 24, 2007
    #1
    1. Advertising

  2. Kyle Schmitt

    Trans Guest

    On Jul 24, 3:21 pm, "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...
    >
    > 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 :x, :eek:bsolete => true

    def x
    ...
    end
    end

    Y.ann:)x, :eek: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.
     
    Trans, Jul 24, 2007
    #2
    1. Advertising

  3. 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
     
    Ben Bleything, Jul 24, 2007
    #3
  4. Kyle Schmitt

    Kyle Schmitt Guest

    Hum. OK, thanks you two. Maybe if I'm lucky it'll end up in ruby 2.0 ;)
     
    Kyle Schmitt, Jul 24, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Sprague
    Replies:
    4
    Views:
    707
  2. Sambucus
    Replies:
    5
    Views:
    1,038
    Andrew Thompson
    Nov 30, 2004
  3. Mimic

    ALA Updates

    Mimic, Aug 24, 2005, in forum: HTML
    Replies:
    77
    Views:
    2,147
    Mimic
    Aug 29, 2005
  4. Tripredacus-X

    Dynamic content ala HTML

    Tripredacus-X, Feb 11, 2004, in forum: XML
    Replies:
    0
    Views:
    355
    Tripredacus-X
    Feb 11, 2004
  5. Asfand Yar Qazi

    Nested exceptions (ala Java)

    Asfand Yar Qazi, Feb 20, 2006, in forum: C++
    Replies:
    4
    Views:
    603
    Asfand Yar Qazi
    Feb 21, 2006
Loading...

Share This Page