classx 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/ChangeLog +84 -0
  2. data/README +4 -2
  3. data/Rakefile +1 -1
  4. data/bench/attribute_set.rb +56 -0
  5. data/bench/initialize.rb +59 -0
  6. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-block_rb.html +1 -1
  7. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-callbacks_rb.html +1 -1
  8. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-change_rb.html +1 -1
  9. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-hunk_rb.html +1 -1
  10. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs_rb.html +1 -1
  11. data/doc/output/coverage/-Library-Ruby-Gems-gems-rcov-0_8_1_2_0-lib-rcov_rb.html +1 -1
  12. data/doc/output/coverage/index.html +27 -27
  13. data/doc/output/coverage/lib-classx-attribute_rb.html +82 -75
  14. data/doc/output/coverage/lib-classx-attributes_rb.html +101 -94
  15. data/doc/output/coverage/lib-classx-validate_rb.html +14 -11
  16. data/doc/output/coverage/lib-classx_rb.html +75 -65
  17. data/example/commandable.rb +9 -3
  18. data/lib/classx.rb +12 -2
  19. data/lib/classx/attribute.rb +10 -3
  20. data/lib/classx/attributes.rb +10 -3
  21. data/lib/classx/commandable.rb +27 -7
  22. data/lib/classx/declare.rb +12 -0
  23. data/lib/classx/role/logger.rb +70 -0
  24. data/lib/classx/validate.rb +6 -3
  25. data/spec/classx/default_option_spec.rb +16 -12
  26. data/spec/classx/handles_spec.rb +5 -2
  27. data/spec/classx/with_coerce.rb +12 -4
  28. data/spec/classx/with_extend.rb +3 -1
  29. data/spec/classx/with_include.rb +3 -1
  30. data/spec/classx/with_multiple_class_spec.rb +4 -2
  31. data/spec/classx/without_accessor_spec.rb +2 -1
  32. data/spec/classx/without_anyoption_spec.rb +3 -1
  33. data/spec/classx/writable_option_spec.rb +8 -4
  34. data/spec/classx_attributes_spec.rb +6 -1
  35. data/tasks/basic_config.rake +1 -1
  36. 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 < ClassX
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::InvalidSetterArgumentError
20
+ point3d.z = 60.0 # raise ClassX::InvalidAttrArgument
19
21
 
20
22
  == Description
21
23
  perl's Moose like Class interface.
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ DESCRIPTION = <<-"END_DESCRIPTION"
17
17
 
18
18
  END_DESCRIPTION
19
19
  BIN_FILES = %w( )
20
- VERS = "0.0.2"
20
+ VERS = "0.0.3"
21
21
 
22
22
  EXTRA_RDOC_FILES = []
23
23
  HECKLE_ROOT_MODULES = ["Classx"]
@@ -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
+ # ----------------------------------------------------------
@@ -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 Thu Aug 21 17:23:11 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
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 Thu Aug 21 17:23:11 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
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 Thu Aug 21 17:23:11 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
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 Thu Aug 21 17:23:12 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
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 Thu Aug 21 17:23:11 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
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 Thu Aug 21 17:23:12 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
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 Thu Aug 21 17:23:10 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
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>3255</tt>
162
+ <td class='lines_total'><tt>3282</tt>
163
163
  </td>
164
- <td class='lines_code'><tt>1819</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.2%</tt>
166
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>39.7%</tt>
167
167
  &nbsp;</td>
168
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='39'/>
169
- <td class='uncovered' width='61'/>
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'>18.6%</tt>
176
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>19.6%</tt>
177
177
  &nbsp;</td>
178
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='19'/>
179
- <td class='uncovered' width='81'/>
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>65</tt>
351
+ <td class='lines_total'><tt>75</tt>
352
352
  </td>
353
- <td class='lines_code'><tt>49</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
  &nbsp;</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>178</tt>
