classx 0.0.2 → 0.0.3
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/ChangeLog +84 -0
- data/README +4 -2
- data/Rakefile +1 -1
- data/bench/attribute_set.rb +56 -0
- data/bench/initialize.rb +59 -0
- data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-block_rb.html +1 -1
- data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-callbacks_rb.html +1 -1
- data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-change_rb.html +1 -1
- data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-hunk_rb.html +1 -1
- data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs_rb.html +1 -1
- data/doc/output/coverage/-Library-Ruby-Gems-gems-rcov-0_8_1_2_0-lib-rcov_rb.html +1 -1
- data/doc/output/coverage/index.html +27 -27
- data/doc/output/coverage/lib-classx-attribute_rb.html +82 -75
- data/doc/output/coverage/lib-classx-attributes_rb.html +101 -94
- data/doc/output/coverage/lib-classx-validate_rb.html +14 -11
- data/doc/output/coverage/lib-classx_rb.html +75 -65
- data/example/commandable.rb +9 -3
- data/lib/classx.rb +12 -2
- data/lib/classx/attribute.rb +10 -3
- data/lib/classx/attributes.rb +10 -3
- data/lib/classx/commandable.rb +27 -7
- data/lib/classx/declare.rb +12 -0
- data/lib/classx/role/logger.rb +70 -0
- data/lib/classx/validate.rb +6 -3
- data/spec/classx/default_option_spec.rb +16 -12
- data/spec/classx/handles_spec.rb +5 -2
- data/spec/classx/with_coerce.rb +12 -4
- data/spec/classx/with_extend.rb +3 -1
- data/spec/classx/with_include.rb +3 -1
- data/spec/classx/with_multiple_class_spec.rb +4 -2
- data/spec/classx/without_accessor_spec.rb +2 -1
- data/spec/classx/without_anyoption_spec.rb +3 -1
- data/spec/classx/writable_option_spec.rb +8 -4
- data/spec/classx_attributes_spec.rb +6 -1
- data/tasks/basic_config.rake +1 -1
- metadata +7 -2
data/ChangeLog
CHANGED
@@ -1,3 +1,87 @@
|
|
1
|
+
commit 106a6048c9dd61009a54bd35081e849461785560
|
2
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
3
|
+
Date: Sat Aug 23 14:22:09 2008 +0900
|
4
|
+
|
5
|
+
update pdf new version.
|
6
|
+
|
7
|
+
commit b12c2f6af136152941acff3e24cc7bb2e0d7bec2
|
8
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
9
|
+
Date: Sat Aug 23 14:05:15 2008 +0900
|
10
|
+
|
11
|
+
fixed.
|
12
|
+
|
13
|
+
commit 7655a1b8a2e719ab6aef5e4239333c2271974fec
|
14
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
15
|
+
Date: Sat Aug 23 13:57:31 2008 +0900
|
16
|
+
|
17
|
+
CAVEAT: change ClassX class to module!!!
|
18
|
+
|
19
|
+
commit a92bcb221eb44b7e699c23dcbd85ca6b8124f74b
|
20
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
21
|
+
Date: Sat Aug 23 13:04:51 2008 +0900
|
22
|
+
|
23
|
+
tweaked inspect for easy debugging.
|
24
|
+
|
25
|
+
commit 75b464c029eb075381eac6c3901766838f8ae935
|
26
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
27
|
+
Date: Sat Aug 23 12:41:29 2008 +0900
|
28
|
+
|
29
|
+
added ClassX::Role::Logger. and ignore as commandline option if :no_cmd_option specified to define attribute.
|
30
|
+
|
31
|
+
commit c0b5ab6ff524a3a085cd85ef9300fd4900cfcb1c
|
32
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
33
|
+
Date: Sat Aug 23 12:09:15 2008 +0900
|
34
|
+
|
35
|
+
FATAL: fixed BUG: when mixin module that has attribute to ClassX based class, attribute_something wrong.
|
36
|
+
|
37
|
+
commit 367d3faf52f20adacd73a63616600bcd254ae9fe
|
38
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
39
|
+
Date: Sat Aug 23 09:15:57 2008 +0900
|
40
|
+
|
41
|
+
fix document.
|
42
|
+
|
43
|
+
commit 6a13669476240c944c34ead40e5785f523992a16
|
44
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
45
|
+
Date: Sat Aug 23 09:13:49 2008 +0900
|
46
|
+
|
47
|
+
change to autoload optional class.
|
48
|
+
|
49
|
+
commit 57afc39197a4ebb149fde046bc4a5feca85b10ac
|
50
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
51
|
+
Date: Sat Aug 23 08:12:57 2008 +0900
|
52
|
+
|
53
|
+
help should show type specify from command line.
|
54
|
+
|
55
|
+
commit 3af7753e0a64434ce8e02f820da7d096355873f9
|
56
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
57
|
+
Date: Fri Aug 22 07:03:09 2008 +0900
|
58
|
+
|
59
|
+
change to dup as possible when you take :default option.as not Proc object.
|
60
|
+
|
61
|
+
commit b8770a895f674f7eb2eb100c016385377d01bf22
|
62
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
63
|
+
Date: Fri Aug 22 06:47:44 2008 +0900
|
64
|
+
|
65
|
+
tweak help message.
|
66
|
+
|
67
|
+
commit d204b63f683aad7bf25cdba19ac941113f5f395f
|
68
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
69
|
+
Date: Fri Aug 22 03:19:55 2008 +0900
|
70
|
+
|
71
|
+
support short option. thanks advice for Shintaro, Kakutani.
|
72
|
+
|
73
|
+
commit 28f1694a54968cb56c674fe62a6f2b6ad35a46b9
|
74
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
75
|
+
Date: Thu Aug 21 20:30:33 2008 +0900
|
76
|
+
|
77
|
+
added ClassX::Declare. thanks Naoto, Takai !!
|
78
|
+
|
79
|
+
commit c3fb1968643ff195258d027012a2a3dab1c4c7f2
|
80
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
81
|
+
Date: Thu Aug 21 17:21:48 2008 +0900
|
82
|
+
|
83
|
+
release 0.0.2
|
84
|
+
|
1
85
|
commit 08727ad7905c9f16a95d2b788b9c5e51288d1580
|
2
86
|
Author: Keiji, Yoshimi <walf443@gmail.com>
|
3
87
|
Date: Thu Aug 21 17:20:16 2008 +0900
|
data/README
CHANGED
@@ -4,7 +4,9 @@
|
|
4
4
|
== Synopsis
|
5
5
|
|
6
6
|
require 'classx'
|
7
|
-
class Point
|
7
|
+
class Point
|
8
|
+
include ClassX
|
9
|
+
|
8
10
|
has :x, :kind_of => Fixnum
|
9
11
|
has :y, :kind_of => Fixnum
|
10
12
|
end
|
@@ -15,7 +17,7 @@
|
|
15
17
|
|
16
18
|
Point.new(:x => 30, :y => 40) #=> <# Point @x=30, @y=40 >
|
17
19
|
point3d = Point3D.new(:x => 30, :y => 40, :z => 50) #=> <# Point3D @x=30, @y=40, @z=50 >
|
18
|
-
point3d.z = 60.0 # raise ClassX::
|
20
|
+
point3d.z = 60.0 # raise ClassX::InvalidAttrArgument
|
19
21
|
|
20
22
|
== Description
|
21
23
|
perl's Moose like Class interface.
|
data/Rakefile
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib' )))
|
3
|
+
require 'classx'
|
4
|
+
|
5
|
+
class PointWithClassX
|
6
|
+
include ClassX
|
7
|
+
has :x, :writable => true
|
8
|
+
has :y, :writable => true
|
9
|
+
has :z, :writable => true
|
10
|
+
end
|
11
|
+
|
12
|
+
class PointWithoutClassX
|
13
|
+
attr_accessor :x, :y, :z
|
14
|
+
|
15
|
+
def initialize hash
|
16
|
+
@x = hash[:x]
|
17
|
+
@y = hash[:y]
|
18
|
+
@z = hash[:z]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
COUNT = 1000
|
23
|
+
|
24
|
+
point_with_classx = PointWithClassX.new({ :x => 0, :y => 0, :z => 0 })
|
25
|
+
point_without_classx = PointWithoutClassX.new({ :x => 0, :y => 0, :z => 0 })
|
26
|
+
|
27
|
+
Benchmark.bm do |x|
|
28
|
+
x.report 'classx' do
|
29
|
+
COUNT.times do
|
30
|
+
point_with_classx.x = rand(10)
|
31
|
+
point_with_classx.y = rand(10)
|
32
|
+
point_with_classx.z = rand(10)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
x.report 'normal class' do
|
36
|
+
COUNT.times do
|
37
|
+
point_without_classx.x = rand(10)
|
38
|
+
point_without_classx.y = rand(10)
|
39
|
+
point_without_classx.z = rand(10)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# On my environment( MacBook1.1 Intel Core Duo 1.83 GHz, 2GB), result is like that. TOOOOO SLOOOW classX!!!!.
|
45
|
+
#
|
46
|
+
# ----------------------------------------------------------
|
47
|
+
# result after 633f7e88
|
48
|
+
# user system total real
|
49
|
+
# classx 0.080000 0.010000 0.090000 ( 0.097012)
|
50
|
+
# normal class 0.010000 0.000000 0.010000 ( 0.001508)
|
51
|
+
# ----------------------------------------------------------
|
52
|
+
# result after 283903a
|
53
|
+
# user system total real
|
54
|
+
# classx 0.810000 0.020000 0.830000 ( 0.902779)
|
55
|
+
# normal class 0.000000 0.000000 0.000000 ( 0.001401)
|
56
|
+
# ----------------------------------------------------------
|
data/bench/initialize.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib' )))
|
3
|
+
require 'classx'
|
4
|
+
|
5
|
+
class PointWithClassX
|
6
|
+
include ClassX
|
7
|
+
has :x
|
8
|
+
has :y
|
9
|
+
has :z
|
10
|
+
end
|
11
|
+
|
12
|
+
class PointWithoutClassX
|
13
|
+
attr_reader :x, :y, :z
|
14
|
+
|
15
|
+
def initialize hash
|
16
|
+
@x = hash[:x]
|
17
|
+
@y = hash[:y]
|
18
|
+
@z = hash[:z]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
COUNT = 1000
|
23
|
+
|
24
|
+
Benchmark.bm do |x|
|
25
|
+
x.report 'classx' do
|
26
|
+
COUNT.times do
|
27
|
+
PointWithClassX.new({ :x => rand(10), :y => rand(10), :z => rand(10) })
|
28
|
+
end
|
29
|
+
end
|
30
|
+
x.report 'normal class' do
|
31
|
+
COUNT.times do
|
32
|
+
PointWithoutClassX.new({ :x => rand(10), :y => rand(10), :z => rand(10) })
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# On my environment( MacBook1.1 Intel Core Duo 1.83 GHz, 2GB), result is like that. TOOOOO SLOOOW classX!!!!.
|
38
|
+
#
|
39
|
+
# ----------------------------------------------------------
|
40
|
+
# result after 633f7e88
|
41
|
+
# user system total real
|
42
|
+
# classx 0.110000 0.000000 0.110000 ( 0.144713)
|
43
|
+
# normal class 0.000000 0.000000 0.000000 ( 0.004702)
|
44
|
+
# ----------------------------------------------------------
|
45
|
+
# result after 7d345a994
|
46
|
+
# user system total real
|
47
|
+
# classx 0.350000 0.010000 0.360000 ( 0.400520)
|
48
|
+
# normal class 0.000000 0.000000 0.000000 ( 0.004222)
|
49
|
+
# ----------------------------------------------------------
|
50
|
+
# result after 28f399333
|
51
|
+
# user system total real
|
52
|
+
# classx 0.380000 0.000000 0.380000 ( 0.424544)
|
53
|
+
# normal class 0.000000 0.000000 0.000000 ( 0.004196)
|
54
|
+
# ----------------------------------------------------------
|
55
|
+
# result after d5619b6533
|
56
|
+
# user system total real
|
57
|
+
# classx 2.130000 0.020000 2.150000 ( 2.377707)
|
58
|
+
# normal class 0.010000 0.000000 0.010000 ( 0.010002)
|
59
|
+
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on
|
556
|
+
<p>Generated on Sat Aug 23 14:29:18 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-callbacks_rb.html
CHANGED
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on
|
556
|
+
<p>Generated on Sat Aug 23 14:29:19 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on
|
556
|
+
<p>Generated on Sat Aug 23 14:29:19 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on
|
556
|
+
<p>Generated on Sat Aug 23 14:29:19 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on
|
556
|
+
<p>Generated on Sat Aug 23 14:29:18 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on
|
556
|
+
<p>Generated on Sat Aug 23 14:29:19 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -148,7 +148,7 @@ table.report tr.dark {
|
|
148
148
|
</script>
|
149
149
|
</head>
|
150
150
|
<body><h3>C0 code coverage information</h3>
|
151
|
-
<p>Generated on
|
151
|
+
<p>Generated on Sat Aug 23 14:29:17 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
152
152
|
</p>
|
153
153
|
<hr/>
|
154
154
|
<table class='report'><thead><tr><td class='heading'>Name</td>
|
@@ -159,24 +159,24 @@ table.report tr.dark {
|
|
159
159
|
</tr>
|
160
160
|
</thead>
|
161
161
|
<tbody><tr class='light'><td>TOTAL</td>
|
162
|
-
<td class='lines_total'><tt>
|
162
|
+
<td class='lines_total'><tt>3282</tt>
|
163
163
|
</td>
|
164
|
-
<td class='lines_code'><tt>
|
164
|
+
<td class='lines_code'><tt>1844</tt>
|
165
165
|
</td>
|
166
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>39.
|
166
|
+
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>39.7%</tt>
|
167
167
|
</td>
|
168
|
-
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='
|
169
|
-
<td class='uncovered' width='
|
168
|
+
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='40'/>
|
169
|
+
<td class='uncovered' width='60'/>
|
170
170
|
</tr>
|
171
171
|
</table>
|
172
172
|
</td>
|
173
173
|
</tr>
|
174
174
|
</table>
|
175
175
|
</td>
|
176
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>
|
176
|
+
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>19.6%</tt>
|
177
177
|
</td>
|
178
|
-
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='
|
179
|
-
<td class='uncovered' width='
|
178
|
+
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='20'/>
|
179
|
+
<td class='uncovered' width='80'/>
|
180
180
|
</tr>
|
181
181
|
</table>
|
182
182
|
</td>
|
@@ -348,9 +348,9 @@ table.report tr.dark {
|
|
348
348
|
</tr>
|
349
349
|
<tr class='dark'><td><a href='lib-classx_rb.html'>lib/classx.rb</a>
|
350
350
|
</td>
|
351
|
-
<td class='lines_total'><tt>
|
351
|
+
<td class='lines_total'><tt>75</tt>
|
352
352
|
</td>
|
353
|
-
<td class='lines_code'><tt>
|
353
|
+
<td class='lines_code'><tt>58</tt>
|
354
354
|
</td>
|
355
355
|
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>100.0%</tt>
|
356
356
|
</td>
|
@@ -375,11 +375,11 @@ table.report tr.dark {
|
|
375
375
|
</tr>
|
376
376
|
<tr class='light'><td><a href='lib-classx-attribute_rb.html'>lib/classx/attribute.rb</a>
|
377
377
|
</td>
|
378
|
-
<td class='lines_total'><tt>
|
378
|
+
<td class='lines_total'><tt>185</tt>
|
379
379
|
</td>
|
380
|
-
<td class='lines_code'><tt>
|
380
|
+
<td class='lines_code'><tt>149</tt>
|
381
381
|
</td>
|
382
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>
|
382
|
+
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>53.0%</tt>
|
383
383
|
</td>
|
384
384
|
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='53'/>
|
385
385
|
<td class='uncovered' width='47'/>
|
@@ -389,10 +389,10 @@ table.report tr.dark {
|
|
389
389
|
</tr>
|
390
390
|
</table>
|
391
391
|
</td>
|
392
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>45.
|
392
|
+
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>45.6%</tt>
|
393
393
|
</td>
|
394
|
-
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='
|
395
|
-
<td class='uncovered' width='
|
394
|
+
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='46'/>
|
395
|
+
<td class='uncovered' width='54'/>
|
396
396
|
</tr>
|
397
397
|
</table>
|
398
398
|
</td>
|
@@ -402,24 +402,24 @@ table.report tr.dark {
|
|
402
402
|
</tr>
|
403
403
|
<tr class='dark'><td><a href='lib-classx-attributes_rb.html'>lib/classx/attributes.rb</a>
|
404
404
|
</td>
|
405
|
-
<td class='lines_total'><tt>
|
405
|
+
<td class='lines_total'><tt>92</tt>
|
406
406
|
</td>
|
407
|
-
<td class='lines_code'><tt>
|
407
|
+
<td class='lines_code'><tt>76</tt>
|
408
408
|
</td>
|
409
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>
|
409
|
+
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>97.8%</tt>
|
410
410
|
</td>
|
411
|
-
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='
|
412
|
-
<td class='uncovered' width='
|
411
|
+
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='98'/>
|
412
|
+
<td class='uncovered' width='2'/>
|
413
413
|
</tr>
|
414
414
|
</table>
|
415
415
|
</td>
|
416
416
|
</tr>
|
417
417
|
</table>
|
418
418
|
</td>
|
419
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>
|
419
|
+
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>97.4%</tt>
|
420
420
|
</td>
|
421
|
-
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='
|
422
|
-
<td class='uncovered' width='
|
421
|
+
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='97'/>
|
422
|
+
<td class='uncovered' width='3'/>
|
423
423
|
</tr>
|
424
424
|
</table>
|
425
425
|
</td>
|
@@ -429,9 +429,9 @@ table.report tr.dark {
|
|
429
429
|
</tr>
|
430
430
|
<tr class='light'><td><a href='lib-classx-validate_rb.html'>lib/classx/validate.rb</a>
|
431
431
|
</td>
|
432
|
-
<td class='lines_total'><tt>
|
432
|
+
<td class='lines_total'><tt>38</tt>
|
433
433
|
</td>
|
434
|
-
<td class='lines_code'><tt>
|
434
|
+
<td class='lines_code'><tt>15</tt>
|
435
435
|
</td>
|
436
436
|
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>100.0%</tt>
|
437
437
|
</td>
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on
|
556
|
+
<p>Generated on Sat Aug 23 14:29:19 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -571,11 +571,11 @@ span.run100 {
|
|
571
571
|
</thead>
|
572
572
|
<tbody><tr class='light'><td><a href='lib-classx-attribute_rb.html'>lib/classx/attribute.rb</a>
|
573
573
|
</td>
|
574
|
-
<td class='lines_total'><tt>
|
574
|
+
<td class='lines_total'><tt>185</tt>
|
575
575
|
</td>
|
576
|
-
<td class='lines_code'><tt>
|
576
|
+
<td class='lines_code'><tt>149</tt>
|
577
577
|
</td>
|
578
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>
|
578
|
+
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>53.0%</tt>
|
579
579
|
</td>
|
580
580
|
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='53'/>
|
581
581
|
<td class='uncovered' width='47'/>
|
@@ -585,10 +585,10 @@ span.run100 {
|
|
585
585
|
</tr>
|
586
586
|
</table>
|
587
587
|
</td>
|
588
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>45.
|
588
|
+
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>45.6%</tt>
|
589
589
|
</td>
|
590
|
-
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='
|
591
|
-
<td class='uncovered' width='
|
590
|
+
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='46'/>
|
591
|
+
<td class='uncovered' width='54'/>
|
592
592
|
</tr>
|
593
593
|
</table>
|
594
594
|
</td>
|
@@ -598,7 +598,7 @@ span.run100 {
|
|
598
598
|
</tr>
|
599
599
|
</tbody>
|
600
600
|
</table>
|
601
|
-
<pre><span class="marked0"><a name="line1"></a> 1
|
601
|
+
<pre><span class="marked0"><a name="line1"></a> 1 module ClassX
|
602
602
|
</span><span class="marked1"><a name="line2"></a> 2 class AttributeFactory
|
603
603
|
</span><span class="marked0"><a name="line3"></a> 3 def self.create args
|
604
604
|
</span><span class="marked1"><a name="line4"></a> 4 klass = Class.new
|
@@ -709,73 +709,80 @@ span.run100 {
|
|
709
709
|
</span><span class="marked0"><a name="line109"></a>109 when Proc
|
710
710
|
</span><span class="marked1"><a name="line110"></a>110 args[:default].call(parent)
|
711
711
|
</span><span class="inferred0"><a name="line111"></a>111 else
|
712
|
-
</span><span class="marked1"><a name="line112"></a>112
|
713
|
-
</span><span class="
|
714
|
-
</span><span class="inferred1"><a name="line114"></a>114
|
715
|
-
</span><span class="
|
716
|
-
</span><span class="inferred1"><a name="line116"></a>116
|
717
|
-
</span><span class="
|
718
|
-
</span><span class="
|
719
|
-
</span><span class="inferred0"><a name="line119"></a>119
|
720
|
-
</span><span class="inferred1"><a name="line120"></a>120
|
721
|
-
</span><span class="
|
722
|
-
</span><span class="marked1"><a name="line122"></a>122
|
723
|
-
</span><span class="
|
724
|
-
</span><span class="inferred1"><a name="line124"></a>124
|
725
|
-
</span><span class="inferred0"><a name="line125"></a>125
|
726
|
-
</span><span class="
|
727
|
-
</span><span class="marked0"><a name="line127"></a>127
|
728
|
-
</span><span class="inferred1"><a name="line128"></a>128
|
729
|
-
</span><span class="
|
730
|
-
</span><span class="marked1"><a name="line130"></a>130
|
731
|
-
</span><span class="
|
732
|
-
</span><span class="
|
733
|
-
</span><span class="
|
734
|
-
</span><span class="marked1"><a name="line134"></a>134
|
735
|
-
</span><span class="inferred0"><a name="line135"></a>135
|
736
|
-
</span><span class="
|
737
|
-
</span><span class="marked0"><a name="line137"></a>137
|
738
|
-
</span><span class="
|
739
|
-
</span><span class="
|
740
|
-
</span><span class="
|
741
|
-
</span><span class="marked0"><a name="line141"></a>141
|
742
|
-
</span><span class="
|
743
|
-
</span><span class="
|
744
|
-
</span><span class="marked1"><a name="line144"></a>144
|
745
|
-
</span><span class="
|
746
|
-
</span><span class="inferred1"><a name="line146"></a>146
|
747
|
-
</span><span class="inferred0"><a name="line147"></a>147
|
748
|
-
</span><span class="marked1"><a name="line148"></a>148
|
749
|
-
</span><span class="
|
750
|
-
</span><span class="
|
751
|
-
</span><span class="
|
752
|
-
</span><span class="
|
753
|
-
</span><span class="
|
754
|
-
</span><span class="
|
755
|
-
</span><span class="
|
756
|
-
</span><span class="uncovered1"><a name="line156"></a>156
|
757
|
-
</span><span class="uncovered0"><a name="line157"></a>157
|
758
|
-
</span><span class="
|
759
|
-
</span><span class="
|
760
|
-
</span><span class="uncovered1"><a name="line160"></a>160
|
761
|
-
</span><span class="uncovered0"><a name="line161"></a>161
|
762
|
-
</span><span class="uncovered1"><a name="line162"></a>162 args[:
|
763
|
-
</span><span class="uncovered0"><a name="line163"></a>163
|
764
|
-
</span><span class="uncovered1"><a name="line164"></a>164
|
765
|
-
</span><span class="
|
766
|
-
</span><span class="
|
767
|
-
</span><span class="uncovered0"><a name="line167"></a>167
|
768
|
-
</span><span class="uncovered1"><a name="line168"></a>168
|
769
|
-
</span><span class="
|
770
|
-
</span><span class="
|
771
|
-
</span><span class="uncovered0"><a name="line171"></a>171
|
772
|
-
</span><span class="uncovered1"><a name="line172"></a>172
|
773
|
-
</span><span class="uncovered0"><a name="line173"></a>173
|
774
|
-
</span><span class="
|
775
|
-
</span><span class="
|
776
|
-
</span><span class="inferred1"><a name="line176"></a>176
|
777
|
-
</span><span class="
|
778
|
-
</span><span class="
|
712
|
+
</span><span class="marked1"><a name="line112"></a>112 begin
|
713
|
+
</span><span class="marked0"><a name="line113"></a>113 args[:default].dup
|
714
|
+
</span><span class="inferred1"><a name="line114"></a>114 rescue Exception
|
715
|
+
</span><span class="marked0"><a name="line115"></a>115 args[:default]
|
716
|
+
</span><span class="inferred1"><a name="line116"></a>116 end
|
717
|
+
</span><span class="inferred0"><a name="line117"></a>117 end
|
718
|
+
</span><span class="inferred1"><a name="line118"></a>118 end
|
719
|
+
</span><span class="inferred0"><a name="line119"></a>119
|
720
|
+
</span><span class="inferred1"><a name="line120"></a>120 # when this option specify true, not raise error in #initialize without value.
|
721
|
+
</span><span class="marked0"><a name="line121"></a>121 define_method :optional? do
|
722
|
+
</span><span class="marked1"><a name="line122"></a>122 return args[:optional]
|
723
|
+
</span><span class="inferred0"><a name="line123"></a>123 end
|
724
|
+
</span><span class="inferred1"><a name="line124"></a>124
|
725
|
+
</span><span class="inferred0"><a name="line125"></a>125 # when it lazy option specified, it will not be initialized when #initialize.
|
726
|
+
</span><span class="marked1"><a name="line126"></a>126 define_method :lazy? do
|
727
|
+
</span><span class="marked0"><a name="line127"></a>127 return args[:lazy]
|
728
|
+
</span><span class="inferred1"><a name="line128"></a>128 end
|
729
|
+
</span><span class="inferred0"><a name="line129"></a>129
|
730
|
+
</span><span class="marked1"><a name="line130"></a>130 define_method :inspect do
|
731
|
+
</span><span class="uncovered0"><a name="line131"></a>131 "ClassX::Attribute[#{self.config.inspect}]"
|
732
|
+
</span><span class="uncovered1"><a name="line132"></a>132 end
|
733
|
+
</span><span class="uncovered0"><a name="line133"></a>133 end
|
734
|
+
</span><span class="marked1"><a name="line134"></a>134 __send__ :extend, tmp_mod
|
735
|
+
</span><span class="inferred0"><a name="line135"></a>135
|
736
|
+
</span><span class="marked1"><a name="line136"></a>136 raise ClassX::RequiredAttrShouldNotHaveDefault if args[:optional] == false && !args[:default].nil?
|
737
|
+
</span><span class="marked0"><a name="line137"></a>137 raise ClassX::OptionalAttrShouldBeWritable if args[:optional] && args[:writable] == false
|
738
|
+
</span><span class="inferred1"><a name="line138"></a>138
|
739
|
+
</span><span class="marked0"><a name="line139"></a>139 define_method :initialize do |val|
|
740
|
+
</span><span class="marked1"><a name="line140"></a>140 @parent = val
|
741
|
+
</span><span class="marked0"><a name="line141"></a>141 @data = nil
|
742
|
+
</span><span class="inferred1"><a name="line142"></a>142 end
|
743
|
+
</span><span class="inferred0"><a name="line143"></a>143
|
744
|
+
</span><span class="marked1"><a name="line144"></a>144 define_method :get do
|
745
|
+
</span><span class="marked0"><a name="line145"></a>145 @data ||= self.class.default(@parent)
|
746
|
+
</span><span class="inferred1"><a name="line146"></a>146 end
|
747
|
+
</span><span class="inferred0"><a name="line147"></a>147
|
748
|
+
</span><span class="marked1"><a name="line148"></a>148 define_method :set do |val|
|
749
|
+
</span><span class="marked0"><a name="line149"></a>149 val = self.class.coerce(val)
|
750
|
+
</span><span class="marked1"><a name="line150"></a>150 raise ClassX::InvalidAttrArgument unless self.class.validate? val
|
751
|
+
</span><span class="marked0"><a name="line151"></a>151 @data = val
|
752
|
+
</span><span class="inferred1"><a name="line152"></a>152 end
|
753
|
+
</span><span class="inferred0"><a name="line153"></a>153
|
754
|
+
</span><span class="inferred1"><a name="line154"></a>154 # for extending attribute point.
|
755
|
+
</span><span class="marked0"><a name="line155"></a>155 if args[:include]
|
756
|
+
</span><span class="uncovered1"><a name="line156"></a>156 case args[:include]
|
757
|
+
</span><span class="uncovered0"><a name="line157"></a>157 when Array
|
758
|
+
</span><span class="uncovered1"><a name="line158"></a>158 args[:include].each do |mod|
|
759
|
+
</span><span class="uncovered0"><a name="line159"></a>159 self.__send__ :include, mod
|
760
|
+
</span><span class="uncovered1"><a name="line160"></a>160 end
|
761
|
+
</span><span class="uncovered0"><a name="line161"></a>161 else
|
762
|
+
</span><span class="uncovered1"><a name="line162"></a>162 self.__send__ :include, args[:include]
|
763
|
+
</span><span class="uncovered0"><a name="line163"></a>163 end
|
764
|
+
</span><span class="uncovered1"><a name="line164"></a>164 end
|
765
|
+
</span><span class="inferred0"><a name="line165"></a>165
|
766
|
+
</span><span class="marked1"><a name="line166"></a>166 if args[:extend]
|
767
|
+
</span><span class="uncovered0"><a name="line167"></a>167 case args[:extend]
|
768
|
+
</span><span class="uncovered1"><a name="line168"></a>168 when Array
|
769
|
+
</span><span class="uncovered0"><a name="line169"></a>169 args[:extend].each do |mod|
|
770
|
+
</span><span class="uncovered1"><a name="line170"></a>170 self.__send__ :extend, mod
|
771
|
+
</span><span class="uncovered0"><a name="line171"></a>171 end
|
772
|
+
</span><span class="uncovered1"><a name="line172"></a>172 else
|
773
|
+
</span><span class="uncovered0"><a name="line173"></a>173 self.__send__ :extend, args[:extend]
|
774
|
+
</span><span class="uncovered1"><a name="line174"></a>174 end
|
775
|
+
</span><span class="uncovered0"><a name="line175"></a>175 end
|
776
|
+
</span><span class="inferred1"><a name="line176"></a>176
|
777
|
+
</span><span class="marked0"><a name="line177"></a>177 define_method :inspect do
|
778
|
+
</span><span class="uncovered1"><a name="line178"></a>178 "<#ClassX::Attribute:#{object_id} #{ @data.nil? ? '@data=nil' : '@data=' + @data.inspect } config=#{self.class.config.inspect}>"
|
779
|
+
</span><span class="uncovered0"><a name="line179"></a>179 end
|
780
|
+
</span><span class="uncovered1"><a name="line180"></a>180 end
|
781
|
+
</span><span class="inferred0"><a name="line181"></a>181
|
782
|
+
</span><span class="marked1"><a name="line182"></a>182 klass
|
783
|
+
</span><span class="inferred0"><a name="line183"></a>183 end
|
784
|
+
</span><span class="inferred1"><a name="line184"></a>184 end
|
785
|
+
</span><span class="inferred0"><a name="line185"></a>185 end
|
779
786
|
</span></pre><hr/>
|
780
787
|
<p>Generated using the <a href='http://eigenclass.org/hiki.rb?rcov'>rcov code coverage analysis tool for Ruby</a>
|
781
788
|
version 0.8.1.2.</p>
|