anise 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ class Module
2
+ # Module extension to return attribute methods. These are all methods
3
+ # that start with `attr_`. This method can be overriden in special cases
4
+ # to work with attribute annotations.
5
+ def attribute_methods
6
+ list = []
7
+ public_methods(true).each do |m|
8
+ list << m if m.to_s =~ /^attr_/
9
+ end
10
+ protected_methods(true).each do |m|
11
+ list << m if m.to_s =~ /^attr_/
12
+ end
13
+ private_methods(true).each do |m|
14
+ list << m if m.to_s =~ /^attr_/
15
+ end
16
+ return list
17
+ end
18
+ end
19
+
@@ -8,6 +8,7 @@ Given a example class X we can apply annotations to it using the #ann method.
8
8
 
9
9
  class X
10
10
  include Anise::Annotation
11
+
11
12
  ann :x1, :a=>1
12
13
  ann :x1, :b=>2
13
14
  end
@@ -1,4 +1,4 @@
1
- = Callbacks
1
+ = Annotation Added Callback
2
2
 
3
3
  Load the annotations, which supports callbacks out of the box.
4
4
 
@@ -0,0 +1,16 @@
1
+ = Annotated Attribute Methods
2
+
3
+ Load the attributes library.
4
+
5
+ require 'anise/attribute'
6
+
7
+ Create a class that includes it.
8
+
9
+ class X
10
+ include Anise::Attribute
11
+
12
+ attr :a, :count => 1
13
+ end
14
+
15
+ X.ann(:a, :count) #=> 1
16
+
@@ -0,0 +1,49 @@
1
+ = Annotators
2
+
3
+ Load the primary annotator library.
4
+
5
+ require 'anise/annotator'
6
+
7
+ Create a class that includes it.
8
+
9
+ class X
10
+ include Anise::Annotator
11
+
12
+ annotator :doc
13
+
14
+ doc "See what I mean?"
15
+
16
+ def see
17
+ puts "Yes, I see!"
18
+ end
19
+ end
20
+
21
+ See that it is set.
22
+
23
+ X.ann(:see, :doc).assert == "See what I mean?"
24
+
25
+ Annotators can override the standard annotation procedure with a
26
+ custom procedure.
27
+
28
+ class Y
29
+ include Anise::Annotator
30
+
31
+ def self.list
32
+ @list ||= []
33
+ end
34
+
35
+ annotator :doc do |method, argument|
36
+ list << [method, argument]
37
+ end
38
+
39
+ doc "See here!"
40
+
41
+ def see
42
+ puts "Yes, I see!"
43
+ end
44
+ end
45
+
46
+ See that it is set.
47
+
48
+ Y.list #=> [[:see, "See here!"]]
49
+
@@ -0,0 +1 @@
1
+ require 'ae/should'
@@ -0,0 +1,30 @@
1
+ = Creating and Reading Annotations
2
+
3
+ Load the primary annotations library.
4
+
5
+ require 'anise/annotation'
6
+
7
+ Including Annotations at the toplevel should make them available to all classes.
8
+
9
+ class ::Object
10
+ include Anise::Annotation
11
+ end
12
+
13
+ Given a example class X we can apply annotations to it using the #ann method.
14
+
15
+ class X
16
+ ann :x1, :a=>1
17
+ ann :x1, :b=>2
18
+ end
19
+
20
+ We can then use #ann to lookup the set annotations.
21
+
22
+ X.ann(:x1,:a).should == 1
23
+
24
+ The #ann method is a public interface, so we can define annotation externally as well.
25
+
26
+ X.ann :x1, :a => 2
27
+ X.ann(:x1, :a).should == 2
28
+
29
+ QED.
30
+
@@ -0,0 +1,20 @@
1
+ = Annotated Attribute Methods
2
+
3
+ Load the attributes library.
4
+
5
+ require 'anise/attribute'
6
+
7
+ Including Anise::Attribute at the toplevel (same as Object).
8
+
9
+ class ::Object
10
+ include Anise::Attribute
11
+ end
12
+
13
+ Create a class that uses it.
14
+
15
+ class X
16
+ attr :a, :count=>1
17
+ end
18
+
19
+ X.ann(:a, :count) #=> 1
20
+
@@ -141,20 +141,18 @@ class Test_Anise_Annotator < Test::Unit::TestCase
141
141
  annotator :req
142
142
 
143
143
  req 'r'
144
-
145
144
  def a ; "a"; end
146
145
 
147
- req 's'
148
-
146
+ req 's', 't'
149
147
  attr :b
150
148
  end
151
149
 
152
150
  def test_annotated
153
- assert_equal( {:req=>['r']}, X.ann(:a) )
151
+ assert_equal( {:req=>'r'}, X.ann(:a) )
154
152
  end
155
153
 
156
154
  def test_annotated