378
+ <td class='lines_total'><tt>185</tt>
379
379
  </td>
380
- <td class='lines_code'><tt>142</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'>52.8%</tt>
382
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>53.0%</tt>
383
383
  &nbsp;</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.1%</tt>
392
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>45.6%</tt>
393
393
  &nbsp;</td>
394
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='45'/>
395
- <td class='uncovered' width='55'/>
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>85</tt>
405
+ <td class='lines_total'><tt>92</tt>
406
406
  </td>
407
- <td class='lines_code'><tt>70</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'>95.3%</tt>
409
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>97.8%</tt>
410
410
  &nbsp;</td>
411
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='95'/>
412
- <td class='uncovered' width='5'/>
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'>94.3%</tt>
419
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>97.4%</tt>
420
420
  &nbsp;</td>
421
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='94'/>
422
- <td class='uncovered' width='6'/>
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>35</tt>
432
+ <td class='lines_total'><tt>38</tt>
433
433
  </td>
434
- <td class='lines_code'><tt>12</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
  &nbsp;</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 Thu Aug 21 17:23:12 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
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>178</tt>
574
+ <td class='lines_total'><tt>185</tt>
575
575
  </td>
576
- <td class='lines_code'><tt>142</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'>52.8%</tt>
578
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>53.0%</tt>
579
579
  &nbsp;</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.1%</tt>
588
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>45.6%</tt>
589
589
  &nbsp;</td>
