anise 0.6.0 → 0.7.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.
- data/.ruby +59 -38
- data/.yardopts +7 -0
- data/DEMO.md +242 -0
- data/{HISTORY.rdoc → HISTORY.md} +28 -7
- data/LICENSE.txt +27 -0
- data/README.md +129 -0
- data/demo/01_annotations.md +81 -0
- data/demo/03_attributes.md +14 -0
- data/demo/04_methods.md +50 -0
- data/demo/05_variables.md +45 -0
- data/{qed → demo}/applique/ae.rb +0 -0
- data/demo/applique/anise.rb +1 -0
- data/{qed/toplevel/01_annotations.qed → demo/toplevel/01_annotations.md} +5 -9
- data/demo/toplevel/03_attributes.md +20 -0
- data/lib/anise.rb +28 -45
- data/lib/anise.yml +59 -38
- data/lib/anise/annotations.rb +132 -0
- data/lib/anise/annotations/store.rb +136 -0
- data/lib/anise/annotative.rb +7 -0
- data/lib/anise/annotative/attributes.rb +147 -0
- data/lib/anise/annotative/methods.rb +131 -0
- data/lib/anise/annotative/variables.rb +99 -0
- data/lib/anise/{module.rb → core_ext.rb} +30 -0
- data/lib/anise/universal.rb +6 -0
- data/lib/anise/version.rb +17 -0
- data/test/case_annotations.rb +173 -0
- data/test/case_attributes.rb +46 -0
- data/test/case_combined_usage.rb +341 -0
- data/test/case_methods.rb +36 -0
- data/test/case_variables.rb +22 -0
- data/test/helper.rb +2 -0
- metadata +99 -98
- data/APACHE2.txt +0 -204
- data/COPYING.rdoc +0 -17
- data/README.rdoc +0 -107
- data/lib/anise/annotation.rb +0 -175
- data/lib/anise/annotator.rb +0 -82
- data/lib/anise/attribute.rb +0 -138
- data/qed/01_annotations.qed +0 -26
- data/qed/02_annotation_added.rdoc +0 -60
- data/qed/03_attributes.rdoc +0 -16
- data/qed/04_annotator.rdoc +0 -49
- data/qed/toplevel/03_attributes.rdoc +0 -20
- data/test/suite.rb +0 -8
- data/test/test_anise.rb +0 -193
- data/test/test_anise_toplevel.rb +0 -194
- data/test/test_annotations.rb +0 -136
- data/test/test_annotations_module.rb +0 -132
- data/test/test_annotations_toplevel.rb +0 -131
- data/test/test_annotator.rb +0 -26
- data/test/test_annotator_toplevel.rb +0 -28
- data/test/test_attribute.rb +0 -37
- data/test/test_attribute_toplevel.rb +0 -65
data/test/test_annotations.rb
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
require 'anise/annotation'
|
2
|
-
|
3
|
-
class Test_Annotation_0 < Test::Unit::TestCase
|
4
|
-
class X
|
5
|
-
include Anise::Annotation
|
6
|
-
|
7
|
-
attr :a
|
8
|
-
|
9
|
-
ann :@a, :valid => lambda{ |x| x.is_a?(Integer) }
|
10
|
-
|
11
|
-
ann :a, :class => Integer
|
12
|
-
|
13
|
-
def initialize(a)
|
14
|
-
@a = a
|
15
|
-
end
|
16
|
-
|
17
|
-
def validate
|
18
|
-
instance_variables.each do |iv|
|
19
|
-
if validator = self.class.ann(iv)[:valid]
|
20
|
-
value = instance_variable_get(iv)
|
21
|
-
unless validator.call(value)
|
22
|
-
raise "Invalid value #{value} for #{iv}"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_annotation_class
|
30
|
-
assert_equal(Integer, X.ann(:a, :class))
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_annotation_validate
|
34
|
-
x = X.new(1)
|
35
|
-
assert_nothing_raised{ x.validate }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class Test_Annotation_1 < Test::Unit::TestCase
|
40
|
-
class X
|
41
|
-
include Anise::Annotation
|
42
|
-
def x1 ; end
|
43
|
-
ann :x1, :a=>1
|
44
|
-
ann :x1, :b=>2
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_1_01
|
48
|
-
assert_equal( X.ann(:x1,:a), X.ann(:x1,:a) )
|
49
|
-
assert_equal( X.ann(:x1,:a).object_id, X.ann(:x1,:a).object_id )
|
50
|
-
end
|
51
|
-
def test_1_02
|
52
|
-
X.ann :x1, :a => 2
|
53
|
-
assert_equal( 2, X.ann(:x1,:a) )
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
class Test_Annotation_2 < Test::Unit::TestCase
|
58
|
-
class X
|
59
|
-
include Anise::Annotation
|
60
|
-
def x1 ; end
|
61
|
-
ann :x1, :a=>1
|
62
|
-
ann :x1, :b=>2
|
63
|
-
end
|
64
|
-
class Y < X ; end
|
65
|
-
|
66
|
-
def test_2_01
|
67
|
-
assert_equal( Y.ann(:x1,:a), Y.ann(:x1,:a) )
|
68
|
-
assert_equal( Y.ann(:x1,:a).object_id, Y.ann(:x1,:a).object_id )
|
69
|
-
end
|
70
|
-
def test_2_02
|
71
|
-
assert_equal( 1, Y.ann(:x1,:a) )
|
72
|
-
assert_equal( 2, Y.ann(:x1,:b) )
|
73
|
-
end
|
74
|
-
def test_2_03
|
75
|
-
Y.ann :x1,:a => 2
|
76
|
-
assert_equal( 2, Y.ann(:x1,:a) )
|
77
|
-
assert_equal( 2, Y.ann(:x1,:b) )
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
class Test_Annotation_3 < Test::Unit::TestCase
|
82
|
-
class X
|
83
|
-
include Anise::Annotation
|
84
|
-
ann :foo, Integer
|
85
|
-
end
|
86
|
-
class Y < X
|
87
|
-
ann :foo, String
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_3_01
|
91
|
-
assert_equal( Integer, X.ann(:foo, :class) )
|
92
|
-
end
|
93
|
-
def test_3_02
|
94
|
-
assert_equal( String, Y.ann(:foo, :class) )
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
class Test_Annotation_4 < Test::Unit::TestCase
|
99
|
-
class X
|
100
|
-
include Anise::Annotation
|
101
|
-
ann :foo, :doc => "hello"
|
102
|
-
ann :foo, :bar => []
|
103
|
-
end
|
104
|
-
class Y < X
|
105
|
-
ann :foo, :class => String, :doc => "bye"
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_4_01
|
109
|
-
assert_equal( "hello", X.ann(:foo,:doc) )
|
110
|
-
end
|
111
|
-
def test_4_02
|
112
|
-
assert_equal( X.ann(:foo), { :doc => "hello", :bar => [] } )
|
113
|
-
end
|
114
|
-
def test_4_03
|
115
|
-
X.ann(:foo,:bar) << "1"
|
116
|
-
assert_equal( ["1"], X.ann(:foo,:bar) )
|
117
|
-
end
|
118
|
-
def test_4_04
|
119
|
-
assert_equal( "bye", Y.ann(:foo,:doc) )
|
120
|
-
end
|
121
|
-
def test_4_05
|
122
|
-
#assert_equal( nil, Y.ann(:foo,:bar) )
|
123
|
-
assert_equal( ["1"], Y.ann(:foo,:bar) )
|
124
|
-
end
|
125
|
-
def test_4_06
|
126
|
-
Y.ann(:foo, :doc => "cap")
|
127
|
-
assert_equal( "cap", Y.ann(:foo, :doc) )
|
128
|
-
end
|
129
|
-
def test_4_07
|
130
|
-
Y.ann!(:foo,:bar) << "2"
|
131
|
-
assert_equal( ["1", "2"], Y.ann(:foo,:bar) )
|
132
|
-
assert_equal( ["1", "2"], Y.ann(:foo,:bar) )
|
133
|
-
assert_equal( ["1"], X.ann(:foo,:bar) )
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
@@ -1,132 +0,0 @@
|
|
1
|
-
require 'anise/annotation'
|
2
|
-
|
3
|
-
class Module
|
4
|
-
include Anise::Annotation
|
5
|
-
end
|
6
|
-
|
7
|
-
class Test_Annotation_Toplevel_0 < Test::Unit::TestCase
|
8
|
-
class X
|
9
|
-
attr :a
|
10
|
-
ann :a, :class => Integer
|
11
|
-
ann :@a, :valid => lambda{ |x| x.is_a?(Integer) }
|
12
|
-
|
13
|
-
def initialize(a)
|
14
|
-
@a = a
|
15
|
-
end
|
16
|
-
|
17
|
-
def validate
|
18
|
-
instance_variables.each do |iv|
|
19
|
-
if validator = self.class.ann(iv)[:valid]
|
20
|
-
value = instance_variable_get(iv)
|
21
|
-
unless validator.call(value)
|
22
|
-
raise "Invalid value #{value} for #{iv}"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_annotation_class
|
30
|
-
assert_equal(Integer, X.ann(:a, :class))
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_annotation_validate
|
34
|
-
x = X.new(1)
|
35
|
-
assert_nothing_raised{ x.validate }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class Test_Annotation_Toplevel_1 < Test::Unit::TestCase
|
40
|
-
class X
|
41
|
-
def x1 ; end
|
42
|
-
ann :x1, :a=>1
|
43
|
-
ann :x1, :b=>2
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_1_01
|
47
|
-
assert_equal( X.ann(:x1,:a), X.ann(:x1,:a) )
|
48
|
-
assert_equal( X.ann(:x1,:a).object_id, X.ann(:x1,:a).object_id )
|
49
|
-
end
|
50
|
-
def test_1_02
|
51
|
-
X.ann :x1, :a => 2
|
52
|
-
assert_equal( 2, X.ann(:x1,:a) )
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
class Test_Annotation_Toplevel_2 < Test::Unit::TestCase
|
57
|
-
class X
|
58
|
-
def x1 ; end
|
59
|
-
ann :x1, :a=>1
|
60
|
-
ann :x1, :b=>2
|
61
|
-
end
|
62
|
-
class Y < X ; end
|
63
|
-
|
64
|
-
def test_2_01
|
65
|
-
assert_equal( Y.ann(:x1,:a), Y.ann(:x1,:a) )
|
66
|
-
assert_equal( Y.ann(:x1,:a).object_id, Y.ann(:x1,:a).object_id )
|
67
|
-
end
|
68
|
-
def test_2_02
|
69
|
-
assert_equal( 1, Y.ann(:x1,:a) )
|
70
|
-
assert_equal( 2, Y.ann(:x1,:b) )
|
71
|
-
end
|
72
|
-
def test_2_03
|
73
|
-
Y.ann :x1,:a => 2
|
74
|
-
assert_equal( 2, Y.ann(:x1,:a) )
|
75
|
-
assert_equal( 2, Y.ann(:x1,:b) )
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
class Test_Annotation_Toplevel_3 < Test::Unit::TestCase
|
80
|
-
class X
|
81
|
-
ann :foo, Integer
|
82
|
-
end
|
83
|
-
class Y < X
|
84
|
-
ann :foo, String
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_3_01
|
88
|
-
assert_equal( Integer, X.ann(:foo, :class) )
|
89
|
-
end
|
90
|
-
def test_3_02
|
91
|
-
assert_equal( String, Y.ann(:foo, :class) )
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
class Test_Annotation_Toplevel_4 < Test::Unit::TestCase
|
96
|
-
class X
|
97
|
-
ann :foo, :doc => "hello"
|
98
|
-
ann :foo, :bar => []
|
99
|
-
end
|
100
|
-
class Y < X
|
101
|
-
ann :foo, :class => String, :doc => "bye"
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_4_01
|
105
|
-
assert_equal( "hello", X.ann(:foo,:doc) )
|
106
|
-
end
|
107
|
-
def test_4_02
|
108
|
-
assert_equal( X.ann(:foo), { :doc => "hello", :bar => [] } )
|
109
|
-
end
|
110
|
-
def test_4_03
|
111
|
-
X.ann(:foo,:bar) << "1"
|
112
|
-
assert_equal( ["1"], X.ann(:foo,:bar) )
|
113
|
-
end
|
114
|
-
def test_4_04
|
115
|
-
assert_equal( "bye", Y.ann(:foo,:doc) )
|
116
|
-
end
|
117
|
-
def test_4_05
|
118
|
-
#assert_equal( nil, Y.ann(:foo,:bar) )
|
119
|
-
assert_equal( ["1"], Y.ann(:foo,:bar) )
|
120
|
-
end
|
121
|
-
def test_4_06
|
122
|
-
Y.ann(:foo, :doc => "cap")
|
123
|
-
assert_equal( "cap", Y.ann(:foo, :doc) )
|
124
|
-
end
|
125
|
-
def test_4_07
|
126
|
-
Y.ann!(:foo,:bar) << "2"
|
127
|
-
assert_equal( ["1", "2"], Y.ann(:foo,:bar) )
|
128
|
-
assert_equal( ["1", "2"], Y.ann(:foo,:bar) )
|
129
|
-
assert_equal( ["1"], X.ann(:foo,:bar) )
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
@@ -1,131 +0,0 @@
|
|
1
|
-
require 'anise/annotation'
|
2
|
-
|
3
|
-
include Anise::Annotation
|
4
|
-
|
5
|
-
class Test_Annotation_Toplevel_0 < Test::Unit::TestCase
|
6
|
-
class X
|
7
|
-
attr :a
|
8
|
-
ann :a, :class => Integer
|
9
|
-
ann :@a, :valid => lambda{ |x| x.is_a?(Integer) }
|
10
|
-
|
11
|
-
def initialize(a)
|
12
|
-
@a = a
|
13
|
-
end
|
14
|
-
|
15
|
-
def validate
|
16
|
-
instance_variables.each do |iv|
|
17
|
-
if validator = self.class.ann(iv)[:valid]
|
18
|
-
value = instance_variable_get(iv)
|
19
|
-
unless validator.call(value)
|
20
|
-
raise "Invalid value #{value} for #{iv}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_annotation_class
|
28
|
-
assert_equal(Integer, X.ann(:a, :class))
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_annotation_validate
|
32
|
-
x = X.new(1)
|
33
|
-
assert_nothing_raised{ x.validate }
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
class Test_Annotation_Toplevel_1 < Test::Unit::TestCase
|
39
|
-
class X
|
40
|
-
def x1 ; end
|
41
|
-
ann :x1, :a=>1
|
42
|
-
ann :x1, :b=>2
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_1_01
|
46
|
-
assert_equal( X.ann(:x1,:a), X.ann(:x1,:a) )
|
47
|
-
assert_equal( X.ann(:x1,:a).object_id, X.ann(:x1,:a).object_id )
|
48
|
-
end
|
49
|
-
def test_1_02
|
50
|
-
X.ann :x1, :a => 2
|
51
|
-
assert_equal( 2, X.ann(:x1,:a) )
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
class Test_Annotation_Toplevel_2 < Test::Unit::TestCase
|
56
|
-
class X
|
57
|
-
def x1 ; end
|
58
|
-
ann :x1, :a=>1
|
59
|
-
ann :x1, :b=>2
|
60
|
-
end
|
61
|
-
class Y < X ; end
|
62
|
-
|
63
|
-
def test_2_01
|
64
|
-
assert_equal( Y.ann(:x1,:a), Y.ann(:x1,:a) )
|
65
|
-
assert_equal( Y.ann(:x1,:a).object_id, Y.ann(:x1,:a).object_id )
|
66
|
-
end
|
67
|
-
def test_2_02
|
68
|
-
assert_equal( 1, Y.ann(:x1,:a) )
|
69
|
-
assert_equal( 2, Y.ann(:x1,:b) )
|
70
|
-
end
|
71
|
-
def test_2_03
|
72
|
-
Y.ann :x1,:a => 2
|
73
|
-
assert_equal( 2, Y.ann(:x1,:a) )
|
74
|
-
assert_equal( 2, Y.ann(:x1,:b) )
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
class Test_Annotation_Toplevel_3 < Test::Unit::TestCase
|
79
|
-
class X
|
80
|
-
ann :foo, Integer
|
81
|
-
end
|
82
|
-
class Y < X
|
83
|
-
ann :foo, String
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_3_01
|
87
|
-
assert_equal( Integer, X.ann(:foo, :class) )
|
88
|
-
end
|
89
|
-
def test_3_02
|
90
|
-
assert_equal( String, Y.ann(:foo, :class) )
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
class Test_Annotation_Toplevel_4 < Test::Unit::TestCase
|
95
|
-
class X
|
96
|
-
ann :foo, :doc => "hello"
|
97
|
-
ann :foo, :bar => []
|
98
|
-
end
|
99
|
-
class Y < X
|
100
|
-
ann :foo, :class => String, :doc => "bye"
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_4_01
|
104
|
-
assert_equal( "hello", X.ann(:foo,:doc) )
|
105
|
-
end
|
106
|
-
def test_4_02
|
107
|
-
assert_equal( X.ann(:foo), { :doc => "hello", :bar => [] } )
|
108
|
-
end
|
109
|
-
def test_4_03
|
110
|
-
X.ann(:foo,:bar) << "1"
|
111
|
-
assert_equal( ["1"], X.ann(:foo,:bar) )
|
112
|
-
end
|
113
|
-
def test_4_04
|
114
|
-
assert_equal( "bye", Y.ann(:foo,:doc) )
|
115
|
-
end
|
116
|
-
def test_4_05
|
117
|
-
#assert_equal( nil, Y.ann(:foo,:bar) )
|
118
|
-
assert_equal( ["1"], Y.ann(:foo,:bar) )
|
119
|
-
end
|
120
|
-
def test_4_06
|
121
|
-
Y.ann(:foo, :doc => "cap")
|
122
|
-
assert_equal( "cap", Y.ann(:foo, :doc) )
|
123
|
-
end
|
124
|
-
def test_4_07
|
125
|
-
Y.ann!(:foo,:bar) << "2"
|
126
|
-
assert_equal( ["1", "2"], Y.ann(:foo,:bar) )
|
127
|
-
assert_equal( ["1", "2"], Y.ann(:foo,:bar) )
|
128
|
-
assert_equal( ["1"], X.ann(:foo,:bar) )
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
data/test/test_annotator.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'anise/annotator'
|
2
|
-
|
3
|
-
class Test_Annotator < Test::Unit::TestCase
|
4
|
-
|
5
|
-
class X
|
6
|
-
include Anise::Annotator
|
7
|
-
|
8
|
-
annotator :req
|
9
|
-
|
10
|
-
req 'r'
|
11
|
-
def a ; "a"; end
|
12
|
-
|
13
|
-
req 'x', 'y'
|
14
|
-
attr :b
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_annotated
|
18
|
-
assert_equal( {:req=>'r'}, X.ann(:a) )
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_annotated
|
22
|
-
assert_equal( {:req=>['x','y']}, X.ann(:b) )
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'anise/annotator'
|
2
|
-
|
3
|
-
include Anise::Annotator
|
4
|
-
|
5
|
-
class Test_Annotator_Toplevel < Test::Unit::TestCase
|
6
|
-
|
7
|
-
class X
|
8
|
-
annotator :req
|
9
|
-
|
10
|
-
req 'r'
|
11
|
-
def a ; "a"; end
|
12
|
-
|
13
|
-
req 's', 't'
|
14
|
-
attr :b
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_annotated
|
18
|
-
assert_equal( {:req=>'r'}, X.ann(:a) )
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_annotated
|
22
|
-
assert_equal( {:req=>['s','t']}, X.ann(:b) )
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
#annotator :req # THIS DOES NOT WORK :(
|
28
|
-
|