classx 0.0.3 → 0.0.4
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 +354 -0
- data/README +5 -0
- data/Rakefile +2 -2
- data/bench/attribute_get.rb +73 -0
- data/bench/attribute_set.rb +53 -19
- data/bench/define_attribute.rb +226 -0
- data/bench/initialize.rb +25 -7
- data/doc/output/coverage/index.html +74 -128
- data/doc/output/coverage/lib-classx-attribute_rb.html +291 -190
- data/doc/output/coverage/lib-classx-attributes_rb.html +167 -101
- data/doc/output/coverage/lib-classx-bracketable_rb.html +671 -0
- data/doc/output/coverage/lib-classx-class_attributes_rb.html +775 -0
- data/doc/output/coverage/lib-classx-commandable_rb.html +727 -0
- data/doc/output/coverage/{-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-block_rb.html → lib-classx-declare_rb.html} +60 -62
- data/doc/output/coverage/lib-classx-validate_rb.html +43 -41
- data/doc/output/coverage/lib-classx_rb.html +208 -78
- data/example/commandable.rb +1 -0
- data/lib/classx.rb +146 -16
- data/lib/classx/attribute.rb +244 -143
- data/lib/classx/attributes.rb +93 -27
- data/lib/classx/bracketable.rb +61 -0
- data/lib/classx/class_attributes.rb +165 -0
- data/lib/classx/commandable.rb +55 -4
- data/lib/classx/declare.rb +40 -3
- data/lib/classx/role/logger.rb +17 -13
- data/lib/classx/validate.rb +26 -24
- data/spec/classx/handles_spec.rb +21 -6
- data/spec/classx/serialize_spec.rb +57 -0
- data/spec/classx/{with_coerce.rb → with_coerce_spec.rb} +0 -0
- data/spec/classx/with_extend_spec.rb +58 -0
- data/spec/classx/with_include_spec.rb +58 -0
- data/spec/classx/with_validate_spec.rb +363 -0
- data/spec/classx/without_anyoption_spec.rb +1 -1
- data/spec/classx/writable_option_spec.rb +29 -4
- data/spec/classx_bracketable_spec.rb +160 -0
- data/spec/classx_class_attributes/default_option_spec.rb +121 -0
- data/spec/classx_class_attributes/dsl_accessor_spec.rb +88 -0
- data/spec/classx_class_attributes/handles_spec.rb +77 -0
- data/spec/classx_class_attributes/with_coerce_spec.rb +119 -0
- data/spec/classx_class_attributes/with_extend_spec.rb +64 -0
- data/spec/classx_class_attributes/with_include_spec.rb +64 -0
- data/spec/classx_class_attributes/with_multiple_class_spec.rb +60 -0
- data/spec/classx_class_attributes/with_validate_spec.rb +248 -0
- data/spec/classx_class_attributes/without_accessor_spec.rb +19 -0
- data/spec/classx_class_attributes/without_anyoption_spec.rb +21 -0
- data/spec/classx_class_attributes/writable_option_spec.rb +100 -0
- data/spec/classx_declare_spec.rb +117 -0
- data/spec/classx_validate_spec.rb +1 -3
- data/tasks/basic_tasks.rake +1 -1
- metadata +36 -26
- data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-callbacks_rb.html +0 -932
- data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-change_rb.html +0 -779
- data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-hunk_rb.html +0 -867
- data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs_rb.html +0 -1715
- data/doc/output/coverage/-Library-Ruby-Gems-gems-rcov-0_8_1_2_0-lib-rcov_rb.html +0 -1598
- data/spec/classx/with_extend.rb +0 -27
- data/spec/classx/with_include.rb +0 -27
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
require 'classx'
|
3
|
+
|
4
|
+
describe ClassX::ClassAttributes do
|
5
|
+
describe '#class_has' do
|
6
|
+
describe 'without accessor' do
|
7
|
+
before do
|
8
|
+
@class = Class.new
|
9
|
+
@class.class_eval do
|
10
|
+
extend ClassX::ClassAttributes
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have empty attributes' do
|
15
|
+
@class.class_attribute_of.keys.should be_empty
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
require 'classx'
|
3
|
+
|
4
|
+
describe ClassX::ClassAttributes do
|
5
|
+
describe '#class_has' do
|
6
|
+
describe 'without any option' do
|
7
|
+
before do
|
8
|
+
@class = Class.new
|
9
|
+
@class.class_eval do
|
10
|
+
extend ClassX::ClassAttributes
|
11
|
+
|
12
|
+
class_has :x
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should define class.x= private method to class' do
|
17
|
+
@class.private_methods.map {|meth| meth.to_s }.should include("x=")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
require 'classx'
|
3
|
+
|
4
|
+
describe ClassX::ClassAttributes do
|
5
|
+
describe '#class_has' do
|
6
|
+
describe 'with :writable option' do
|
7
|
+
describe 'when you specify false for attribute' do
|
8
|
+
before do
|
9
|
+
@class = Class.new
|
10
|
+
@class.class_eval do
|
11
|
+
extend ClassX::ClassAttributes
|
12
|
+
class_has :x, :writable => false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should define class.x public method to class' do
|
17
|
+
@class.methods.map {|meth| meth.to_s }.should include('x')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should define class.x= private method to class' do
|
21
|
+
@class.private_methods.map {|meth| meth.to_s }.should include("x=")
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should have attributes [:x]' do
|
25
|
+
@class.class_attribute_of.keys.should == ['x']
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should raise NoMethodError using attr_name = val' do
|
29
|
+
lambda { @class.x = 20 }.should raise_error(NoMethodError)
|
30
|
+
end
|
31
|
+
|
32
|
+
# NOTE: why don't it unify Exception Class between above and this?
|
33
|
+
# => This exception was caused by mistake of program. So, in general I think, you should not
|
34
|
+
# rascue this error.
|
35
|
+
it 'should raise RuntimeError using attr_name(val)' do
|
36
|
+
pending "I don't know how to know call this method from class context or reciever context." do
|
37
|
+
lambda { @class.x(20) }.should raise_error(RuntimeError)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'when you specify true for attribute' do
|
43
|
+
before do
|
44
|
+
@class = Class.new
|
45
|
+
@class.class_eval do
|
46
|
+
extend ClassX::ClassAttributes
|
47
|
+
class_has :x, :writable => true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should define class.x public method to class' do
|
52
|
+
@class.methods.map {|meth| meth.to_s }.should include('x')
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should define class.x= public method to class' do
|
56
|
+
@class.public_methods.map {|meth| meth.to_s }.should include("x=")
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should have attributes [:x]' do
|
60
|
+
@class.class_attribute_of.keys.should == ['x']
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should update value using attr_name = val' do
|
64
|
+
@class.x = 20
|
65
|
+
@class.x.should == 20
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should update value using attr_name(val)' do
|
69
|
+
@class.x(20)
|
70
|
+
@class.x.should == 20
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'with :writable is false' do
|
77
|
+
it 'should raise ClassX::OptionalAttrShouldBeWritable' do
|
78
|
+
lambda {
|
79
|
+
klass = Class.new
|
80
|
+
klass.class_eval do
|
81
|
+
extend ClassX::ClassAttributes
|
82
|
+
class_has :x, :optional => true, :writable => false
|
83
|
+
end
|
84
|
+
}.should raise_error(ClassX::OptionalAttrShouldBeWritable)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe 'with :writable is true' do
|
89
|
+
it 'should not raise ClassX::OptionalAttrShouldBeWritable' do
|
90
|
+
lambda {
|
91
|
+
klass = Class.new
|
92
|
+
klass.class_eval do
|
93
|
+
extend ClassX::ClassAttributes
|
94
|
+
class_has :x, :optional => true, :writable => true
|
95
|
+
end
|
96
|
+
}.should_not raise_error(ClassX::OptionalAttrShouldBeWritable)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
require 'classx'
|
3
|
+
require 'classx/declare'
|
4
|
+
|
5
|
+
describe ClassX::Declare do
|
6
|
+
describe 'simple define' do
|
7
|
+
before do
|
8
|
+
|
9
|
+
@class = Class.new
|
10
|
+
@class.class_eval do
|
11
|
+
extend ClassX::Declare
|
12
|
+
|
13
|
+
classx :Class do
|
14
|
+
has :x
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should define class into class' do
|
20
|
+
@class.constants.map {|k| k.to_s }.should include("Class")
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have attributes' do
|
24
|
+
@class.const_get('Class').attribute_of.keys.should == ["x"]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'with CAttrs' do
|
29
|
+
before do
|
30
|
+
|
31
|
+
@class = Class.new
|
32
|
+
@class.class_eval do
|
33
|
+
extend ClassX::Declare
|
34
|
+
|
35
|
+
classx :Class, [:CAttrs] do
|
36
|
+
class_has :x
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should define class into class' do
|
42
|
+
@class.constants.map {|k| k.to_s }.should include("Class")
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should have class attributes' do
|
46
|
+
@class.const_get('Class').class_attribute_of.keys.should == ["x"]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'with Commandable' do
|
51
|
+
before do
|
52
|
+
|
53
|
+
@class = Class.new
|
54
|
+
@class.class_eval do
|
55
|
+
extend ClassX::Declare
|
56
|
+
|
57
|
+
classx :Class, [:Commandable] do
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should define class into class' do
|
63
|
+
@class.constants.map {|k| k.to_s }.should include("Class")
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should have :from_argv method' do
|
67
|
+
@class.const_get('Class').respond_to?(:from_argv).should be_true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe 'with Bracketable' do
|
72
|
+
before do
|
73
|
+
|
74
|
+
@class = Class.new
|
75
|
+
@class.class_eval do
|
76
|
+
extend ClassX::Declare
|
77
|
+
|
78
|
+
classx :Class, [:Bracketable] do
|
79
|
+
has :x
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should define class into class' do
|
85
|
+
@class.constants.map {|k| k.to_s }.should include("Class")
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should access Hash like interface' do
|
89
|
+
obj = @class.const_get('Class').new(:x => 10)
|
90
|
+
obj[:x].should == 10
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe 'nested define' do
|
95
|
+
before do
|
96
|
+
|
97
|
+
@class = Class.new
|
98
|
+
@class.class_eval do
|
99
|
+
extend ClassX::Declare
|
100
|
+
|
101
|
+
classx :Class do
|
102
|
+
classx :Class do
|
103
|
+
has :x
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should define class into class' do
|
110
|
+
@class.const_get('Class').constants.map {|k| k.to_s }.should include("Class")
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should have attributes' do
|
114
|
+
@class.const_get('Class').const_get('Class').attribute_of.keys.should == ["x"]
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -3,14 +3,12 @@ require 'classx'
|
|
3
3
|
require 'classx/validate'
|
4
4
|
|
5
5
|
describe ClassX::Validate do
|
6
|
-
include ClassX::Validate
|
7
6
|
before do
|
8
7
|
@class = Class.new
|
9
8
|
@class.class_eval do
|
10
|
-
include ClassX::Validate
|
11
9
|
|
12
10
|
def run params
|
13
|
-
validate params do
|
11
|
+
ClassX::Validate.validate params do
|
14
12
|
has :x
|
15
13
|
has :y, :kind_of => Integer
|
16
14
|
end
|
data/tasks/basic_tasks.rake
CHANGED
@@ -18,7 +18,7 @@ Spec::Rake::SpecTask.new(:spec) do |t|
|
|
18
18
|
t.warning = true
|
19
19
|
t.rcov = true
|
20
20
|
t.rcov_dir = 'doc/output/coverage'
|
21
|
-
t.rcov_opts = ['--exclude', 'spec,\.autotest']
|
21
|
+
t.rcov_opts = ['--exclude', 'spec,\.autotest,/Library/']
|
22
22
|
end
|
23
23
|
|
24
24
|
desc "Heckle each module and class in turn"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: classx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keiji, Yoshimi
|
@@ -9,20 +9,11 @@ autorequire: ""
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-09-13 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
type: :development
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 1.1.4
|
24
|
-
version:
|
25
|
-
description: ""
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Meta Framework extending and flexible attribute like Moose ( perl )
|
26
17
|
email: walf443 at gmail.com
|
27
18
|
executables: []
|
28
19
|
|
@@ -38,9 +29,10 @@ files:
|
|
38
29
|
- lib/classx
|
39
30
|
- lib/classx/attribute.rb
|
40
31
|
- lib/classx/attributes.rb
|
32
|
+
- lib/classx/bracketable.rb
|
33
|
+
- lib/classx/class_attributes.rb
|
41
34
|
- lib/classx/commandable.rb
|
42
35
|
- lib/classx/declare.rb
|
43
|
-
- lib/classx/include
|
44
36
|
- lib/classx/role
|
45
37
|
- lib/classx/role/logger.rb
|
46
38
|
- lib/classx/validate.rb
|
@@ -48,31 +40,47 @@ files:
|
|
48
40
|
- spec/classx
|
49
41
|
- spec/classx/default_option_spec.rb
|
50
42
|
- spec/classx/handles_spec.rb
|
51
|
-
- spec/classx/
|
52
|
-
- spec/classx/
|
53
|
-
- spec/classx/
|
43
|
+
- spec/classx/serialize_spec.rb
|
44
|
+
- spec/classx/with_coerce_spec.rb
|
45
|
+
- spec/classx/with_extend_spec.rb
|
46
|
+
- spec/classx/with_include_spec.rb
|
54
47
|
- spec/classx/with_multiple_class_spec.rb
|
48
|
+
- spec/classx/with_validate_spec.rb
|
55
49
|
- spec/classx/without_accessor_spec.rb
|
56
50
|
- spec/classx/without_anyoption_spec.rb
|
57
51
|
- spec/classx/writable_option_spec.rb
|
58
52
|
- spec/classx_attributes_spec.rb
|
53
|
+
- spec/classx_bracketable_spec.rb
|
54
|
+
- spec/classx_class_attributes
|
55
|
+
- spec/classx_class_attributes/default_option_spec.rb
|
56
|
+
- spec/classx_class_attributes/dsl_accessor_spec.rb
|
57
|
+
- spec/classx_class_attributes/handles_spec.rb
|
58
|
+
- spec/classx_class_attributes/with_coerce_spec.rb
|
59
|
+
- spec/classx_class_attributes/with_extend_spec.rb
|
60
|
+
- spec/classx_class_attributes/with_include_spec.rb
|
61
|
+
- spec/classx_class_attributes/with_multiple_class_spec.rb
|
62
|
+
- spec/classx_class_attributes/with_validate_spec.rb
|
63
|
+
- spec/classx_class_attributes/without_accessor_spec.rb
|
64
|
+
- spec/classx_class_attributes/without_anyoption_spec.rb
|
65
|
+
- spec/classx_class_attributes/writable_option_spec.rb
|
66
|
+
- spec/classx_declare_spec.rb
|
59
67
|
- spec/classx_validate_spec.rb
|
60
68
|
- spec/spec.opts
|
61
69
|
- spec/spec_helper.rb
|
62
70
|
- doc/output
|
63
71
|
- doc/output/coverage
|
64
|
-
- doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-block_rb.html
|
65
|
-
- doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-callbacks_rb.html
|
66
|
-
- doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-change_rb.html
|
67
|
-
- doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-hunk_rb.html
|
68
|
-
- doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs_rb.html
|
69
|
-
- doc/output/coverage/-Library-Ruby-Gems-gems-rcov-0_8_1_2_0-lib-rcov_rb.html
|
70
72
|
- doc/output/coverage/index.html
|
71
73
|
- doc/output/coverage/lib-classx-attribute_rb.html
|
72
74
|
- doc/output/coverage/lib-classx-attributes_rb.html
|
75
|
+
- doc/output/coverage/lib-classx-bracketable_rb.html
|
76
|
+
- doc/output/coverage/lib-classx-class_attributes_rb.html
|
77
|
+
- doc/output/coverage/lib-classx-commandable_rb.html
|
78
|
+
- doc/output/coverage/lib-classx-declare_rb.html
|
73
79
|
- doc/output/coverage/lib-classx-validate_rb.html
|
74
80
|
- doc/output/coverage/lib-classx_rb.html
|
81
|
+
- bench/attribute_get.rb
|
75
82
|
- bench/attribute_set.rb
|
83
|
+
- bench/define_attribute.rb
|
76
84
|
- bench/initialize.rb
|
77
85
|
- example/commandable.rb
|
78
86
|
- tasks/basic_config.rake
|
@@ -110,10 +118,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
118
|
requirements: []
|
111
119
|
|
112
120
|
rubyforge_project: akasakarb
|
113
|
-
rubygems_version:
|
121
|
+
rubygems_version: 1.0.1
|
114
122
|
signing_key:
|
115
123
|
specification_version: 2
|
116
|
-
summary:
|
124
|
+
summary: Meta Framework extending and flexible attribute like Moose ( perl )
|
117
125
|
test_files:
|
118
126
|
- spec/classx_attributes_spec.rb
|
127
|
+
- spec/classx_bracketable_spec.rb
|
128
|
+
- spec/classx_declare_spec.rb
|
119
129
|
- spec/classx_validate_spec.rb
|
data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-callbacks_rb.html
DELETED
@@ -1,932 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
-
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'><head><title>/Library/Ruby/Gems/gems/diff-lcs-1.1.2/lib/diff/lcs/callbacks.rb - C0 code coverage information</title>
|
3
|
-
<style type='text/css'>body { background-color: rgb(240, 240, 245); }</style>
|
4
|
-
<style type='text/css'>span.cross-ref-title {
|
5
|
-
font-size: 140%;
|
6
|
-
}
|
7
|
-
span.cross-ref a {
|
8
|
-
text-decoration: none;
|
9
|
-
}
|
10
|
-
span.cross-ref {
|
11
|
-
background-color:#f3f7fa;
|
12
|
-
border: 1px dashed #333;
|
13
|
-
margin: 1em;
|
14
|
-
padding: 0.5em;
|
15
|
-
overflow: hidden;
|
16
|
-
}
|
17
|
-
a.crossref-toggle {
|
18
|
-
text-decoration: none;
|
19
|
-
}
|
20
|
-
span.marked0 {
|
21
|
-
background-color: rgb(185, 210, 200);
|
22
|
-
display: block;
|
23
|
-
}
|
24
|
-
span.marked1 {
|
25
|
-
background-color: rgb(190, 215, 205);
|
26
|
-
display: block;
|
27
|
-
}
|
28
|
-
span.inferred0 {
|
29
|
-
background-color: rgb(175, 200, 200);
|
30
|
-
display: block;
|
31
|
-
}
|
32
|
-
span.inferred1 {
|
33
|
-
background-color: rgb(180, 205, 205);
|
34
|
-
display: block;
|
35
|
-
}
|
36
|
-
span.uncovered0 {
|
37
|
-
background-color: rgb(225, 110, 110);
|
38
|
-
display: block;
|
39
|
-
}
|
40
|
-
span.uncovered1 {
|
41
|
-
background-color: rgb(235, 120, 120);
|
42
|
-
display: block;
|
43
|
-
}
|
44
|
-
span.overview {
|
45
|
-
border-bottom: 8px solid black;
|
46
|
-
}
|
47
|
-
div.overview {
|
48
|
-
border-bottom: 8px solid black;
|
49
|
-
}
|
50
|
-
body {
|
51
|
-
font-family: verdana, arial, helvetica;
|
52
|
-
}
|
53
|
-
div.footer {
|
54
|
-
font-size: 68%;
|
55
|
-
margin-top: 1.5em;
|
56
|
-
}
|
57
|
-
h1, h2, h3, h4, h5, h6 {
|
58
|
-
margin-bottom: 0.5em;
|
59
|
-
}
|
60
|
-
h5 {
|
61
|
-
margin-top: 0.5em;
|
62
|
-
}
|
63
|
-
.hidden {
|
64
|
-
display: none;
|
65
|
-
}
|
66
|
-
div.separator {
|
67
|
-
height: 10px;
|
68
|
-
}
|
69
|
-
/* Commented out for better readability, esp. on IE */
|
70
|
-
/*
|
71
|
-
table tr td, table tr th {
|
72
|
-
font-size: 68%;
|
73
|
-
}
|
74
|
-
td.value table tr td {
|
75
|
-
font-size: 11px;
|
76
|
-
}
|
77
|
-
*/
|
78
|
-
table.percent_graph {
|
79
|
-
height: 12px;
|
80
|
-
border: #808080 1px solid;
|
81
|
-
empty-cells: show;
|
82
|
-
}
|
83
|
-
table.percent_graph td.covered {
|
84
|
-
height: 10px;
|
85
|
-
background: #00f000;
|
86
|
-
}
|
87
|
-
table.percent_graph td.uncovered {
|
88
|
-
height: 10px;
|
89
|
-
background: #e00000;
|
90
|
-
}
|
91
|
-
table.percent_graph td.NA {
|
92
|
-
height: 10px;
|
93
|
-
background: #eaeaea;
|
94
|
-
}
|
95
|
-
table.report {
|
96
|
-
border-collapse: collapse;
|
97
|
-
width: 100%;
|
98
|
-
}
|
99
|
-
table.report td.heading {
|
100
|
-
background: #dcecff;
|
101
|
-
border: #d0d0d0 1px solid;
|
102
|
-
font-weight: bold;
|
103
|
-
text-align: center;
|
104
|
-
}
|
105
|
-
table.report td.heading:hover {
|
106
|
-
background: #c0ffc0;
|
107
|
-
}
|
108
|
-
table.report td.text {
|
109
|
-
border: #d0d0d0 1px solid;
|
110
|
-
}
|
111
|
-
table.report td.value,
|
112
|
-
table.report td.lines_total,
|
113
|
-
table.report td.lines_code {
|
114
|
-
text-align: right;
|
115
|
-
border: #d0d0d0 1px solid;
|
116
|
-
}
|
117
|
-
table.report tr.light {
|
118
|
-
background-color: rgb(240, 240, 245);
|
119
|
-
}
|
120
|
-
table.report tr.dark {
|
121
|
-
background-color: rgb(230, 230, 235);
|
122
|
-
}
|
123
|
-
</style>
|
124
|
-
<script type='text/javascript'>
|
125
|
-
// <![CDATA[
|
126
|
-
function toggleCode( id ) {
|
127
|
-
if ( document.getElementById )
|
128
|
-
elem = document.getElementById( id );
|
129
|
-
else if ( document.all )
|
130
|
-
elem = eval( "document.all." + id );
|
131
|
-
else
|
132
|
-
return false;
|
133
|
-
|
134
|
-
elemStyle = elem.style;
|
135
|
-
|
136
|
-
if ( elemStyle.display != "block" ) {
|
137
|
-
elemStyle.display = "block"
|
138
|
-
} else {
|
139
|
-
elemStyle.display = "none"
|
140
|
-
}
|
141
|
-
|
142
|
-
return true;
|
143
|
-
}
|
144
|
-
|
145
|
-
// Make cross-references hidden by default
|
146
|
-
document.writeln( "<style type=\"text/css\">span.cross-ref { display: none }</style>" )
|
147
|
-
// ]]>
|
148
|
-
</script>
|
149
|
-
<style type='text/css'>span.run0 {
|
150
|
-
background-color: rgb(178, 204, 255);
|
151
|
-
display: block;
|
152
|
-
}
|
153
|
-
span.run1 {
|
154
|
-
background-color: rgb(178, 206, 255);
|
155
|
-
display: block;
|
156
|
-
}
|
157
|
-
span.run2 {
|
158
|
-
background-color: rgb(178, 209, 255);
|
159
|
-
display: block;
|
160
|
-
}
|
161
|
-
span.run3 {
|
162
|
-
background-color: rgb(178, 211, 255);
|
163
|
-
display: block;
|
164
|
-
}
|
165
|
-
span.run4 {
|
166
|
-
background-color: rgb(178, 214, 255);
|
167
|
-
display: block;
|
168
|
-
}
|
169
|
-
span.run5 {
|
170
|
-
background-color: rgb(178, 218, 255);
|
171
|
-
display: block;
|
172
|
-
}
|
173
|
-
span.run6 {
|
174
|
-
background-color: rgb(178, 220, 255);
|
175
|
-
display: block;
|
176
|
-
}
|
177
|
-
span.run7 {
|
178
|
-
background-color: rgb(178, 223, 255);
|
179
|
-
display: block;
|
180
|
-
}
|
181
|
-
span.run8 {
|
182
|
-
background-color: rgb(178, 225, 255);
|
183
|
-
display: block;
|
184
|
-
}
|
185
|
-
span.run9 {
|
186
|
-
background-color: rgb(178, 228, 255);
|
187
|
-
display: block;
|
188
|
-
}
|
189
|
-
span.run10 {
|
190
|
-
background-color: rgb(178, 232, 255);
|
191
|
-
display: block;
|
192
|
-
}
|
193
|
-
span.run11 {
|
194
|
-
background-color: rgb(178, 234, 255);
|
195
|
-
display: block;
|
196
|
-
}
|
197
|
-
span.run12 {
|
198
|
-
background-color: rgb(178, 237, 255);
|
199
|
-
display: block;
|
200
|
-
}
|
201
|
-
span.run13 {
|
202
|
-
background-color: rgb(178, 239, 255);
|
203
|
-
display: block;
|
204
|
-
}
|
205
|
-
span.run14 {
|
206
|
-
background-color: rgb(178, 242, 255);
|
207
|
-
display: block;
|
208
|
-
}
|
209
|
-
span.run15 {
|
210
|
-
background-color: rgb(178, 246, 255);
|
211
|
-
display: block;
|
212
|
-
}
|
213
|
-
span.run16 {
|
214
|
-
background-color: rgb(178, 248, 255);
|
215
|
-
display: block;
|
216
|
-
}
|
217
|
-
span.run17 {
|
218
|
-
background-color: rgb(178, 251, 255);
|
219
|
-
display: block;
|
220
|
-
}
|
221
|
-
span.run18 {
|
222
|
-
background-color: rgb(178, 253, 255);
|
223
|
-
display: block;
|
224
|
-
}
|
225
|
-
span.run19 {
|
226
|
-
background-color: rgb(178, 255, 253);
|
227
|
-
display: block;
|
228
|
-
}
|
229
|
-
span.run20 {
|
230
|
-
background-color: rgb(178, 255, 249);
|
231
|
-
display: block;
|
232
|
-
}
|
233
|
-
span.run21 {
|
234
|
-
background-color: rgb(178, 255, 247);
|
235
|
-
display: block;
|
236
|
-
}
|
237
|
-
span.run22 {
|
238
|
-
background-color: rgb(178, 255, 244);
|
239
|
-
display: block;
|
240
|
-
}
|
241
|
-
span.run23 {
|
242
|
-
background-color: rgb(178, 255, 242);
|
243
|
-
display: block;
|
244
|
-
}
|
245
|
-
span.run24 {
|
246
|
-
background-color: rgb(178, 255, 239);
|
247
|
-
display: block;
|
248
|
-
}
|
249
|
-
span.run25 {
|
250
|
-
background-color: rgb(178, 255, 235);
|
251
|
-
display: block;
|
252
|
-
}
|
253
|
-
span.run26 {
|
254
|
-
background-color: rgb(178, 255, 233);
|
255
|
-
display: block;
|
256
|
-
}
|
257
|
-
span.run27 {
|
258
|
-
background-color: rgb(178, 255, 230);
|
259
|
-
display: block;
|
260
|
-
}
|
261
|
-
span.run28 {
|
262
|
-
background-color: rgb(178, 255, 228);
|
263
|
-
display: block;
|
264
|
-
}
|
265
|
-
span.run29 {
|
266
|
-
background-color: rgb(178, 255, 225);
|
267
|
-
display: block;
|
268
|
-
}
|
269
|
-
span.run30 {
|
270
|
-
background-color: rgb(178, 255, 221);
|
271
|
-
display: block;
|
272
|
-
}
|
273
|
-
span.run31 {
|
274
|
-
background-color: rgb(178, 255, 219);
|
275
|
-
display: block;
|
276
|
-
}
|
277
|
-
span.run32 {
|
278
|
-
background-color: rgb(178, 255, 216);
|
279
|
-
display: block;
|
280
|
-
}
|
281
|
-
span.run33 {
|
282
|
-
background-color: rgb(178, 255, 214);
|
283
|
-
display: block;
|
284
|
-
}
|
285
|
-
span.run34 {
|
286
|
-
background-color: rgb(178, 255, 211);
|
287
|
-
display: block;
|
288
|
-
}
|
289
|
-
span.run35 {
|
290
|
-
background-color: rgb(178, 255, 207);
|
291
|
-
display: block;
|
292
|
-
}
|
293
|
-
span.run36 {
|
294
|
-
background-color: rgb(178, 255, 205);
|
295
|
-
display: block;
|
296
|
-
}
|
297
|
-
span.run37 {
|
298
|
-
background-color: rgb(178, 255, 202);
|
299
|
-
display: block;
|
300
|
-
}
|
301
|
-
span.run38 {
|
302
|
-
background-color: rgb(178, 255, 200);
|
303
|
-
display: block;
|
304
|
-
}
|
305
|
-
span.run39 {
|
306
|
-
background-color: rgb(178, 255, 197);
|
307
|
-
display: block;
|
308
|
-
}
|
309
|
-
span.run40 {
|
310
|
-
background-color: rgb(178, 255, 193);
|
311
|
-
display: block;
|
312
|
-
}
|
313
|
-
span.run41 {
|
314
|
-
background-color: rgb(178, 255, 191);
|
315
|
-
display: block;
|
316
|
-
}
|
317
|
-
span.run42 {
|
318
|
-
background-color: rgb(178, 255, 188);
|
319
|
-
display: block;
|
320
|
-
}
|
321
|
-
span.run43 {
|
322
|
-
background-color: rgb(178, 255, 186);
|
323
|
-
display: block;
|
324
|
-
}
|
325
|
-
span.run44 {
|
326
|
-
background-color: rgb(178, 255, 183);
|
327
|
-
display: block;
|
328
|
-
}
|
329
|
-
span.run45 {
|
330
|
-
background-color: rgb(178, 255, 179);
|
331
|
-
display: block;
|
332
|
-
}
|
333
|
-
span.run46 {
|
334
|
-
background-color: rgb(179, 255, 178);
|
335
|
-
display: block;
|
336
|
-
}
|
337
|
-
span.run47 {
|
338
|
-
background-color: rgb(182, 255, 178);
|
339
|
-
display: block;
|
340
|
-
}
|
341
|
-
span.run48 {
|
342
|
-
background-color: rgb(184, 255, 178);
|
343
|
-
display: block;
|
344
|
-
}
|
345
|
-
span.run49 {
|
346
|
-
background-color: rgb(187, 255, 178);
|
347
|
-
display: block;
|
348
|
-
}
|
349
|
-
span.run50 {
|
350
|
-
background-color: rgb(191, 255, 178);
|
351
|
-
display: block;
|
352
|
-
}
|
353
|
-
span.run51 {
|
354
|
-
background-color: rgb(193, 255, 178);
|
355
|
-
display: block;
|
356
|
-
}
|
357
|
-
span.run52 {
|
358
|
-
background-color: rgb(196, 255, 178);
|
359
|
-
display: block;
|
360
|
-
}
|
361
|
-
span.run53 {
|
362
|
-
background-color: rgb(198, 255, 178);
|
363
|
-
display: block;
|
364
|
-
}
|
365
|
-
span.run54 {
|
366
|
-
background-color: rgb(201, 255, 178);
|
367
|
-
display: block;
|
368
|
-
}
|
369
|
-
span.run55 {
|
370
|
-
background-color: rgb(205, 255, 178);
|
371
|
-
display: block;
|
372
|
-
}
|
373
|
-
span.run56 {
|
374
|
-
background-color: rgb(207, 255, 178);
|
375
|
-
display: block;
|
376
|
-
}
|
377
|
-
span.run57 {
|
378
|
-
background-color: rgb(210, 255, 178);
|
379
|
-
display: block;
|
380
|
-
}
|
381
|
-
span.run58 {
|
382
|
-
background-color: rgb(212, 255, 178);
|
383
|
-
display: block;
|
384
|
-
}
|
385
|
-
span.run59 {
|
386
|
-
background-color: rgb(215, 255, 178);
|
387
|
-
display: block;
|
388
|
-
}
|
389
|
-
span.run60 {
|
390
|
-
background-color: rgb(219, 255, 178);
|
391
|
-
display: block;
|
392
|
-
}
|
393
|
-
span.run61 {
|
394
|
-
background-color: rgb(221, 255, 178);
|
395
|
-
display: block;
|
396
|
-
}
|
397
|
-
span.run62 {
|
398
|
-
background-color: rgb(224, 255, 178);
|
399
|
-
display: block;
|
400
|
-
}
|
401
|
-
span.run63 {
|
402
|
-
background-color: rgb(226, 255, 178);
|
403
|
-
display: block;
|
404
|
-
}
|
405
|
-
span.run64 {
|
406
|
-
background-color: rgb(229, 255, 178);
|
407
|
-
display: block;
|
408
|
-
}
|
409
|
-
span.run65 {
|
410
|
-
background-color: rgb(233, 255, 178);
|
411
|
-
display: block;
|
412
|
-
}
|
413
|
-
span.run66 {
|
414
|
-
background-color: rgb(235, 255, 178);
|
415
|
-
display: block;
|
416
|
-
}
|
417
|
-
span.run67 {
|
418
|
-
background-color: rgb(238, 255, 178);
|
419
|
-
display: block;
|
420
|
-
}
|
421
|
-
span.run68 {
|
422
|
-
background-color: rgb(240, 255, 178);
|
423
|
-
display: block;
|
424
|
-
}
|
425
|
-
span.run69 {
|
426
|
-
background-color: rgb(243, 255, 178);
|
427
|
-
display: block;
|
428
|
-
}
|
429
|
-
span.run70 {
|
430
|
-
background-color: rgb(247, 255, 178);
|
431
|
-
display: block;
|
432
|
-
}
|
433
|
-
span.run71 {
|
434
|
-
background-color: rgb(249, 255, 178);
|
435
|
-
display: block;
|
436
|
-
}
|
437
|
-
span.run72 {
|
438
|
-
background-color: rgb(252, 255, 178);
|
439
|
-
display: block;
|
440
|
-
}
|
441
|
-
span.run73 {
|
442
|
-
background-color: rgb(255, 255, 178);
|
443
|
-
display: block;
|
444
|
-
}
|
445
|
-
span.run74 {
|
446
|
-
background-color: rgb(255, 252, 178);
|
447
|
-
display: block;
|
448
|
-
}
|
449
|
-
span.run75 {
|
450
|
-
background-color: rgb(255, 248, 178);
|
451
|
-
display: block;
|
452
|
-
}
|
453
|
-
span.run76 {
|
454
|
-
background-color: rgb(255, 246, 178);
|
455
|
-
display: block;
|
456
|
-
}
|
457
|
-
span.run77 {
|
458
|
-
background-color: rgb(255, 243, 178);
|
459
|
-
display: block;
|
460
|
-
}
|
461
|
-
span.run78 {
|
462
|
-
background-color: rgb(255, 240, 178);
|
463
|
-
display: block;
|
464
|
-
}
|
465
|
-
span.run79 {
|
466
|
-
background-color: rgb(255, 238, 178);
|
467
|
-
display: block;
|
468
|
-
}
|
469
|
-
span.run80 {
|
470
|
-
background-color: rgb(255, 234, 178);
|
471
|
-
display: block;
|
472
|
-
}
|
473
|
-
span.run81 {
|
474
|
-
background-color: rgb(255, 232, 178);
|
475
|
-
display: block;
|
476
|
-
}
|
477
|
-
span.run82 {
|
478
|
-
background-color: rgb(255, 229, 178);
|
479
|
-
display: block;
|
480
|
-
}
|
481
|
-
span.run83 {
|
482
|
-
background-color: rgb(255, 226, 178);
|
483
|
-
display: block;
|
484
|
-
}
|
485
|
-
span.run84 {
|
486
|
-
background-color: rgb(255, 224, 178);
|
487
|
-
display: block;
|
488
|
-
}
|
489
|
-
span.run85 {
|
490
|
-
background-color: rgb(255, 220, 178);
|
491
|
-
display: block;
|
492
|
-
}
|
493
|
-
span.run86 {
|
494
|
-
background-color: rgb(255, 218, 178);
|
495
|
-
display: block;
|
496
|
-
}
|
497
|
-
span.run87 {
|
498
|
-
background-color: rgb(255, 215, 178);
|
499
|
-
display: block;
|
500
|
-
}
|
501
|
-
span.run88 {
|
502
|
-
background-color: rgb(255, 212, 178);
|
503
|
-
display: block;
|
504
|
-
}
|
505
|
-
span.run89 {
|
506
|
-
background-color: rgb(255, 210, 178);
|
507
|
-
display: block;
|
508
|
-
}
|
509
|
-
span.run90 {
|
510
|
-
background-color: rgb(255, 206, 178);
|
511
|
-
display: block;
|
512
|
-
}
|
513
|
-
span.run91 {
|
514
|
-
background-color: rgb(255, 204, 178);
|
515
|
-
display: block;
|
516
|
-
}
|
517
|
-
span.run92 {
|
518
|
-
background-color: rgb(255, 201, 178);
|
519
|
-
display: block;
|
520
|
-
}
|
521
|
-
span.run93 {
|
522
|
-
background-color: rgb(255, 198, 178);
|
523
|
-
display: block;
|
524
|
-
}
|
525
|
-
span.run94 {
|
526
|
-
background-color: rgb(255, 196, 178);
|
527
|
-
display: block;
|
528
|
-
}
|
529
|
-
span.run95 {
|
530
|
-
background-color: rgb(255, 192, 178);
|
531
|
-
display: block;
|
532
|
-
}
|
533
|
-
span.run96 {
|
534
|
-
background-color: rgb(255, 189, 178);
|
535
|
-
display: block;
|
536
|
-
}
|
537
|
-
span.run97 {
|
538
|
-
background-color: rgb(255, 187, 178);
|
539
|
-
display: block;
|
540
|
-
}
|
541
|
-
span.run98 {
|
542
|
-
background-color: rgb(255, 184, 178);
|
543
|
-
display: block;
|
544
|
-
}
|
545
|
-
span.run99 {
|
546
|
-
background-color: rgb(255, 182, 178);
|
547
|
-
display: block;
|
548
|
-
}
|
549
|
-
span.run100 {
|
550
|
-
background-color: rgb(255, 178, 178);
|
551
|
-
display: block;
|
552
|
-
}
|
553
|
-
</style>
|
554
|
-
</head>
|
555
|
-
<body><h3>C0 code coverage information</h3>
|
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
|
-
</p>
|
558
|
-
<hr/>
|
559
|
-
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
560
|
-
</span><span class='marked1'>and this: this line is also marked as covered.
|
561
|
-
</span><span class='inferred0'>Lines considered as run by rcov, but not reported by Ruby, look like this,
|
562
|
-
</span><span class='inferred1'>and this: these lines were inferred by rcov (using simple heuristics).
|
563
|
-
</span><span class='uncovered0'>Finally, here's a line marked as not executed.
|
564
|
-
</span></pre>
|
565
|
-
<table class='report'><thead><tr><td class='heading'>Name</td>
|
566
|
-
<td class='heading'>Total lines</td>
|
567
|
-
<td class='heading'>Lines of code</td>
|
568
|
-
<td class='heading'>Total coverage</td>
|
569
|
-
<td class='heading'>Code coverage</td>
|
570
|
-
</tr>
|
571
|
-
</thead>
|
572
|
-
<tbody><tr class='light'><td><a href='-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-callbacks_rb.html'>/Library/Ruby/Gems/gems/diff-lcs-1.1.2/lib/diff/lcs/callbacks.rb</a>
|
573
|
-
</td>
|
574
|
-
<td class='lines_total'><tt>322</tt>
|
575
|
-
</td>
|
576
|
-
<td class='lines_code'><tt>83</tt>
|
577
|
-
</td>
|
578
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>84.5%</tt>
|
579
|
-
</td>
|
580
|
-
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='84'/>
|
581
|
-
<td class='uncovered' width='16'/>
|
582
|
-
</tr>
|
583
|
-
</table>
|
584
|
-
</td>
|
585
|
-
</tr>
|
586
|
-
</table>
|
587
|
-
</td>
|
588
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>41.0%</tt>
|
589
|
-
</td>
|
590
|
-
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='41'/>
|
591
|
-
<td class='uncovered' width='59'/>
|
592
|
-
</tr>
|
593
|
-
</table>
|
594
|
-
</td>
|
595
|
-
</tr>
|
596
|
-
</table>
|
597
|
-
</td>
|
598
|
-
</tr>
|
599
|
-
</tbody>
|
600
|
-
</table>
|
601
|
-
<pre><span class="inferred1"><a name="line1"></a> 1 #! /usr/env/bin ruby
|
602
|
-
</span><span class="inferred0"><a name="line2"></a> 2 #--
|
603
|
-
</span><span class="inferred1"><a name="line3"></a> 3 # Copyright 2004 Austin Ziegler <diff-lcs@halostatue.ca>
|
604
|
-
</span><span class="inferred0"><a name="line4"></a> 4 # adapted from:
|
605
|
-
</span><span class="inferred1"><a name="line5"></a> 5 # Algorithm::Diff (Perl) by Ned Konz <perl@bike-nomad.com>
|
606
|
-
</span><span class="inferred0"><a name="line6"></a> 6 # Smalltalk by Mario I. Wolczko <mario@wolczko.com>
|
607
|
-
</span><span class="inferred1"><a name="line7"></a> 7 # implements McIlroy-Hunt diff algorithm
|
608
|
-
</span><span class="inferred0"><a name="line8"></a> 8 #
|
609
|
-
</span><span class="inferred1"><a name="line9"></a> 9 # This program is free software. It may be redistributed and/or modified under
|
610
|
-
</span><span class="inferred0"><a name="line10"></a> 10 # the terms of the GPL version 2 (or later), the Perl Artistic licence, or the
|
611
|
-
</span><span class="inferred1"><a name="line11"></a> 11 # Ruby licence.
|
612
|
-
</span><span class="inferred0"><a name="line12"></a> 12 #
|
613
|
-
</span><span class="inferred1"><a name="line13"></a> 13 # $Id: callbacks.rb,v 1.4 2004/09/14 18:51:26 austin Exp $
|
614
|
-
</span><span class="inferred0"><a name="line14"></a> 14 #++
|
615
|
-
</span><span class="inferred1"><a name="line15"></a> 15 # Contains definitions for all default callback objects.
|
616
|
-
</span><span class="inferred0"><a name="line16"></a> 16
|
617
|
-
</span><span class="marked1"><a name="line17"></a> 17 require 'diff/lcs/change'
|
618
|
-
</span><span class="inferred0"><a name="line18"></a> 18
|
619
|
-
</span><span class="marked1"><a name="line19"></a> 19 module Diff::LCS
|
620
|
-
</span><span class="inferred0"><a name="line20"></a> 20 # This callback object implements the default set of callback events, which
|
621
|
-
</span><span class="inferred1"><a name="line21"></a> 21 # only returns the event itself. Note that #finished_a and #finished_b are
|
622
|
-
</span><span class="inferred0"><a name="line22"></a> 22 # not implemented -- I haven't yet figured out where they would be useful.
|
623
|
-
</span><span class="inferred1"><a name="line23"></a> 23 #
|
624
|
-
</span><span class="inferred0"><a name="line24"></a> 24 # Note that this is intended to be called as is, e.g.,
|
625
|
-
</span><span class="inferred1"><a name="line25"></a> 25 #
|
626
|
-
</span><span class="inferred0"><a name="line26"></a> 26 # Diff::LCS.LCS(seq1, seq2, Diff::LCS::DefaultCallbacks)
|
627
|
-
</span><span class="marked1"><a name="line27"></a> 27 class DefaultCallbacks
|
628
|
-
</span><span class="marked0"><a name="line28"></a> 28 class << self
|
629
|
-
</span><span class="inferred1"><a name="line29"></a> 29 # Called when two items match.
|
630
|
-
</span><span class="marked0"><a name="line30"></a> 30 def match(event)
|
631
|
-
</span><span class="uncovered1"><a name="line31"></a> 31 event
|
632
|
-
</span><span class="uncovered0"><a name="line32"></a> 32 end
|
633
|
-
</span><span class="inferred1"><a name="line33"></a> 33 # Called when the old value is discarded in favour of the new value.
|
634
|
-
</span><span class="marked0"><a name="line34"></a> 34 def discard_a(event)
|
635
|
-
</span><span class="uncovered1"><a name="line35"></a> 35 event
|
636
|
-
</span><span class="uncovered0"><a name="line36"></a> 36 end
|
637
|
-
</span><span class="inferred1"><a name="line37"></a> 37 # Called when the new value is discarded in favour of the old value.
|
638
|
-
</span><span class="marked0"><a name="line38"></a> 38 def discard_b(event)
|
639
|
-
</span><span class="uncovered1"><a name="line39"></a> 39 event
|
640
|
-
</span><span class="uncovered0"><a name="line40"></a> 40 end
|
641
|
-
</span><span class="inferred1"><a name="line41"></a> 41 # Called when both the old and new values have changed.
|
642
|
-
</span><span class="marked0"><a name="line42"></a> 42 def change(event)
|
643
|
-
</span><span class="uncovered1"><a name="line43"></a> 43 event
|
644
|
-
</span><span class="uncovered0"><a name="line44"></a> 44 end
|
645
|
-
</span><span class="inferred1"><a name="line45"></a> 45
|
646
|
-
</span><span class="marked0"><a name="line46"></a> 46 private :new
|
647
|
-
</span><span class="inferred1"><a name="line47"></a> 47 end
|
648
|
-
</span><span class="inferred0"><a name="line48"></a> 48 end
|
649
|
-
</span><span class="inferred1"><a name="line49"></a> 49
|
650
|
-
</span><span class="inferred0"><a name="line50"></a> 50 # An alias for DefaultCallbacks that is used in Diff::LCS#traverse_sequences.
|
651
|
-
</span><span class="inferred1"><a name="line51"></a> 51 #
|
652
|
-
</span><span class="inferred0"><a name="line52"></a> 52 # Diff::LCS.LCS(seq1, seq2, Diff::LCS::SequenceCallbacks)
|
653
|
-
</span><span class="marked1"><a name="line53"></a> 53 SequenceCallbacks = DefaultCallbacks
|
654
|
-
</span><span class="inferred0"><a name="line54"></a> 54 # An alias for DefaultCallbacks that is used in Diff::LCS#traverse_balanced.
|
655
|
-
</span><span class="inferred1"><a name="line55"></a> 55 #
|
656
|
-
</span><span class="inferred0"><a name="line56"></a> 56 # Diff::LCS.LCS(seq1, seq2, Diff::LCS::BalancedCallbacks)
|
657
|
-
</span><span class="marked1"><a name="line57"></a> 57 BalancedCallbacks = DefaultCallbacks
|
658
|
-
</span><span class="inferred0"><a name="line58"></a> 58 end
|
659
|
-
</span><span class="inferred1"><a name="line59"></a> 59
|
660
|
-
</span><span class="inferred0"><a name="line60"></a> 60 # This will produce a compound array of simple diff change objects. Each
|
661
|
-
</span><span class="inferred1"><a name="line61"></a> 61 # element in the #diffs array is a +hunk+ or +hunk+ array, where each
|
662
|
-
</span><span class="inferred0"><a name="line62"></a> 62 # element in each +hunk+ array is a single Change object representing the
|
663
|
-
</span><span class="inferred1"><a name="line63"></a> 63 # addition or removal of a single element from one of the two tested
|
664
|
-
</span><span class="inferred0"><a name="line64"></a> 64 # sequences. The +hunk+ provides the full context for the changes.
|
665
|
-
</span><span class="inferred1"><a name="line65"></a> 65 #
|
666
|
-
</span><span class="inferred0"><a name="line66"></a> 66 # diffs = Diff::LCS.diff(seq1, seq2)
|
667
|
-
</span><span class="inferred1"><a name="line67"></a> 67 # # This example shows a simplified array format.
|
668
|
-
</span><span class="inferred0"><a name="line68"></a> 68 # # [ [ [ '-', 0, 'a' ] ], # 1
|
669
|
-
</span><span class="inferred1"><a name="line69"></a> 69 # # [ [ '+', 2, 'd' ] ], # 2
|
670
|
-
</span><span class="inferred0"><a name="line70"></a> 70 # # [ [ '-', 4, 'h' ], # 3
|
671
|
-
</span><span class="inferred1"><a name="line71"></a> 71 # # [ '+', 4, 'f' ] ],
|
672
|
-
</span><span class="inferred0"><a name="line72"></a> 72 # # [ [ '+', 6, 'k' ] ], # 4
|
673
|
-
</span><span class="inferred1"><a name="line73"></a> 73 # # [ [ '-', 8, 'n' ], # 5
|
674
|
-
</span><span class="inferred0"><a name="line74"></a> 74 # # [ '-', 9, 'p' ],
|
675
|
-
</span><span class="inferred1"><a name="line75"></a> 75 # # [ '+', 9, 'r' ],
|
676
|
-
</span><span class="inferred0"><a name="line76"></a> 76 # # [ '+', 10, 's' ],
|
677
|
-
</span><span class="inferred1"><a name="line77"></a> 77 # # [ '+', 11, 't' ] ] ]
|
678
|
-
</span><span class="inferred0"><a name="line78"></a> 78 #
|
679
|
-
</span><span class="inferred1"><a name="line79"></a> 79 # There are five hunks here. The first hunk says that the +a+ at position 0
|
680
|
-
</span><span class="inferred0"><a name="line80"></a> 80 # of the first sequence should be deleted (<tt>'-'</tt>). The second hunk
|
681
|
-
</span><span class="inferred1"><a name="line81"></a> 81 # says that the +d+ at position 2 of the second sequence should be inserted
|
682
|
-
</span><span class="inferred0"><a name="line82"></a> 82 # (<tt>'+'</tt>). The third hunk says that the +h+ at position 4 of the
|
683
|
-
</span><span class="inferred1"><a name="line83"></a> 83 # first sequence should be removed and replaced with the +f+ from position 4
|
684
|
-
</span><span class="inferred0"><a name="line84"></a> 84 # of the second sequence. The other two hunks are described similarly.
|
685
|
-
</span><span class="inferred1"><a name="line85"></a> 85 #
|
686
|
-
</span><span class="inferred0"><a name="line86"></a> 86 # === Use
|
687
|
-
</span><span class="inferred1"><a name="line87"></a> 87 # This callback object must be initialised and is used by the Diff::LCS#diff
|
688
|
-
</span><span class="inferred0"><a name="line88"></a> 88 # method.
|
689
|
-
</span><span class="inferred1"><a name="line89"></a> 89 #
|
690
|
-
</span><span class="inferred0"><a name="line90"></a> 90 # cbo = Diff::LCS::DiffCallbacks.new
|
691
|
-
</span><span class="inferred1"><a name="line91"></a> 91 # Diff::LCS.LCS(seq1, seq2, cbo)
|
692
|
-
</span><span class="inferred0"><a name="line92"></a> 92 # cbo.finish
|
693
|
-
</span><span class="inferred1"><a name="line93"></a> 93 #
|
694
|
-
</span><span class="inferred0"><a name="line94"></a> 94 # Note that the call to #finish is absolutely necessary, or the last set of
|
695
|
-
</span><span class="inferred1"><a name="line95"></a> 95 # changes will not be visible. Alternatively, can be used as:
|
696
|
-
</span><span class="inferred0"><a name="line96"></a> 96 #
|
697
|
-
</span><span class="inferred1"><a name="line97"></a> 97 # cbo = Diff::LCS::DiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) }
|
698
|
-
</span><span class="inferred0"><a name="line98"></a> 98 #
|
699
|
-
</span><span class="inferred1"><a name="line99"></a> 99 # The necessary #finish call will be made.
|
700
|
-
</span><span class="inferred0"><a name="line100"></a>100 #
|
701
|
-
</span><span class="inferred1"><a name="line101"></a>101 # === Simplified Array Format
|
702
|
-
</span><span class="inferred0"><a name="line102"></a>102 # The simplified array format used in the example above can be obtained
|
703
|
-
</span><span class="inferred1"><a name="line103"></a>103 # with:
|
704
|
-
</span><span class="inferred0"><a name="line104"></a>104 #
|
705
|
-
</span><span class="inferred1"><a name="line105"></a>105 # require 'pp'
|
706
|
-
</span><span class="inferred0"><a name="line106"></a>106 # pp diffs.map { |e| e.map { |f| f.to_a } }
|
707
|
-
</span><span class="marked1"><a name="line107"></a>107 class Diff::LCS::DiffCallbacks
|
708
|
-
</span><span class="inferred0"><a name="line108"></a>108 # Returns the difference set collected during the diff process.
|
709
|
-
</span><span class="marked1"><a name="line109"></a>109 attr_reader :diffs
|
710
|
-
</span><span class="inferred0"><a name="line110"></a>110
|
711
|
-
</span><span class="marked1"><a name="line111"></a>111 def initialize # :yields self:
|
712
|
-
</span><span class="uncovered0"><a name="line112"></a>112 @hunk = []
|
713
|
-
</span><span class="uncovered1"><a name="line113"></a>113 @diffs = []
|
714
|
-
</span><span class="uncovered0"><a name="line114"></a>114
|
715
|
-
</span><span class="uncovered1"><a name="line115"></a>115 if block_given?
|
716
|
-
</span><span class="uncovered0"><a name="line116"></a>116 begin
|
717
|
-
</span><span class="uncovered1"><a name="line117"></a>117 yield self
|
718
|
-
</span><span class="uncovered0"><a name="line118"></a>118 ensure
|
719
|
-
</span><span class="uncovered1"><a name="line119"></a>119 self.finish
|
720
|
-
</span><span class="uncovered0"><a name="line120"></a>120 end
|
721
|
-
</span><span class="uncovered1"><a name="line121"></a>121 end
|
722
|
-
</span><span class="uncovered0"><a name="line122"></a>122 end
|
723
|
-
</span><span class="inferred1"><a name="line123"></a>123
|
724
|
-
</span><span class="inferred0"><a name="line124"></a>124 # Finalizes the diff process. If an unprocessed hunk still exists, then it
|
725
|
-
</span><span class="inferred1"><a name="line125"></a>125 # is appended to the diff list.
|
726
|
-
</span><span class="marked0"><a name="line126"></a>126 def finish
|
727
|
-
</span><span class="uncovered1"><a name="line127"></a>127 add_nonempty_hunk
|
728
|
-
</span><span class="uncovered0"><a name="line128"></a>128 end
|
729
|
-
</span><span class="inferred1"><a name="line129"></a>129
|
730
|
-
</span><span class="marked0"><a name="line130"></a>130 def match(event)
|
731
|
-
</span><span class="uncovered1"><a name="line131"></a>131 add_nonempty_hunk
|
732
|
-
</span><span class="uncovered0"><a name="line132"></a>132 end
|
733
|
-
</span><span class="inferred1"><a name="line133"></a>133
|
734
|
-
</span><span class="marked0"><a name="line134"></a>134 def discard_a(event)
|
735
|
-
</span><span class="uncovered1"><a name="line135"></a>135 @hunk << Diff::LCS::Change.new('-', event.old_position, event.old_element)
|
736
|
-
</span><span class="uncovered0"><a name="line136"></a>136 end
|
737
|
-
</span><span class="inferred1"><a name="line137"></a>137
|
738
|
-
</span><span class="marked0"><a name="line138"></a>138 def discard_b(event)
|
739
|
-
</span><span class="uncovered1"><a name="line139"></a>139 @hunk << Diff::LCS::Change.new('+', event.new_position, event.new_element)
|
740
|
-
</span><span class="uncovered0"><a name="line140"></a>140 end
|
741
|
-
</span><span class="inferred1"><a name="line141"></a>141
|
742
|
-
</span><span class="marked0"><a name="line142"></a>142 private
|
743
|
-
</span><span class="marked1"><a name="line143"></a>143 def add_nonempty_hunk
|
744
|
-
</span><span class="uncovered0"><a name="line144"></a>144 @diffs << @hunk unless @hunk.empty?
|
745
|
-
</span><span class="uncovered1"><a name="line145"></a>145 @hunk = []
|
746
|
-
</span><span class="uncovered0"><a name="line146"></a>146 end
|
747
|
-
</span><span class="uncovered1"><a name="line147"></a>147 end
|
748
|
-
</span><span class="inferred0"><a name="line148"></a>148
|
749
|
-
</span><span class="inferred1"><a name="line149"></a>149 # This will produce a compound array of contextual diff change objects. Each
|
750
|
-
</span><span class="inferred0"><a name="line150"></a>150 # element in the #diffs array is a "hunk" array, where each element in each
|
751
|
-
</span><span class="inferred1"><a name="line151"></a>151 # "hunk" array is a single change. Each change is a Diff::LCS::ContextChange
|
752
|
-
</span><span class="inferred0"><a name="line152"></a>152 # that contains both the old index and new index values for the change. The
|
753
|
-
</span><span class="inferred1"><a name="line153"></a>153 # "hunk" provides the full context for the changes. Both old and new objects
|
754
|
-
</span><span class="inferred0"><a name="line154"></a>154 # will be presented for changed objects. +nil+ will be substituted for a
|
755
|
-
</span><span class="inferred1"><a name="line155"></a>155 # discarded object.
|
756
|
-
</span><span class="inferred0"><a name="line156"></a>156 #
|
757
|
-
</span><span class="inferred1"><a name="line157"></a>157 # seq1 = %w(a b c e h j l m n p)
|
758
|
-
</span><span class="inferred0"><a name="line158"></a>158 # seq2 = %w(b c d e f j k l m r s t)
|
759
|
-
</span><span class="inferred1"><a name="line159"></a>159 #
|
760
|
-
</span><span class="inferred0"><a name="line160"></a>160 # diffs = Diff::LCS.diff(seq1, seq2, Diff::LCS::ContextDiffCallbacks)
|
761
|
-
</span><span class="inferred1"><a name="line161"></a>161 # # This example shows a simplified array format.
|
762
|
-
</span><span class="inferred0"><a name="line162"></a>162 # # [ [ [ '-', [ 0, 'a' ], [ 0, nil ] ] ], # 1
|
763
|
-
</span><span class="inferred1"><a name="line163"></a>163 # # [ [ '+', [ 3, nil ], [ 2, 'd' ] ] ], # 2
|
764
|
-
</span><span class="inferred0"><a name="line164"></a>164 # # [ [ '-', [ 4, 'h' ], [ 4, nil ] ], # 3
|
765
|
-
</span><span class="inferred1"><a name="line165"></a>165 # # [ '+', [ 5, nil ], [ 4, 'f' ] ] ],
|
766
|
-
</span><span class="inferred0"><a name="line166"></a>166 # # [ [ '+', [ 6, nil ], [ 6, 'k' ] ] ], # 4
|
767
|
-
</span><span class="inferred1"><a name="line167"></a>167 # # [ [ '-', [ 8, 'n' ], [ 9, nil ] ], # 5
|
768
|
-
</span><span class="inferred0"><a name="line168"></a>168 # # [ '+', [ 9, nil ], [ 9, 'r' ] ],
|
769
|
-
</span><span class="inferred1"><a name="line169"></a>169 # # [ '-', [ 9, 'p' ], [ 10, nil ] ],
|
770
|
-
</span><span class="inferred0"><a name="line170"></a>170 # # [ '+', [ 10, nil ], [ 10, 's' ] ],
|
771
|
-
</span><span class="inferred1"><a name="line171"></a>171 # # [ '+', [ 10, nil ], [ 11, 't' ] ] ] ]
|
772
|
-
</span><span class="inferred0"><a name="line172"></a>172 #
|
773
|
-
</span><span class="inferred1"><a name="line173"></a>173 # The five hunks shown are comprised of individual changes; if there is a
|
774
|
-
</span><span class="inferred0"><a name="line174"></a>174 # related set of changes, they are still shown individually.
|
775
|
-
</span><span class="inferred1"><a name="line175"></a>175 #
|
776
|
-
</span><span class="inferred0"><a name="line176"></a>176 # This callback can also be used with Diff::LCS#sdiff, which will produce
|
777
|
-
</span><span class="inferred1"><a name="line177"></a>177 # results like:
|
778
|
-
</span><span class="inferred0"><a name="line178"></a>178 #
|
779
|
-
</span><span class="inferred1"><a name="line179"></a>179 # diffs = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextCallbacks)
|
780
|
-
</span><span class="inferred0"><a name="line180"></a>180 # # This example shows a simplified array format.
|
781
|
-
</span><span class="inferred1"><a name="line181"></a>181 # # [ [ [ "-", [ 0, "a" ], [ 0, nil ] ] ], # 1
|
782
|
-
</span><span class="inferred0"><a name="line182"></a>182 # # [ [ "+", [ 3, nil ], [ 2, "d" ] ] ], # 2
|
783
|
-
</span><span class="inferred1"><a name="line183"></a>183 # # [ [ "!", [ 4, "h" ], [ 4, "f" ] ] ], # 3
|
784
|
-
</span><span class="inferred0"><a name="line184"></a>184 # # [ [ "+", [ 6, nil ], [ 6, "k" ] ] ], # 4
|
785
|
-
</span><span class="inferred1"><a name="line185"></a>185 # # [ [ "!", [ 8, "n" ], [ 9, "r" ] ], # 5
|
786
|
-
</span><span class="inferred0"><a name="line186"></a>186 # # [ "!", [ 9, "p" ], [ 10, "s" ] ],
|
787
|
-
</span><span class="inferred1"><a name="line187"></a>187 # # [ "+", [ 10, nil ], [ 11, "t" ] ] ] ]
|
788
|
-
</span><span class="inferred0"><a name="line188"></a>188 #
|
789
|
-
</span><span class="inferred1"><a name="line189"></a>189 # The five hunks are still present, but are significantly shorter in total
|
790
|
-
</span><span class="inferred0"><a name="line190"></a>190 # presentation, because changed items are shown as changes ("!") instead of
|
791
|
-
</span><span class="inferred1"><a name="line191"></a>191 # potentially "mismatched" pairs of additions and deletions.
|
792
|
-
</span><span class="inferred0"><a name="line192"></a>192 #
|
793
|
-
</span><span class="inferred1"><a name="line193"></a>193 # The result of this operation is similar to that of
|
794
|
-
</span><span class="inferred0"><a name="line194"></a>194 # Diff::LCS::SDiffCallbacks. They may be compared as:
|
795
|
-
</span><span class="inferred1"><a name="line195"></a>195 #
|
796
|
-
</span><span class="inferred0"><a name="line196"></a>196 # s = Diff::LCS.sdiff(seq1, seq2).reject { |e| e.action == "=" }
|
797
|
-
</span><span class="inferred1"><a name="line197"></a>197 # c = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextDiffCallbacks).flatten
|
798
|
-
</span><span class="inferred0"><a name="line198"></a>198 #
|
799
|
-
</span><span class="inferred1"><a name="line199"></a>199 # s == c # -> true
|
800
|
-
</span><span class="inferred0"><a name="line200"></a>200 #
|
801
|
-
</span><span class="inferred1"><a name="line201"></a>201 # === Use
|
802
|
-
</span><span class="inferred0"><a name="line202"></a>202 # This callback object must be initialised and can be used by the
|
803
|
-
</span><span class="inferred1"><a name="line203"></a>203 # Diff::LCS#diff or Diff::LCS#sdiff methods.
|
804
|
-
</span><span class="inferred0"><a name="line204"></a>204 #
|
805
|
-
</span><span class="inferred1"><a name="line205"></a>205 # cbo = Diff::LCS::ContextDiffCallbacks.new
|
806
|
-
</span><span class="inferred0"><a name="line206"></a>206 # Diff::LCS.LCS(seq1, seq2, cbo)
|
807
|
-
</span><span class="inferred1"><a name="line207"></a>207 # cbo.finish
|
808
|
-
</span><span class="inferred0"><a name="line208"></a>208 #
|
809
|
-
</span><span class="inferred1"><a name="line209"></a>209 # Note that the call to #finish is absolutely necessary, or the last set of
|
810
|
-
</span><span class="inferred0"><a name="line210"></a>210 # changes will not be visible. Alternatively, can be used as:
|
811
|
-
</span><span class="inferred1"><a name="line211"></a>211 #
|
812
|
-
</span><span class="inferred0"><a name="line212"></a>212 # cbo = Diff::LCS::ContextDiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) }
|
813
|
-
</span><span class="inferred1"><a name="line213"></a>213 #
|
814
|
-
</span><span class="inferred0"><a name="line214"></a>214 # The necessary #finish call will be made.
|
815
|
-
</span><span class="inferred1"><a name="line215"></a>215 #
|
816
|
-
</span><span class="inferred0"><a name="line216"></a>216 # === Simplified Array Format
|
817
|
-
</span><span class="inferred1"><a name="line217"></a>217 # The simplified array format used in the example above can be obtained
|
818
|
-
</span><span class="inferred0"><a name="line218"></a>218 # with:
|
819
|
-
</span><span class="inferred1"><a name="line219"></a>219 #
|
820
|
-
</span><span class="inferred0"><a name="line220"></a>220 # require 'pp'
|
821
|
-
</span><span class="inferred1"><a name="line221"></a>221 # pp diffs.map { |e| e.map { |f| f.to_a } }
|
822
|
-
</span><span class="marked0"><a name="line222"></a>222 class Diff::LCS::ContextDiffCallbacks < Diff::LCS::DiffCallbacks
|
823
|
-
</span><span class="marked1"><a name="line223"></a>223 def discard_a(event)
|
824
|
-
</span><span class="uncovered0"><a name="line224"></a>224 @hunk << Diff::LCS::ContextChange.simplify(event)
|
825
|
-
</span><span class="uncovered1"><a name="line225"></a>225 end
|
826
|
-
</span><span class="inferred0"><a name="line226"></a>226
|
827
|
-
</span><span class="marked1"><a name="line227"></a>227 def discard_b(event)
|
828
|
-
</span><span class="uncovered0"><a name="line228"></a>228 @hunk << Diff::LCS::ContextChange.simplify(event)
|
829
|
-
</span><span class="uncovered1"><a name="line229"></a>229 end
|
830
|
-
</span><span class="inferred0"><a name="line230"></a>230
|
831
|
-
</span><span class="marked1"><a name="line231"></a>231 def change(event)
|
832
|
-
</span><span class="uncovered0"><a name="line232"></a>232 @hunk << Diff::LCS::ContextChange.simplify(event)
|
833
|
-
</span><span class="uncovered1"><a name="line233"></a>233 end
|
834
|
-
</span><span class="uncovered0"><a name="line234"></a>234 end
|
835
|
-
</span><span class="inferred1"><a name="line235"></a>235
|
836
|
-
</span><span class="inferred0"><a name="line236"></a>236 # This will produce a simple array of diff change objects. Each element in
|
837
|
-
</span><span class="inferred1"><a name="line237"></a>237 # the #diffs array is a single ContextChange. In the set of #diffs provided
|
838
|
-
</span><span class="inferred0"><a name="line238"></a>238 # by SDiffCallbacks, both old and new objects will be presented for both
|
839
|
-
</span><span class="inferred1"><a name="line239"></a>239 # changed <strong>and unchanged</strong> objects. +nil+ will be substituted
|
840
|
-
</span><span class="inferred0"><a name="line240"></a>240 # for a discarded object.
|
841
|
-
</span><span class="inferred1"><a name="line241"></a>241 #
|
842
|
-
</span><span class="inferred0"><a name="line242"></a>242 # The diffset produced by this callback, when provided to Diff::LCS#sdiff,
|
843
|
-
</span><span class="inferred1"><a name="line243"></a>243 # will compute and display the necessary components to show two sequences
|
844
|
-
</span><span class="inferred0"><a name="line244"></a>244 # and their minimized differences side by side, just like the Unix utility
|
845
|
-
</span><span class="inferred1"><a name="line245"></a>245 # +sdiff+.
|
846
|
-
</span><span class="inferred0"><a name="line246"></a>246 #
|
847
|
-
</span><span class="inferred1"><a name="line247"></a>247 # same same
|
848
|
-
</span><span class="inferred0"><a name="line248"></a>248 # before | after
|
849
|
-
</span><span class="inferred1"><a name="line249"></a>249 # old < -
|
850
|
-
</span><span class="inferred0"><a name="line250"></a>250 # - > new
|
851
|
-
</span><span class="inferred1"><a name="line251"></a>251 #
|
852
|
-
</span><span class="inferred0"><a name="line252"></a>252 # seq1 = %w(a b c e h j l m n p)
|
853
|
-
</span><span class="inferred1"><a name="line253"></a>253 # seq2 = %w(b c d e f j k l m r s t)
|
854
|
-
</span><span class="inferred0"><a name="line254"></a>254 #
|
855
|
-
</span><span class="inferred1"><a name="line255"></a>255 # diffs = Diff::LCS.sdiff(seq1, seq2)
|
856
|
-
</span><span class="inferred0"><a name="line256"></a>256 # # This example shows a simplified array format.
|
857
|
-
</span><span class="inferred1"><a name="line257"></a>257 # # [ [ "-", [ 0, "a"], [ 0, nil ] ],
|
858
|
-
</span><span class="inferred0"><a name="line258"></a>258 # # [ "=", [ 1, "b"], [ 0, "b" ] ],
|
859
|
-
</span><span class="inferred1"><a name="line259"></a>259 # # [ "=", [ 2, "c"], [ 1, "c" ] ],
|
860
|
-
</span><span class="inferred0"><a name="line260"></a>260 # # [ "+", [ 3, nil], [ 2, "d" ] ],
|
861
|
-
</span><span class="inferred1"><a name="line261"></a>261 # # [ "=", [ 3, "e"], [ 3, "e" ] ],
|
862
|
-
</span><span class="inferred0"><a name="line262"></a>262 # # [ "!", [ 4, "h"], [ 4, "f" ] ],
|
863
|
-
</span><span class="inferred1"><a name="line263"></a>263 # # [ "=", [ 5, "j"], [ 5, "j" ] ],
|
864
|
-
</span><span class="inferred0"><a name="line264"></a>264 # # [ "+", [ 6, nil], [ 6, "k" ] ],
|
865
|
-
</span><span class="inferred1"><a name="line265"></a>265 # # [ "=", [ 6, "l"], [ 7, "l" ] ],
|
866
|
-
</span><span class="inferred0"><a name="line266"></a>266 # # [ "=", [ 7, "m"], [ 8, "m" ] ],
|
867
|
-
</span><span class="inferred1"><a name="line267"></a>267 # # [ "!", [ 8, "n"], [ 9, "r" ] ],
|
868
|
-
</span><span class="inferred0"><a name="line268"></a>268 # # [ "!", [ 9, "p"], [ 10, "s" ] ],
|
869
|
-
</span><span class="inferred1"><a name="line269"></a>269 # # [ "+", [ 10, nil], [ 11, "t" ] ] ]
|
870
|
-
</span><span class="inferred0"><a name="line270"></a>270 #
|
871
|
-
</span><span class="inferred1"><a name="line271"></a>271 # The result of this operation is similar to that of
|
872
|
-
</span><span class="inferred0"><a name="line272"></a>272 # Diff::LCS::ContextDiffCallbacks. They may be compared as:
|
873
|
-
</span><span class="inferred1"><a name="line273"></a>273 #
|
874
|
-
</span><span class="inferred0"><a name="line274"></a>274 # s = Diff::LCS.sdiff(seq1, seq2).reject { |e| e.action == "=" }
|
875
|
-
</span><span class="inferred1"><a name="line275"></a>275 # c = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextDiffCallbacks).flatten
|
876
|
-
</span><span class="inferred0"><a name="line276"></a>276 #
|
877
|
-
</span><span class="inferred1"><a name="line277"></a>277 # s == c # -> true
|
878
|
-
</span><span class="inferred0"><a name="line278"></a>278 #
|
879
|
-
</span><span class="inferred1"><a name="line279"></a>279 # === Use
|
880
|
-
</span><span class="inferred0"><a name="line280"></a>280 # This callback object must be initialised and is used by the Diff::LCS#sdiff
|
881
|
-
</span><span class="inferred1"><a name="line281"></a>281 # method.
|
882
|
-
</span><span class="inferred0"><a name="line282"></a>282 #
|
883
|
-
</span><span class="inferred1"><a name="line283"></a>283 # cbo = Diff::LCS::SDiffCallbacks.new
|
884
|
-
</span><span class="inferred0"><a name="line284"></a>284 # Diff::LCS.LCS(seq1, seq2, cbo)
|
885
|
-
</span><span class="inferred1"><a name="line285"></a>285 #
|
886
|
-
</span><span class="inferred0"><a name="line286"></a>286 # As with the other initialisable callback objects, Diff::LCS::SDiffCallbacks
|
887
|
-
</span><span class="inferred1"><a name="line287"></a>287 # can be initialised with a block. As there is no "fininishing" to be done,
|
888
|
-
</span><span class="inferred0"><a name="line288"></a>288 # this has no effect on the state of the object.
|
889
|
-
</span><span class="inferred1"><a name="line289"></a>289 #
|
890
|
-
</span><span class="inferred0"><a name="line290"></a>290 # cbo = Diff::LCS::SDiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) }
|
891
|
-
</span><span class="inferred1"><a name="line291"></a>291 #
|
892
|
-
</span><span class="inferred0"><a name="line292"></a>292 # === Simplified Array Format
|
893
|
-
</span><span class="inferred1"><a name="line293"></a>293 # The simplified array format used in the example above can be obtained
|
894
|
-
</span><span class="inferred0"><a name="line294"></a>294 # with:
|
895
|
-
</span><span class="inferred1"><a name="line295"></a>295 #
|
896
|
-
</span><span class="inferred0"><a name="line296"></a>296 # require 'pp'
|
897
|
-
</span><span class="inferred1"><a name="line297"></a>297 # pp diffs.map { |e| e.to_a }
|
898
|
-
</span><span class="marked0"><a name="line298"></a>298 class Diff::LCS::SDiffCallbacks
|
899
|
-
</span><span class="inferred1"><a name="line299"></a>299 # Returns the difference set collected during the diff process.
|
900
|
-
</span><span class="marked0"><a name="line300"></a>300 attr_reader :diffs
|
901
|
-
</span><span class="inferred1"><a name="line301"></a>301
|
902
|
-
</span><span class="marked0"><a name="line302"></a>302 def initialize #:yields self:
|
903
|
-
</span><span class="uncovered1"><a name="line303"></a>303 @diffs = []
|
904
|
-
</span><span class="uncovered0"><a name="line304"></a>304 yield self if block_given?
|
905
|
-
</span><span class="uncovered1"><a name="line305"></a>305 end
|
906
|
-
</span><span class="inferred0"><a name="line306"></a>306
|
907
|
-
</span><span class="marked1"><a name="line307"></a>307 def match(event)
|
908
|
-
</span><span class="uncovered0"><a name="line308"></a>308 @diffs << Diff::LCS::ContextChange.simplify(event)
|
909
|
-
</span><span class="uncovered1"><a name="line309"></a>309 end
|
910
|
-
</span><span class="inferred0"><a name="line310"></a>310
|
911
|
-
</span><span class="marked1"><a name="line311"></a>311 def discard_a(event)
|
912
|
-
</span><span class="uncovered0"><a name="line312"></a>312 @diffs << Diff::LCS::ContextChange.simplify(event)
|
913
|
-
</span><span class="uncovered1"><a name="line313"></a>313 end
|
914
|
-
</span><span class="inferred0"><a name="line314"></a>314
|
915
|
-
</span><span class="marked1"><a name="line315"></a>315 def discard_b(event)
|
916
|
-
</span><span class="uncovered0"><a name="line316"></a>316 @diffs << Diff::LCS::ContextChange.simplify(event)
|
917
|
-
</span><span class="uncovered1"><a name="line317"></a>317 end
|
918
|
-
</span><span class="inferred0"><a name="line318"></a>318
|
919
|
-
</span><span class="marked1"><a name="line319"></a>319 def change(event)
|
920
|
-
</span><span class="uncovered0"><a name="line320"></a>320 @diffs << Diff::LCS::ContextChange.simplify(event)
|
921
|
-
</span><span class="uncovered1"><a name="line321"></a>321 end
|
922
|
-
</span><span class="uncovered0"><a name="line322"></a>322 end
|
923
|
-
</span></pre><hr/>
|
924
|
-
<p>Generated using the <a href='http://eigenclass.org/hiki.rb?rcov'>rcov code coverage analysis tool for Ruby</a>
|
925
|
-
version 0.8.1.2.</p>
|
926
|
-
<p><a href='http://validator.w3.org/check/referer'><img src='http://www.w3.org/Icons/valid-xhtml10' height='31' alt='Valid XHTML 1.0!' width='88'/>
|
927
|
-
</a>
|
928
|
-
<a href='http://jigsaw.w3.org/css-validator/check/referer'><img src='http://jigsaw.w3.org/css-validator/images/vcss' alt='Valid CSS!' style='border:0;width:88px;height:31px'/>
|
929
|
-
</a>
|
930
|
-
</p>
|
931
|
-
</body>
|
932
|
-
</html>
|