Anise
¶ ↑
Hompage / Report Issue / Source Code / Mailing List / IRC Channel
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 Annotative::Attributes
module.
class X extend Anise::Annotative::Attributes 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::Annotative::Methods 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. Since both AnnotatedMethods
and AnnotatedAttributes
preclude Annotations
all three can be used by simply using the later two.
class X extend Anise::Annotative::Attributes extend Anise::Annotative::Methods ... end
Note also that the Anise
module is clean and contains only modules and classes with detailed names starting the “Annotat-”, so it is prefectly convenient for inclusion in the toplevel namespace or your own applications namespace.
module MyApp include Anise class Foo extend Annotative::Attributes ... end 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 Citron-based unit tests use:
$ rubytest
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.