expiration-date 1.0.0 → 1.0.1
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/History.txt +6 -0
- data/Rakefile +1 -1
- data/lib/expiration-date.rb +3 -2
- data/spec/expiration-date_spec.rb +20 -1
- metadata +2 -2
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ PROJ.url = 'http://codeforpeople.rubyforge.org/expiration-date'
|
|
14
14
|
PROJ.rubyforge.name = 'codeforpeople'
|
15
15
|
PROJ.rdoc.remote_dir = 'expiration-date'
|
16
16
|
PROJ.version = ExpirationDate::VERSION
|
17
|
-
PROJ.release_name = '
|
17
|
+
PROJ.release_name = 'Buggy Bacon'
|
18
18
|
|
19
19
|
PROJ.spec.opts << '--color'
|
20
20
|
|
data/lib/expiration-date.rb
CHANGED
@@ -4,7 +4,7 @@ require 'thread'
|
|
4
4
|
module ExpirationDate
|
5
5
|
|
6
6
|
# :stopdoc:
|
7
|
-
VERSION = '1.0.
|
7
|
+
VERSION = '1.0.1'
|
8
8
|
ExpirationLabel = Struct.new(:mutex, :age, :expires_on)
|
9
9
|
# :startdoc:
|
10
10
|
|
@@ -57,7 +57,8 @@ module ExpirationDate
|
|
57
57
|
if label.expires_on.nil? || now >= label.expires_on
|
58
58
|
label.mutex.synchronize {
|
59
59
|
break unless label.expires_on.nil? || now >= label.expires_on
|
60
|
-
|
60
|
+
block = ::#{self.name}._managers_specials[#{name.inspect}]
|
61
|
+
@#{name} = instance_eval(&block)
|
61
62
|
label.age ||= #{age}
|
62
63
|
label.expires_on = now + label.age
|
63
64
|
}
|
@@ -6,6 +6,7 @@ class TestA
|
|
6
6
|
|
7
7
|
expiring_attr(:foo, 0.5) { 'foo' }
|
8
8
|
expiring_attr('bar', 10 ) { 'bar' }
|
9
|
+
expiring_attr(:me, 60 ) { self }
|
9
10
|
end
|
10
11
|
|
11
12
|
|
@@ -39,6 +40,19 @@ describe ExpirationDate do
|
|
39
40
|
a.bar.should == 'bar'
|
40
41
|
end
|
41
42
|
|
43
|
+
it 'can assign an attribute' do
|
44
|
+
a = TestA.new
|
45
|
+
a.foo.should == 'foo'
|
46
|
+
|
47
|
+
foobar = 'foobar'
|
48
|
+
a.foo = foobar
|
49
|
+
a.foo.should be_equal(foobar)
|
50
|
+
|
51
|
+
sleep 0.75
|
52
|
+
a.foo.should_not be_equal(foobar)
|
53
|
+
a.foo.should == 'foo'
|
54
|
+
end
|
55
|
+
|
42
56
|
it 'can alter an expiration label' do
|
43
57
|
a = TestA.new
|
44
58
|
bar = a.bar
|
@@ -60,7 +74,7 @@ describe ExpirationDate do
|
|
60
74
|
bar.should_not be_equal(a.bar)
|
61
75
|
end
|
62
76
|
|
63
|
-
it 'ignores requests on unknown expriation
|
77
|
+
it 'ignores requests on unknown expriation labels' do
|
64
78
|
a = TestA.new
|
65
79
|
|
66
80
|
h = a.expiration_labels
|
@@ -72,6 +86,11 @@ describe ExpirationDate do
|
|
72
86
|
a.alter_expiration_label(:foobar, 42)
|
73
87
|
h.keys.length == 2
|
74
88
|
end
|
89
|
+
|
90
|
+
it 'executes the block in the context of the instance' do
|
91
|
+
a = TestA.new
|
92
|
+
a.me.should be_equal(a)
|
93
|
+
end
|
75
94
|
end
|
76
95
|
|
77
96
|
# EOF
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expiration-date
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Pease
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-08-
|
12
|
+
date: 2008-08-23 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|