/anise

Dynamic Annotations System for Ruby

Primary LanguageRubyOtherNOASSERTION

Anise

Introduction

Anise is an Annotation System for the Ruby programming language. Unlike most other annotations systems it is not a comment-based or macro-based system that sits over-and-above the rest of the code. Rather, Anise is a dynamic annotations system operating at runtime.

Installation

To install with RubyGems simply open a console and type:

gem install anise

To manually install you will need Setup.rb (see setup.rubyforge.org). Then download the tarball package and do:

$ tar -xvzf anise-0.2.0.tgz
$ cd anise-0.2.0
$ sudo setup.rb all

Instruction

The following example briefly demonstrates all three major features. To use any of them first require the ‘anise` library.

require 'anise'

General annotations are provided by the ‘Anise::Annotations` module.

class X
  extend Anise::Annotations

  ann :grape, :class=>String
end

X.ann(:grape, :class)  #=> String

Annotated attributes can be easily added to a class via the ‘AnnotatedAttributes` module.

class X
  extend Anise::AnnotatedAttributes

  attr :baz, Integer, :max => 10
end

X.ann(:baz)  #=> {:class=>Integer, :max=>10}

Mewthod annotations can be had via the ‘AnnotatedMethods` module.

class X
  extend Anise::AnnotatedMethods

  def self.doc(string)
    method_annotation(:doc=>string)
  end

  doc "This is an entry."

  def bar
    # ...
  end
end

X.ann(:bar)  #=> {:doc=>"This is an entry."}

Any of these modules can be used in conjunction, as well. The ‘AnnotatedComplex` module is provided as a convenience to using the all in one go.

class X
  extend Anise::AnnotatedComplex
end

Development

Test Instructions

Ainse has two test suites, one using QED and the other using Citron which is built on RubyTest.

To run the QED demonstrations simple run:

$ qed

To run the unit tests use:

$ rubytest

See the QED homepage for more informaiton about QED.

Copyrights

Copyright © 2008 Rubyworks. All rights reserved.

This program is distributed under the terms of the BSD-2-Clause license.

See LICNESE.txt file for details.