157
- assert_equal( {:req=>['s']}, X.ann(:b) )
155
+ assert_equal( {:req=>['s','t']}, X.ann(:b) )
158
156
  end
159
157
  end
160
158
 
@@ -189,7 +187,7 @@ class Test_Anise_Attribute_Using_Attr_Accessor < Test::Unit::TestCase
189
187
 
190
188
  def test_instance_attributes
191
189
  a = A.new
192
- assert_equal( [:x], A.instance_attributes )
190
+ assert_equal( [:x], A.instance_attributes - [:taguri] )
193
191
  end
194
192
  end
195
193
 
@@ -135,11 +135,9 @@ class Test_Anise_Toplevel_Annotator < Test::Unit::TestCase
135
135
  annotator :req
136
136
 
137
137
  req 'r'
138
-
139
138
  def a ; "a"; end
140
139
 
141
- req 's'
142
-
140
+ req 's', 't'
143
141
  attr :b
144
142
 
145
143
  def initialize
@@ -154,11 +152,11 @@ class Test_Anise_Toplevel_Annotator < Test::Unit::TestCase
154
152
  end
155
153
 
156
154
  def test_annotated_a
157
- assert_equal( {:req=>['r']}, X.ann(:a) )
155
+ assert_equal( {:req=>'r'}, X.ann(:a) )
158
156
  end
159
157
 
160
158
  def test_annotated_b
161
- assert_equal( {:req=>['s']}, X.ann(:b) )
159
+ assert_equal( {:req=>['s', 't']}, X.ann(:b) )
162
160
  end
163
161
  end
164
162
 
@@ -190,7 +188,7 @@ class Test_Anise_Toplevel_Attribute_Using_Attr_Accessor < Test::Unit::TestCase
190
188
 
191
189
  def test_instance_attributes
192
190
  a = A.new
193
- assert_equal( [:x], A.instance_attributes )
191
+ assert_equal( [:x], A.instance_attributes - [:taguri] )
194
192
  end
195
193
  end
196
194
 
@@ -8,20 +8,18 @@ class Test_Annotator < Test::Unit::TestCase
8
8
  annotator :req
9
9
 
10
10
  req 'r'
11
-
12
11
  def a ; "a"; end
13
12
 
14
- req 's'
15
-
13
+ req 'x', 'y'
16
14
  attr :b
17
15
  end
18
16
 
19
17
  def test_annotated
20
- assert_equal( {:req=>['r']}, X.ann(:a) )
18
+ assert_equal( {:req=>'r'}, X.ann(:a) )
21
19
  end
22
20
 
23
21
  def test_annotated
24
- assert_equal( {:req=>['s']}, X.ann(:b) )
22
+ assert_equal( {:req=>['x','y']}, X.ann(:b) )
25
23
  end
26
24
 
27
25
  end
@@ -8,20 +8,18 @@ class Test_Annotator_Toplevel < Test::Unit::TestCase
8
8
  annotator :req
9
9
 
10
10
  req 'r'
11
-
12
11
  def a ; "a"; end
13
12
 
14
- req 's'
15
-
13
+ req 's', 't'
16
14
  attr :b
17
15
  end
18
16
 
19
17
  def test_annotated
20
- assert_equal( {:req=>['r']}, X.ann(:a) )
18
+ assert_equal( {:req=>'r'}, X.ann(:a) )
21
19
  end
22
20
 
23
21
  def test_annotated
24
- assert_equal( {:req=>['s']}, X.ann(:b) )
22
+ assert_equal( {:req=>['s','t']}, X.ann(:b) )
25
23
  end
26
24
 
27
25
  end
@@ -31,7 +31,7 @@ class Test_Attribute_Using_Attr_Accessor < Test::Unit::TestCase
31
31
 
32
32
  def test_01
33
33
  a = A.new
34
- assert_equal( [:x], A.instance_attributes )
34
+ assert_equal( [:x], A.instance_attributes - [:taguri] )
35
35
  end
36
36
  end
37
37
 
@@ -1,4 +1,4 @@
1
- require 'anise/annotation'
1
+ #require 'anise/annotation'
2
2
  require 'anise/attribute'
3
3
 
4
4
  include Anise::Attribute
@@ -31,7 +31,7 @@ class Test_Attribute_Toplevel_Using_Attr_Accessor < Test::Unit::TestCase
31
31
 
32
32
  def test_01
33
33
  a = A.new
34
- assert_equal( [:x], A.instance_attributes )
34
+ assert_equal( [:x], A.instance_attributes - [:taguri] ) # taguri is from YAML :(
35
35
  end
36
36
  end
37
37
 
metadata CHANGED
@@ -1,114 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ hash: 11
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
5
11
  platform: ruby
6
12
  authors:
