glue 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +66 -0
- data/README +1 -1
- data/Rakefile +148 -5
- data/doc/RELEASES +32 -1
- data/install.rb +1 -1
- data/lib/glue.rb +6 -6
- data/lib/glue/array.rb +2 -2
- data/lib/glue/aspects.rb +237 -0
- data/lib/glue/attribute.rb +1 -10
- data/lib/glue/cache.rb +2 -2
- data/lib/glue/dynamic_include.rb +5 -2
- data/lib/glue/flexob.rb +8 -1
- data/lib/glue/hash.rb +2 -2
- data/lib/glue/inflector.rb +1 -1
- data/lib/glue/logger.rb +2 -2
- data/lib/glue/misc.rb +1 -15
- data/lib/glue/mixins.rb +2 -2
- data/lib/glue/number.rb +2 -2
- data/lib/glue/object.rb +1 -1
- data/lib/glue/pool.rb +2 -2
- data/lib/glue/property.rb +21 -20
- data/lib/glue/string.rb +3 -3
- data/lib/glue/time.rb +2 -2
- data/lib/glue/validation.rb +20 -20
- data/test/glue/tc_aspects.rb +101 -0
- data/test/glue/tc_cache.rb +6 -6
- data/test/glue/tc_hash.rb +3 -5
- data/test/glue/tc_numbers.rb +6 -8
- data/test/glue/tc_property.rb +1 -3
- data/test/glue/tc_property_mixins.rb +4 -9
- data/test/glue/tc_property_type_checking.rb +1 -1
- data/test/glue/tc_strings.rb +35 -36
- data/test/glue/tc_validation.rb +4 -3
- data/vendor/breakpoint.rb +1 -1
- data/vendor/breakpoint_client.rb +1 -1
- metadata +37 -55
@@ -0,0 +1,101 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'glue/aspects'
|
5
|
+
|
6
|
+
include Glue
|
7
|
+
|
8
|
+
class TestCaseAspects < Test::Unit::TestCase # :nodoc: all
|
9
|
+
|
10
|
+
class Monitor
|
11
|
+
def self.pre(this)
|
12
|
+
this.ma = 2
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.post(this)
|
16
|
+
this.mb = 5
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module Localize
|
21
|
+
def localize
|
22
|
+
@ll = 5
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module Tester
|
27
|
+
include Aspects
|
28
|
+
|
29
|
+
attr_accessor :ta
|
30
|
+
pre { |this| this.ta = 5 }
|
31
|
+
end
|
32
|
+
|
33
|
+
class Dummy
|
34
|
+
include Aspects
|
35
|
+
include Tester
|
36
|
+
|
37
|
+
attr_accessor :a, :b, :c
|
38
|
+
attr_accessor :oa, :ob
|
39
|
+
attr_accessor :ma, :mb
|
40
|
+
attr_accessor :ll
|
41
|
+
attr_accessor :pa
|
42
|
+
|
43
|
+
pre :pre_advice
|
44
|
+
wrap Monitor
|
45
|
+
wrap Localize, :pre => :localize
|
46
|
+
post { |this| this.pa = 3 }
|
47
|
+
|
48
|
+
def initialize
|
49
|
+
@a = 0
|
50
|
+
end
|
51
|
+
|
52
|
+
def hello(q)
|
53
|
+
@a += 1 + q
|
54
|
+
end
|
55
|
+
|
56
|
+
def pre_advice
|
57
|
+
@b = 1
|
58
|
+
@a += 1
|
59
|
+
end
|
60
|
+
|
61
|
+
def post_advice
|
62
|
+
@c = 1
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
# Class aspect.
|
68
|
+
|
69
|
+
class Observer < Aspect
|
70
|
+
def self.pre(this)
|
71
|
+
this.oa = 9
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Instance aspect.
|
76
|
+
|
77
|
+
class Epilogue < Aspect
|
78
|
+
def post(this)
|
79
|
+
this.ob = 9
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_all
|
84
|
+
Observer.wrap(Dummy, :hello)
|
85
|
+
Epilogue.new.wrap(Dummy, :hello)
|
86
|
+
Aspects.wrap(Dummy, :hello)
|
87
|
+
|
88
|
+
d = Dummy.new
|
89
|
+
d.hello(3)
|
90
|
+
assert_equal 5, d.a
|
91
|
+
assert_equal 1, d.b
|
92
|
+
assert_equal 9, d.oa
|
93
|
+
assert_equal 9, d.ob
|
94
|
+
assert_equal 2, d.ma
|
95
|
+
assert_equal 5, d.mb
|
96
|
+
assert_equal 5, d.ll
|
97
|
+
assert_equal 3, d.pa
|
98
|
+
assert_equal 5, d.ta
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
data/test/glue/tc_cache.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'test/unit'
|
2
|
+
require 'glue/cache'
|
3
3
|
|
4
|
-
class TC_Glue_Cache < Test::Unit::TestCase
|
5
|
-
|
4
|
+
class TC_Glue_Cache < Test::Unit::TestCase # :nodoc: all
|
5
|
+
include Glue
|
6
6
|
|
7
7
|
class Dummy
|
8
|
-
include
|
8
|
+
include LRUCache::Item
|
9
9
|
end
|
10
10
|
|
11
11
|
def setup
|
12
|
-
@cache =
|
12
|
+
@cache = LRUCache.new(maxitems = 3)
|
13
13
|
end
|
14
14
|
|
15
15
|
def teardown
|
data/test/glue/tc_hash.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
|
-
# :nodoc: all
|
2
|
-
|
3
1
|
require "test/unit"
|
4
2
|
require "glue/hash"
|
5
3
|
|
6
|
-
class
|
7
|
-
|
4
|
+
class TestCaseGlueCache < Test::Unit::TestCase # :nodoc: all
|
5
|
+
include Glue
|
8
6
|
|
9
7
|
def setup
|
10
|
-
@safe_cache =
|
8
|
+
@safe_cache = SafeHash.new(Hash.new)
|
11
9
|
end
|
12
10
|
|
13
11
|
def teardown
|
data/test/glue/tc_numbers.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
|
1
|
+
require 'test/unit'
|
2
|
+
require 'glue/number'
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
class TC_N_NumberUtils < Test::Unit::TestCase
|
7
|
-
# :nodoc: all
|
4
|
+
class TestCaseNumberUtils < Test::Unit::TestCase # :nodoc: all
|
5
|
+
include Glue
|
8
6
|
|
9
7
|
def setup
|
10
8
|
end
|
@@ -13,8 +11,8 @@ class TC_N_NumberUtils < Test::Unit::TestCase
|
|
13
11
|
end
|
14
12
|
|
15
13
|
def test_ceil_multiple
|
16
|
-
assert_equal(20,
|
17
|
-
assert_equal(10,
|
14
|
+
assert_equal(20, NumberUtils.ceil_multiple(15, 10))
|
15
|
+
assert_equal(10, NumberUtils.ceil_multiple(1, 10))
|
18
16
|
end
|
19
17
|
|
20
18
|
end
|
data/test/glue/tc_property.rb
CHANGED
@@ -6,8 +6,6 @@ require 'og'
|
|
6
6
|
require 'glue/logger'
|
7
7
|
require 'glue/property'
|
8
8
|
|
9
|
-
include N
|
10
|
-
|
11
9
|
def VarChar(size)
|
12
10
|
return String, :sql => "VARCHAR(#{ size })"
|
13
11
|
end
|
@@ -95,4 +93,4 @@ class TC_N_Properties < Test::Unit::TestCase
|
|
95
93
|
|
96
94
|
end
|
97
95
|
|
98
|
-
end
|
96
|
+
end
|
@@ -1,15 +1,10 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
|
4
|
-
#--
|
5
|
-
# Thomas Quas <tquas@yahoo.com>
|
6
|
-
# George Moschovitis <gm@navel.gr>
|
7
|
-
# $Id$
|
8
|
-
#++
|
1
|
+
# * Thomas Quas <tquas@yahoo.com>
|
2
|
+
# * George Moschovitis <gm@navel.gr>
|
3
|
+
# $Id: tc_property_mixins.rb 1 2005-04-11 11:04:30Z gmosx $
|
9
4
|
|
10
5
|
$LOAD_PATH.unshift 'lib'
|
11
6
|
|
12
|
-
require
|
7
|
+
require 'test/unit'
|
13
8
|
require 'glue/property'
|
14
9
|
|
15
10
|
module Mixin
|
data/test/glue/tc_strings.rb
CHANGED
@@ -1,30 +1,29 @@
|
|
1
|
-
# :nodoc: all
|
2
1
|
|
3
|
-
require
|
4
|
-
require
|
2
|
+
require 'test/unit'
|
3
|
+
require 'glue/string'
|
5
4
|
|
6
|
-
class
|
7
|
-
|
5
|
+
class TCStringUtilsUtils < Test::Unit::TestCase # :nodoc: all
|
6
|
+
include Glue
|
8
7
|
|
9
8
|
def setup
|
10
9
|
@s = "this is any cool test"
|
11
10
|
end
|
12
11
|
|
13
12
|
def test_valid?
|
14
|
-
assert_equal(true,
|
15
|
-
assert_equal(false,
|
16
|
-
assert_equal(false,
|
13
|
+
assert_equal(true, StringUtils.valid?("test"))
|
14
|
+
assert_equal(false, StringUtils.valid?(""))
|
15
|
+
assert_equal(false, StringUtils.valid?(nil))
|
17
16
|
end
|
18
17
|
|
19
18
|
def test_head
|
20
|
-
assert_equal(nil,
|
21
|
-
assert_equal("this...",
|
22
|
-
assert_equal("this+++",
|
23
|
-
assert_equal("thi...",
|
24
|
-
assert_equal("this is...",
|
25
|
-
assert_equal(nil,
|
26
|
-
assert_equal(nil,
|
27
|
-
assert_equal("this is...",
|
19
|
+
assert_equal(nil, StringUtils.head(nil))
|
20
|
+
assert_equal("this...", StringUtils.head(@s, 3))
|
21
|
+
assert_equal("this+++", StringUtils.head(@s, 3, false, "+++"))
|
22
|
+
assert_equal("thi...", StringUtils.head(@s, 3, true))
|
23
|
+
assert_equal("this is...", StringUtils.head(@s, 8))
|
24
|
+
assert_equal(nil, StringUtils.head(@s, 0))
|
25
|
+
assert_equal(nil, StringUtils.head(@s, 0, true))
|
26
|
+
assert_equal("this is...", StringUtils.head(@s, 8, true))
|
28
27
|
end
|
29
28
|
|
30
29
|
def test_rewrite
|
@@ -34,65 +33,65 @@ class TC_StringUtilsUtils < Test::Unit::TestCase
|
|
34
33
|
[/^games/, "../../games"],
|
35
34
|
[/^tmp/, "/n/theseas/var/tmp"],
|
36
35
|
]
|
37
|
-
string =
|
36
|
+
string = StringUtils.rewrite("games/arkanoid.html", rules)
|
38
37
|
assert_equal("../../games/arkanoid.html", string)
|
39
|
-
string =
|
38
|
+
string = StringUtils.rewrite("tmp/garbage.html", rules)
|
40
39
|
assert_equal("/n/theseas/var/tmp/garbage.html", string)
|
41
|
-
string =
|
40
|
+
string = StringUtils.rewrite("root/index.html", rules)
|
42
41
|
assert_equal("root/index.html", string)
|
43
|
-
assert_equal(nil,
|
44
|
-
assert_equal("",
|
42
|
+
assert_equal(nil, StringUtils.rewrite(nil, rules))
|
43
|
+
assert_equal("", StringUtils.rewrite("", rules))
|
45
44
|
|
46
45
|
assert_raises(ArgumentError) {
|
47
|
-
assert_equal("koko",
|
46
|
+
assert_equal("koko", StringUtils.rewrite("koko", nil))
|
48
47
|
}
|
49
48
|
|
50
49
|
# bug: should keep order
|
51
|
-
s =
|
50
|
+
s = StringUtils.rewrite("/$/koko.html", rules)
|
52
51
|
assert_equal("../n1/koko.html", s)
|
53
52
|
end
|
54
53
|
|
55
54
|
def test_wrap
|
56
55
|
s = "1234567890abcdefghijklmnopqrstu"
|
57
56
|
r = "1234 5678 90ab cdef ghij klmn opqr stu"
|
58
|
-
assert_equal(r,
|
57
|
+
assert_equal(r, StringUtils::wrap(s, 4, " "))
|
59
58
|
|
60
59
|
s = "111111111111111111111111111111111111111111111111"
|
61
60
|
r = "1111111111 1111111111 1111111111 1111111111 11111111"
|
62
|
-
assert_equal(r,
|
61
|
+
assert_equal(r, StringUtils::wrap(s, 10, " "))
|
63
62
|
|
64
63
|
s = "jackdaws love my big sphinx of quartz"
|
65
64
|
r = "jackdaws love my big sphinx of quartz"
|
66
|
-
assert_equal(r,
|
65
|
+
assert_equal(r, StringUtils::wrap(s, 10, " "))
|
67
66
|
|
68
67
|
s = "jackdaws love my big sphinx of quartz"
|
69
68
|
r = "jack daws love my big sphi nx of quar tz"
|
70
|
-
assert_equal(r,
|
69
|
+
assert_equal(r, StringUtils::wrap(s, 4, " "))
|
71
70
|
|
72
71
|
s = "jack.daws love my big sphinx of quartz"
|
73
72
|
r = "jack .daw s love my big sphi nx of quar tz"
|
74
|
-
assert_equal(r,
|
73
|
+
assert_equal(r, StringUtils::wrap(s, 4, " "))
|
75
74
|
|
76
|
-
assert_equal("",
|
77
|
-
assert_equal(nil,
|
75
|
+
assert_equal("", StringUtils::wrap("", 4, " "))
|
76
|
+
assert_equal(nil, StringUtils::wrap(nil, 4, " "))
|
78
77
|
end
|
79
78
|
=begin
|
80
79
|
def test_rationalize_filename
|
81
|
-
filename =
|
80
|
+
filename = StringUtils.rationalize_filename("hello my friend!.gif")
|
82
81
|
assert_equal("hello-my-friend.gif", filename)
|
83
|
-
filename =
|
82
|
+
filename = StringUtils.rationalize_filename("���� ����.gif")
|
84
83
|
assert_equal("pame-pali.gif", filename)
|
85
|
-
filename =
|
84
|
+
filename = StringUtils.rationalize_filename("�� ���.gif")
|
86
85
|
assert_equal("ti-les.gif", filename)
|
87
86
|
|
88
87
|
# bug:
|
89
|
-
filename =
|
88
|
+
filename = StringUtils.rationalize_filename("image-(10).gif")
|
90
89
|
assert_equal("image-10.gif", filename)
|
91
90
|
end
|
92
91
|
=end
|
93
92
|
def test_random_string
|
94
|
-
s1 =
|
95
|
-
s2 =
|
93
|
+
s1 = StringUtils.random()
|
94
|
+
s2 = StringUtils.random()
|
96
95
|
assert_not_equal(s1, s2)
|
97
96
|
assert(s1.size == s2.size)
|
98
97
|
end
|
data/test/glue/tc_validation.rb
CHANGED
@@ -6,12 +6,13 @@ require 'glue'
|
|
6
6
|
require 'glue/property'
|
7
7
|
require 'glue/validation'
|
8
8
|
|
9
|
-
|
9
|
+
Glue::Property.type_checking = false
|
10
10
|
|
11
11
|
class TC_Validation < Test::Unit::TestCase # :nodoc: all
|
12
|
-
|
12
|
+
include Glue
|
13
|
+
|
13
14
|
# Override the default error message
|
14
|
-
|
15
|
+
Validation::Errors.invalid_format = 'INVALID'
|
15
16
|
|
16
17
|
module Mixin
|
17
18
|
prop_accessor :value, String
|
data/vendor/breakpoint.rb
CHANGED
data/vendor/breakpoint_client.rb
CHANGED
@@ -70,7 +70,7 @@ ARGV.options do |opts|
|
|
70
70
|
opts.on("-v", "--version",
|
71
71
|
"Display the version information."
|
72
72
|
) do
|
73
|
-
id = %q$Id: breakpoint_client.rb
|
73
|
+
id = %q$Id: breakpoint_client.rb 1 2005-04-11 11:04:30Z gmosx $
|
74
74
|
puts id.sub("Id: ", "")
|
75
75
|
puts "(Breakpoint::Version = #{Breakpoint::Version})"
|
76
76
|
exit
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
|
|
3
3
|
specification_version: 1
|
4
4
|
name: glue
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2005-04-
|
6
|
+
version: 0.16.0
|
7
|
+
date: 2005-04-18
|
8
8
|
summary: Glue utilities
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -21,72 +21,74 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
21
21
|
-
|
22
22
|
- ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 1.8.
|
24
|
+
version: 1.8.2
|
25
25
|
version:
|
26
26
|
platform: ruby
|
27
27
|
authors:
|
28
28
|
- George Moschovitis
|
29
29
|
files:
|
30
|
+
- CHANGELOG
|
30
31
|
- Rakefile
|
31
32
|
- INSTALL
|
32
|
-
- CHANGELOG
|
33
33
|
- README
|
34
34
|
- install.rb
|
35
|
+
- doc/RELEASES
|
35
36
|
- doc/LICENSE
|
36
37
|
- doc/AUTHORS
|
37
|
-
- doc/RELEASES
|
38
|
-
- lib/glue.rb
|
39
38
|
- lib/glue
|
40
|
-
- lib/glue
|
39
|
+
- lib/glue.rb
|
41
40
|
- lib/glue/logger.rb
|
42
|
-
- lib/glue/
|
43
|
-
- lib/glue/
|
41
|
+
- lib/glue/array.rb
|
42
|
+
- lib/glue/validation.rb
|
43
|
+
- lib/glue/flexob.rb
|
44
44
|
- lib/glue/hash.rb
|
45
|
-
- lib/glue/number.rb
|
46
|
-
- lib/glue/time.rb
|
47
45
|
- lib/glue/property.rb
|
46
|
+
- lib/glue/inflector.rb
|
47
|
+
- lib/glue/number.rb
|
48
|
+
- lib/glue/dynamic_include.rb
|
49
|
+
- lib/glue/aspects.rb
|
48
50
|
- lib/glue/misc.rb
|
49
|
-
- lib/glue/
|
51
|
+
- lib/glue/time.rb
|
52
|
+
- lib/glue/attribute.rb
|
50
53
|
- lib/glue/cache.rb
|
51
54
|
- lib/glue/string.rb
|
52
|
-
- lib/glue/dynamic_include.rb
|
53
55
|
- lib/glue/object.rb
|
54
|
-
- lib/glue/
|
55
|
-
- lib/glue/
|
56
|
-
- lib/glue/attribute.rb
|
56
|
+
- lib/glue/mixins.rb
|
57
|
+
- lib/glue/pool.rb
|
57
58
|
- test/glue
|
58
59
|
- test/glue/tc_strings.rb
|
59
|
-
- test/glue/tc_property_type_checking.rb
|
60
|
-
- test/glue/tc_logger.rb
|
61
60
|
- test/glue/tc_validation.rb
|
62
|
-
- test/glue/
|
63
|
-
- test/glue/tc_hash.rb
|
64
|
-
- test/glue/tc_attribute.rb
|
61
|
+
- test/glue/tc_numbers.rb
|
65
62
|
- test/glue/tc_property_mixins.rb
|
63
|
+
- test/glue/tc_logger.rb
|
64
|
+
- test/glue/tc_aspects.rb
|
65
|
+
- test/glue/tc_property_type_checking.rb
|
66
66
|
- test/glue/tc_cache.rb
|
67
|
-
- test/glue/
|
68
|
-
-
|
67
|
+
- test/glue/tc_hash.rb
|
68
|
+
- test/glue/tc_attribute.rb
|
69
|
+
- test/glue/tc_property.rb
|
69
70
|
- vendor/extensions
|
70
71
|
- vendor/binding_of_caller.rb
|
71
|
-
- vendor/blankslate.rb
|
72
72
|
- vendor/breakpoint.rb
|
73
|
+
- vendor/blankslate.rb
|
73
74
|
- vendor/README
|
75
|
+
- vendor/breakpoint_client.rb
|
76
|
+
- vendor/extensions/kernel.rb
|
77
|
+
- vendor/extensions/array.rb
|
74
78
|
- vendor/extensions/enumerable.rb
|
75
|
-
- vendor/extensions/all.rb
|
76
79
|
- vendor/extensions/hash.rb
|
77
|
-
- vendor/extensions/continuation.rb
|
78
80
|
- vendor/extensions/module.rb
|
79
|
-
- vendor/extensions/
|
81
|
+
- vendor/extensions/numeric.rb
|
80
82
|
- vendor/extensions/ostruct.rb
|
81
|
-
- vendor/extensions/kernel.rb
|
82
83
|
- vendor/extensions/class.rb
|
83
|
-
- vendor/extensions/
|
84
|
-
- vendor/extensions/_base.rb
|
85
|
-
- vendor/extensions/io.rb
|
84
|
+
- vendor/extensions/symbol.rb
|
86
85
|
- vendor/extensions/string.rb
|
87
86
|
- vendor/extensions/object.rb
|
88
|
-
- vendor/extensions/
|
89
|
-
- vendor/extensions/
|
87
|
+
- vendor/extensions/io.rb
|
88
|
+
- vendor/extensions/all.rb
|
89
|
+
- vendor/extensions/_base.rb
|
90
|
+
- vendor/extensions/binding.rb
|
91
|
+
- vendor/extensions/continuation.rb
|
90
92
|
- vendor/extensions/_template.rb
|
91
93
|
test_files: []
|
92
94
|
rdoc_options:
|
@@ -97,31 +99,11 @@ rdoc_options:
|
|
97
99
|
- "--all"
|
98
100
|
- "--inline-source"
|
99
101
|
extra_rdoc_files:
|
102
|
+
- CHANGELOG
|
100
103
|
- Rakefile
|
101
104
|
- INSTALL
|
102
|
-
- CHANGELOG
|
103
105
|
- README
|
104
106
|
executables: []
|
105
107
|
extensions: []
|
106
108
|
requirements: []
|
107
|
-
dependencies:
|
108
|
-
- !ruby/object:Gem::Dependency
|
109
|
-
name: extensions
|
110
|
-
version_requirement:
|
111
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
112
|
-
requirements:
|
113
|
-
-
|
114
|
-
- ">="
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: "0.5"
|
117
|
-
version:
|
118
|
-
- !ruby/object:Gem::Dependency
|
119
|
-
name: flexmock
|
120
|
-
version_requirement:
|
121
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
122
|
-
requirements:
|
123
|
-
-
|
124
|
-
- ">="
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
version: 0.0.3
|
127
|
-
version:
|
109
|
+
dependencies: []
|