590
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='45'/>
591
- <td class='uncovered' width='55'/>
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 class ClassX
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 args[:default]
713
- </span><span class="inferred0"><a name="line113"></a>113 end
714
- </span><span class="inferred1"><a name="line114"></a>114 end
715
- </span><span class="inferred0"><a name="line115"></a>115
716
- </span><span class="inferred1"><a name="line116"></a>116 # when this option specify true, not raise error in #initialize without value.
717
- </span><span class="marked0"><a name="line117"></a>117 define_method :optional? do
718
- </span><span class="marked1"><a name="line118"></a>118 return args[:optional]
719
- </span><span class="inferred0"><a name="line119"></a>119 end
720
- </span><span class="inferred1"><a name="line120"></a>120
721
- </span><span class="inferred0"><a name="line121"></a>121 # when it lazy option specified, it will not be initialized when #initialize.
722
- </span><span class="marked1"><a name="line122"></a>122 define_method :lazy? do
723
- </span><span class="marked0"><a name="line123"></a>123 return args[:lazy]
724
- </span><span class="inferred1"><a name="line124"></a>124 end
725
- </span><span class="inferred0"><a name="line125"></a>125
726
- </span><span class="inferred1"><a name="line126"></a>126 end
727
- </span><span class="marked0"><a name="line127"></a>127 __send__ :extend, tmp_mod
728
- </span><span class="inferred1"><a name="line128"></a>128
729
- </span><span class="marked0"><a name="line129"></a>129 raise ClassX::RequiredAttrShouldNotHaveDefault if args[:optional] == false &amp;&amp; !args[:default].nil?
730
- </span><span class="marked1"><a name="line130"></a>130 raise ClassX::OptionalAttrShouldBeWritable if args[:optional] &amp;&amp; args[:writable] == false
731
- </span><span class="inferred0"><a name="line131"></a>131
732
- </span><span class="marked1"><a name="line132"></a>132 define_method :initialize do |val|
733
- </span><span class="marked0"><a name="line133"></a>133 @parent = val
734
- </span><span class="marked1"><a name="line134"></a>134 @data = nil
735
- </span><span class="inferred0"><a name="line135"></a>135 end
736
- </span><span class="inferred1"><a name="line136"></a>136
737
- </span><span class="marked0"><a name="line137"></a>137 define_method :get do
738
- </span><span class="marked1"><a name="line138"></a>138 @data ||= self.class.default(@parent)
739
- </span><span class="inferred0"><a name="line139"></a>139 end
740
- </span><span class="inferred1"><a name="line140"></a>140
741
- </span><span class="marked0"><a name="line141"></a>141 define_method :set do |val|
742
- </span><span class="marked1"><a name="line142"></a>142 val = self.class.coerce(val)
743
- </span><span class="marked0"><a name="line143"></a>143 raise ClassX::InvalidAttrArgument unless self.class.validate? val
744
- </span><span class="marked1"><a name="line144"></a>144 @data = val
745
- </span><span class="inferred0"><a name="line145"></a>145 end
746
- </span><span class="inferred1"><a name="line146"></a>146
747
- </span><span class="inferred0"><a name="line147"></a>147 # for extending attribute point.
748
- </span><span class="marked1"><a name="line148"></a>148 if args[:include]
749
- </span><span class="uncovered0"><a name="line149"></a>149 case args[:include]
750
- </span><span class="uncovered1"><a name="line150"></a>150 when Array
751
- </span><span class="uncovered0"><a name="line151"></a>151 args[:include].each do |mod|
752
- </span><span class="uncovered1"><a name="line152"></a>152 self.__send__ :include, mod
753
- </span><span class="uncovered0"><a name="line153"></a>153 end
754
- </span><span class="uncovered1"><a name="line154"></a>154 else
755
- </span><span class="uncovered0"><a name="line155"></a>155 self.__send__ :include, args[:include]
756
- </span><span class="uncovered1"><a name="line156"></a>156 end
757
- </span><span class="uncovered0"><a name="line157"></a>157 end
758
- </span><span class="inferred1"><a name="line158"></a>158
759
- </span><span class="marked0"><a name="line159"></a>159 if args[:extend]
760
- </span><span class="uncovered1"><a name="line160"></a>160 case args[:extend]
761
- </span><span class="uncovered0"><a name="line161"></a>161 when Array
762
- </span><span class="uncovered1"><a name="line162"></a>162 args[:extend].each do |mod|
763
- </span><span class="uncovered0"><a name="line163"></a>163 self.__send__ :extend, mod
764
- </span><span class="uncovered1"><a name="line164"></a>164 end
765
- </span><span class="uncovered0"><a name="line165"></a>165 else
766
- </span><span class="uncovered1"><a name="line166"></a>166 self.__send__ :extend, args[:extend]
767
- </span><span class="uncovered0"><a name="line167"></a>167 end
768
- </span><span class="uncovered1"><a name="line168"></a>168 end
769
- </span><span class="inferred0"><a name="line169"></a>169
770
- </span><span class="marked1"><a name="line170"></a>170 define_method :inspect do
771
- </span><span class="uncovered0"><a name="line171"></a>171 &quot;&lt;#ClassX::Attribute #{self.class.config.inspect}:#{object_id} #{ @data.nil? ? '' : '@data=' + @data.inspect } &gt;&quot;
772
- </span><span class="uncovered1"><a name="line172"></a>172 end
773
- </span><span class="uncovered0"><a name="line173"></a>173 end
774
- </span><span class="inferred1"><a name="line174"></a>174
775
- </span><span class="marked0"><a name="line175"></a>175 klass
776
- </span><span class="inferred1"><a name="line176"></a>176 end
777
- </span><span class="inferred0"><a name="line177"></a>177 end
778
- </span><span class="inferred1"><a name="line178"></a>178 end
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 &quot;ClassX::Attribute[#{self.config.inspect}]&quot;
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 &amp;&amp; !args[:default].nil?
737
+ </span><span class="marked0"><a name="line137"></a>137 raise ClassX::OptionalAttrShouldBeWritable if args[:optional] &amp;&amp; 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 &quot;&lt;#ClassX::Attribute:#{object_id} #{ @data.nil? ? '@data=nil' : '@data=' + @data.inspect } config=#{self.class.config.inspect}&gt;&quot;
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>