anise 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/MANIFEST +19 -19
- data/RELEASE +3 -6
- data/VERSION +1 -1
- data/lib/anise/annotation.rb +15 -8
- data/lib/anise/annotator.rb +12 -5
- data/lib/anise/attribute.rb +3 -3
- metadata +2 -2
data/MANIFEST
CHANGED
@@ -1,18 +1,17 @@
|
|
1
|
-
|
1
|
+
lib
|
2
|
+
meta
|
2
3
|
test
|
3
|
-
|
4
|
-
test/test_annotator.rb
|
5
|
-
test/suite.rb
|
6
|
-
test/test_annotator_toplevel.rb
|
7
|
-
test/test_annotations.rb
|
8
|
-
test/test_attribute_toplevel.rb
|
9
|
-
test/test_anise.rb
|
10
|
-
test/test_anise_toplevel.rb
|
11
|
-
test/test_annotations_toplevel.rb
|
4
|
+
MANIFEST
|
12
5
|
RELEASE
|
13
6
|
README
|
14
7
|
HISTORY
|
15
|
-
|
8
|
+
VERSION
|
9
|
+
COPYING
|
10
|
+
lib/anise
|
11
|
+
lib/anise.rb
|
12
|
+
lib/anise/attribute.rb
|
13
|
+
lib/anise/annotation.rb
|
14
|
+
lib/anise/annotator.rb
|
16
15
|
meta/require
|
17
16
|
meta/created
|
18
17
|
meta/homepage
|
@@ -21,11 +20,12 @@ meta/abstract
|
|
21
20
|
meta/license
|
22
21
|
meta/authors
|
23
22
|
meta/contact
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
test/test_attribute.rb
|
24
|
+
test/test_annotator.rb
|
25
|
+
test/suite.rb
|
26
|
+
test/test_annotator_toplevel.rb
|
27
|
+
test/test_annotations.rb
|
28
|
+
test/test_attribute_toplevel.rb
|
29
|
+
test/test_anise.rb
|
30
|
+
test/test_anise_toplevel.rb
|
31
|
+
test/test_annotations_toplevel.rb
|
data/RELEASE
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
= Anise 0.2.
|
2
|
-
|
3
|
-
This is the first public release of Anise.
|
1
|
+
= Anise 0.2.2 hits the streets.
|
4
2
|
|
5
3
|
Anise is a spin off the the Facets annotations.rb library.
|
6
4
|
It includes the Annotations functionality, and adds
|
@@ -9,8 +7,7 @@ annotations on the fly.
|
|
9
7
|
|
10
8
|
### 0.2.0 // 2008-09-23
|
11
9
|
|
12
|
-
|
10
|
+
1 Major Enhancments
|
13
11
|
|
14
|
-
*
|
15
|
-
* Names of modules are more consistant.
|
12
|
+
* #ann! will auto-prime any referenced annotation if it does not yet exist.
|
16
13
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
anise 0.2.
|
1
|
+
anise 0.2.2 beta (2009-02-11)
|
data/lib/anise/annotation.rb
CHANGED
@@ -37,7 +37,7 @@ module Anise
|
|
37
37
|
# instance_variables.each do |iv|
|
38
38
|
# if validator = self.class.ann(iv)[:valid]
|
39
39
|
# value = instance_variable_get(iv)
|
40
|
-
# unless validator.call(
|
40
|
+
# unless validator.call(value)
|
41
41
|
# raise "Invalid value #{value} for #{iv}"
|
42
42
|
# end
|
43
43
|
# end
|
@@ -50,11 +50,11 @@ module Anise
|
|
50
50
|
# class X
|
51
51
|
# include Anise::Annotation
|
52
52
|
#
|
53
|
-
# ann self, :valid => lambda{ |x| x.is_a?(
|
53
|
+
# ann self, :valid => lambda{ |x| x.is_a?(Enumerable) }
|
54
54
|
# end
|
55
55
|
#
|
56
56
|
# Altough annotations are arbitrary they are tied to the class or
|
57
|
-
# module they are defined
|
57
|
+
# module they are defined against.
|
58
58
|
#
|
59
59
|
#--
|
60
60
|
# TODO: By using a global variable rather the definining a class
|
@@ -111,7 +111,7 @@ module Anise
|
|
111
111
|
|
112
112
|
# Set or read annotations.
|
113
113
|
#
|
114
|
-
def ann(
|
114
|
+
def ann(ref, keys_or_class=nil, keys=nil)
|
115
115
|
return annotation(ref) unless keys_or_class or keys
|
116
116
|
|
117
117
|
if Class === keys_or_class
|
@@ -136,9 +136,11 @@ module Anise
|
|
136
136
|
# it first must be duplicated, otherwise the change may effect annotations
|
137
137
|
# in the class or module's ancestors.
|
138
138
|
#
|
139
|
-
def ann!(
|
139
|
+
def ann!(ref, keys_or_class=nil, keys=nil)
|
140
140
|
#return annotation(ref) unless keys_or_class or keys
|
141
|
-
|
141
|
+
unless keys_or_class or keys
|
142
|
+
return annotations[ref] ||= {}
|
143
|
+
end
|
142
144
|
|
143
145
|
if Class === keys_or_class
|
144
146
|
keys ||= {}
|
@@ -154,7 +156,12 @@ module Anise
|
|
154
156
|
annotations[ref].update(keys)
|
155
157
|
else
|
156
158
|
key = keys.to_sym
|
157
|
-
annotations[ref]
|
159
|
+
annotations[ref] ||= {}
|
160
|
+
begin
|
161
|
+
annotations[ref][key] = annotation(ref)[key].dup
|
162
|
+
rescue TypeError
|
163
|
+
annotations[ref][key] = annotation(ref)[key]
|
164
|
+
end
|
158
165
|
end
|
159
166
|
end
|
160
167
|
|
@@ -163,4 +170,4 @@ module Anise
|
|
163
170
|
end
|
164
171
|
|
165
172
|
# 2006-11-07 trans Created this ultra-concise version of annotations.
|
166
|
-
# Copyright (c) 2005, 2008 TigerOps
|
173
|
+
# Copyright (c) 2005, 2008 TigerOps
|
data/lib/anise/annotator.rb
CHANGED
@@ -3,8 +3,8 @@ module Anise
|
|
3
3
|
|
4
4
|
# = Annotator
|
5
5
|
#
|
6
|
-
# Annotator allows for the creation of dynamic method
|
7
|
-
# annotations which attach to the next method defined.
|
6
|
+
# Annotator allows for the creation of dynamic <i>method
|
7
|
+
# annotations</i> which attach to the next method defined.
|
8
8
|
#
|
9
9
|
# require 'anise/annotator'
|
10
10
|
#
|
@@ -22,9 +22,16 @@ module Anise
|
|
22
22
|
#
|
23
23
|
# X.ann(:see, :doc) #=> "See what I mean?"
|
24
24
|
#
|
25
|
-
|
26
|
-
#
|
27
|
-
|
25
|
+
# This idiom of annotator before definition was popularized by
|
26
|
+
# Rake's desc/task pair. Annotator makes it very easy to add
|
27
|
+
# similar capabilites to any program.
|
28
|
+
#
|
29
|
+
# The library uses the #method_added callback, so be sure to
|
30
|
+
# respect good practices of calling +super+ if you need to override
|
31
|
+
# this method while using Annotator.
|
32
|
+
#
|
33
|
+
# TODO: Ensure thread safety of the internal <code>@pending_annotations</code> variable.
|
34
|
+
#
|
28
35
|
module Annotator
|
29
36
|
|
30
37
|
def self.append_features(base)
|
data/lib/anise/attribute.rb
CHANGED
@@ -8,8 +8,8 @@ module Anise
|
|
8
8
|
# This framework modifies the major attr_* methods to allow easy
|
9
9
|
# addition of annotations. It modifies the built in attribute methods
|
10
10
|
# (attr, attr_reader, attr_writer and attr_accessor), to allow
|
11
|
-
# annotations to added to them directly rather than
|
12
|
-
# separate #ann statement.
|
11
|
+
# annotations to be added to them directly rather than requiring
|
12
|
+
# a separate #ann statement.
|
13
13
|
#
|
14
14
|
# require 'anise/attribute'
|
15
15
|
#
|
@@ -22,7 +22,7 @@ module Anise
|
|
22
22
|
# See annotation.rb for more information.
|
23
23
|
#
|
24
24
|
# NOTE: This library was designed to be backward compatible with
|
25
|
-
#
|
25
|
+
# the standard versions of the same methods.
|
26
26
|
#
|
27
27
|
module Attribute
|
28
28
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tigerops-community@rubyforge.org
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2009-02-11 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|