7
- - tigerops-community@rubyforge.org
8
- - trans <transfire@gmail.com>
13
+ - Thomas Sawyer
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2009-05-28 00:00:00 -04:00
18
+ date: 2011-04-30 00:00:00 -04:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
17
- name: facets
18
- type: :runtime
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
22
+ name: qed
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
21
26
  requirements:
22
- - - ">"
27
+ - - ">="
23
28
  - !ruby/object:Gem::Version
24
- version: 2.4.0
25
- version:
26
- description: Annable is an annotations systems for the Ruby programming lanaguage.
27
- email:
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: syckle
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id002
49
+ description: 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.
50
+ email: transfire@gmail.com
28
51
  executables: []
29
52
 
30
53
  extensions: []
31
54
 
32
55
  extra_rdoc_files:
33
- - README
34
- - MANIFEST
35
- - RELEASE
36
- - HISTORY
37
- - VERSION
38
- - COPYING
56
+ - README.rdoc
39
57
  files:
40
- - lib
41
- - meta
42
- - test
43
- - spec
44
- - MANIFEST
45
- - RELEASE
46
- - README
47
- - HISTORY
48
- - VERSION
49
- - COPYING
50
- - lib/anise
51
- - lib/anise.rb
52
- - lib/anise/attribute.rb
58
+ - .ruby
53
59
  - lib/anise/annotation.rb
54
60
  - lib/anise/annotator.rb
55
- - meta/require
56
- - meta/created
57
- - meta/homepage
58
- - meta/summary
59
- - meta/abstract
60
- - meta/license
61
- - meta/authors
62
- - meta/contact
63
- - test/test_attribute.rb
64
- - test/test_annotator.rb
61
+ - lib/anise/attribute.rb
62
+ - lib/anise/module.rb
63
+ - lib/anise.rb
64
+ - lib/anise.yml
65
+ - qed/01_annotations.qed
66
+ - qed/02_annotation_added.rdoc
67
+ - qed/03_attributes.rdoc
68
+ - qed/04_annotator.rdoc
69
+ - qed/applique/ae.rb
70
+ - qed/toplevel/01_annotations.qed
71
+ - qed/toplevel/03_attributes.rdoc
65
72
  - test/suite.rb
66
- - test/test_annotator_toplevel.rb
67
- - test/test_annotations.rb
68
- - test/test_attribute_toplevel.rb
69
73
  - test/test_anise.rb
70
- - test/test_annotations_module.rb
71
74
  - test/test_anise_toplevel.rb
75
+ - test/test_annotations.rb
76
+ - test/test_annotations_module.rb
72
77
  - test/test_annotations_toplevel.rb
73
- - spec/04_callbacks.rd
74
- - spec/01_annotations.rd
78
+ - test/test_annotator.rb
79
+ - test/test_annotator_toplevel.rb
80
+ - test/test_attribute.rb
81
+ - test/test_attribute_toplevel.rb
82
+ - HISTORY.rdoc
83
+ - APACHE2.txt
84
+ - README.rdoc
85
+ - VERSION
86
+ - COPYING.rdoc
75
87
  has_rdoc: true
76
- homepage: http://
88
+ homepage: http://rubyworks.github.com/anise
89
+ licenses:
90
+ - Apache 2.0
77
91
  post_install_message:
78
92
  rdoc_options:
79
- - --inline-source
80
93
  - --title
81
- - anise api
94
+ - Anise API
82
95
  - --main
83
- - README
96
+ - README.rdoc
84
97
  require_paths:
85
98
  - lib
86
99
  required_ruby_version: !ruby/object:Gem::Requirement
100
+ none: false
87
101
  requirements:
88
102
  - - ">="
89
103
  - !ruby/object:Gem::Version
104
+ hash: 3
105
+ segments:
106
+ - 0
90
107
  version: "0"
91
- version:
92
108
  required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
93
110
  requirements:
94
111
  - - ">="
95
112
  - !ruby/object:Gem::Version
113
+ hash: 3
114
+ segments:
115
+ - 0
96
116
  version: "0"
97
- version:
98
117
  requirements: []
99
118
 
100
119
  rubyforge_project: anise
101
- rubygems_version: 1.2.0
120
+ rubygems_version: 1.3.7
102
121
  signing_key:
103
- specification_version: 2
104
- summary: Annable is an annotations systems for the Ruby programming lanaguage.
105
- test_files:
106
- - test/test_attribute.rb
107
- - test/test_annotator.rb
108
- - test/test_annotator_toplevel.rb
109
- - test/test_annotations.rb
110
- - test/test_attribute_toplevel.rb
111
- - test/test_anise.rb
112
- - test/test_annotations_module.rb
113
- - test/test_anise_toplevel.rb
114
- - test/test_annotations_toplevel.rb
122
+ specification_version: 3
123
+ summary: Dynamic Annotation System
124
+ test_files: []
125
+