activegroonga 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/README.textile +55 -0
  2. data/Rakefile +45 -165
  3. data/{license/LGPL → doc/text/lgpl.txt} +0 -0
  4. data/doc/text/news.textile +60 -0
  5. data/doc/text/tutorial.textile +3 -0
  6. data/lib/active_groonga/base.rb +50 -2
  7. data/lib/active_groonga/railtie.rb +6 -5
  8. data/lib/active_groonga/railties/groonga.rake +8 -4
  9. data/lib/active_groonga/result_set.rb +133 -8
  10. data/lib/active_groonga/version.rb +1 -1
  11. data/test/active-groonga-test-utils.rb +6 -0
  12. data/test/run-test.rb +11 -24
  13. data/test/test-base.rb +10 -4
  14. data/test/test-result-set.rb +121 -9
  15. metadata +90 -138
  16. data/AUTHORS +0 -1
  17. data/NEWS.ja.rdoc +0 -46
  18. data/NEWS.rdoc +0 -46
  19. data/README.ja.rdoc +0 -52
  20. data/README.rdoc +0 -52
  21. data/test-unit-notify/Rakefile +0 -47
  22. data/test-unit-notify/lib/test/unit/notify.rb +0 -104
  23. data/test-unit/COPYING +0 -56
  24. data/test-unit/GPL +0 -340
  25. data/test-unit/PSFL +0 -271
  26. data/test-unit/Rakefile +0 -53
  27. data/test-unit/TODO +0 -5
  28. data/test-unit/bin/testrb +0 -5
  29. data/test-unit/html/bar.svg +0 -153
  30. data/test-unit/html/developer.svg +0 -469
  31. data/test-unit/html/favicon.ico +0 -0
  32. data/test-unit/html/favicon.svg +0 -82
  33. data/test-unit/html/heading-mark.svg +0 -393
  34. data/test-unit/html/index.html +0 -247
  35. data/test-unit/html/index.html.ja +0 -270
  36. data/test-unit/html/install.svg +0 -636
  37. data/test-unit/html/logo.svg +0 -483
  38. data/test-unit/html/test-unit.css +0 -339
  39. data/test-unit/html/tutorial.svg +0 -559
  40. data/test-unit/lib/test/unit.rb +0 -328
  41. data/test-unit/lib/test/unit/assertionfailederror.rb +0 -25
  42. data/test-unit/lib/test/unit/assertions.rb +0 -1334
  43. data/test-unit/lib/test/unit/attribute.rb +0 -125
  44. data/test-unit/lib/test/unit/autorunner.rb +0 -363
  45. data/test-unit/lib/test/unit/collector.rb +0 -36
  46. data/test-unit/lib/test/unit/collector/descendant.rb +0 -23
  47. data/test-unit/lib/test/unit/collector/dir.rb +0 -108
  48. data/test-unit/lib/test/unit/collector/load.rb +0 -144
  49. data/test-unit/lib/test/unit/collector/objectspace.rb +0 -34
  50. data/test-unit/lib/test/unit/color-scheme.rb +0 -106
  51. data/test-unit/lib/test/unit/color.rb +0 -96
  52. data/test-unit/lib/test/unit/diff.rb +0 -740
  53. data/test-unit/lib/test/unit/error.rb +0 -130
  54. data/test-unit/lib/test/unit/exceptionhandler.rb +0 -39
  55. data/test-unit/lib/test/unit/failure.rb +0 -136
  56. data/test-unit/lib/test/unit/fixture.rb +0 -176
  57. data/test-unit/lib/test/unit/notification.rb +0 -129
  58. data/test-unit/lib/test/unit/omission.rb +0 -191
  59. data/test-unit/lib/test/unit/pending.rb +0 -150
  60. data/test-unit/lib/test/unit/priority.rb +0 -180
  61. data/test-unit/lib/test/unit/runner/console.rb +0 -52
  62. data/test-unit/lib/test/unit/runner/emacs.rb +0 -8
  63. data/test-unit/lib/test/unit/runner/tap.rb +0 -8
  64. data/test-unit/lib/test/unit/testcase.rb +0 -483
  65. data/test-unit/lib/test/unit/testresult.rb +0 -121
  66. data/test-unit/lib/test/unit/testsuite.rb +0 -110
  67. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +0 -14
  68. data/test-unit/lib/test/unit/ui/console/testrunner.rb +0 -430
  69. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +0 -63
  70. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +0 -82
  71. data/test-unit/lib/test/unit/ui/testrunner.rb +0 -53
  72. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +0 -77
  73. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +0 -41
  74. data/test-unit/lib/test/unit/util/backtracefilter.rb +0 -42
  75. data/test-unit/lib/test/unit/util/method-owner-finder.rb +0 -28
  76. data/test-unit/lib/test/unit/util/observable.rb +0 -90
  77. data/test-unit/lib/test/unit/util/output.rb +0 -31
  78. data/test-unit/lib/test/unit/util/procwrapper.rb +0 -48
  79. data/test-unit/lib/test/unit/version.rb +0 -7
  80. data/test-unit/sample/adder.rb +0 -13
  81. data/test-unit/sample/subtracter.rb +0 -12
  82. data/test-unit/sample/test_adder.rb +0 -20
  83. data/test-unit/sample/test_subtracter.rb +0 -20
  84. data/test-unit/sample/test_user.rb +0 -23
  85. data/test-unit/test/collector/test-descendant.rb +0 -133
  86. data/test-unit/test/collector/test-load.rb +0 -442
  87. data/test-unit/test/collector/test_dir.rb +0 -406
  88. data/test-unit/test/collector/test_objectspace.rb +0 -100
  89. data/test-unit/test/run-test.rb +0 -15
  90. data/test-unit/test/test-attribute.rb +0 -86
  91. data/test-unit/test/test-color-scheme.rb +0 -69
  92. data/test-unit/test/test-color.rb +0 -47
  93. data/test-unit/test/test-diff.rb +0 -518
  94. data/test-unit/test/test-emacs-runner.rb +0 -60
  95. data/test-unit/test/test-fixture.rb +0 -287
  96. data/test-unit/test/test-notification.rb +0 -33
  97. data/test-unit/test/test-omission.rb +0 -81
  98. data/test-unit/test/test-pending.rb +0 -70
  99. data/test-unit/test/test-priority.rb +0 -119
  100. data/test-unit/test/test-testcase.rb +0 -544
  101. data/test-unit/test/test_assertions.rb +0 -1197
  102. data/test-unit/test/test_error.rb +0 -26
  103. data/test-unit/test/test_failure.rb +0 -33
  104. data/test-unit/test/test_testresult.rb +0 -113
  105. data/test-unit/test/test_testsuite.rb +0 -129
  106. data/test-unit/test/testunit-test-util.rb +0 -14
  107. data/test-unit/test/ui/test_tap.rb +0 -33
  108. data/test-unit/test/ui/test_testrunmediator.rb +0 -20
  109. data/test-unit/test/util/test-method-owner-finder.rb +0 -38
  110. data/test-unit/test/util/test-output.rb +0 -11
  111. data/test-unit/test/util/test_backtracefilter.rb +0 -41
  112. data/test-unit/test/util/test_observable.rb +0 -102
  113. data/test-unit/test/util/test_procwrapper.rb +0 -36
@@ -1,121 +0,0 @@
1
- #--
2
- # Author:: Nathaniel Talbott.
3
- # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
4
- # License:: Ruby license.
5
-
6
- require 'test/unit/util/observable'
7
- require 'test/unit/failure'
8
- require 'test/unit/error'
9
- require 'test/unit/omission'
10
- require 'test/unit/pending'
11
- require 'test/unit/notification'
12
-
13
- module Test
14
- module Unit
15
- module NullResultContainerInitializer
16
- private
17
- def initialize_containers
18
- end
19
- end
20
-
21
- # Collects Test::Unit::Failure and Test::Unit::Error so that
22
- # they can be displayed to the user. To this end, observers
23
- # can be added to it, allowing the dynamic updating of, say, a
24
- # UI.
25
- class TestResult
26
- include Util::Observable
27
- include NullResultContainerInitializer
28
- include TestResultFailureSupport
29
- include TestResultErrorSupport
30
- include TestResultPendingSupport
31
- include TestResultOmissionSupport
32
- include TestResultNotificationSupport
33
-
34
- CHANGED = "CHANGED"
35
- FAULT = "FAULT"
36
-
37
- attr_reader :run_count, :pass_count, :assertion_count, :faults
38
-
39
- # Constructs a new, empty TestResult.
40
- def initialize
41
- @run_count, @pass_count, @assertion_count = 0, 0, 0
42
- @summary_generators = []
43
- @problem_checkers = []
44
- @faults = []
45
- initialize_containers
46
- end
47
-
48
- # Records a test run.
49
- def add_run
50
- @run_count += 1
51
- notify_changed
52
- end
53
-
54
- def add_pass
55
- @pass_count += 1
56
- end
57
-
58
- # Records an individual assertion.
59
- def add_assertion
60
- @assertion_count += 1
61
- notify_changed
62
- end
63
-
64
- # Returns a string contain the recorded runs, assertions,
65
- # failures and errors in this TestResult.
66
- def summary
67
- ["#{run_count} tests",
68
- "#{assertion_count} assertions",
69
- *@summary_generators.collect {|generator| send(generator)}].join(", ")
70
- end
71
-
72
- # Returnes a string that shows result status.
73
- def status
74
- if passed?
75
- if pending_count > 0
76
- "pending"
77
- elsif omission_count > 0
78
- "omission"
79
- elsif notification_count > 0
80
- "notification"
81
- else
82
- "pass"
83
- end
84
- elsif error_count > 0
85
- "error"
86
- elsif failure_count > 0
87
- "failure"
88
- end
89
- end
90
-
91
- def to_s
92
- summary
93
- end
94
-
95
- # Returns whether or not this TestResult represents
96
- # successful completion.
97
- def passed?
98
- @problem_checkers.all? {|checker| not send(checker)}
99
- end
100
-
101
- def pass_percentage
102
- n_tests = @run_count - omission_count
103
- if n_tests.zero?
104
- 0
105
- else
106
- 100.0 * (@pass_count / n_tests.to_f)
107
- end
108
- end
109
-
110
- private
111
- def notify_changed
112
- notify_listeners(CHANGED, self)
113
- end
114
-
115
- def notify_fault(fault)
116
- @faults << fault
117
- notify_listeners(FAULT, fault)
118
- end
119
- end
120
- end
121
- end
@@ -1,110 +0,0 @@
1
- #--
2
- #
3
- # Author:: Nathaniel Talbott.
4
- # Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
5
- # License:: Ruby license.
6
-
7
- require 'test/unit/error'
8
-
9
- module Test
10
- module Unit
11
-
12
- # A collection of tests which can be #run.
13
- #
14
- # Note: It is easy to confuse a TestSuite instance with
15
- # something that has a static suite method; I know because _I_
16
- # have trouble keeping them straight. Think of something that
17
- # has a suite method as simply providing a way to get a
18
- # meaningful TestSuite instance.
19
- class TestSuite
20
- attr_reader :name, :tests
21
-
22
- STARTED = name + "::STARTED"
23
- FINISHED = name + "::FINISHED"
24
-
25
- # Creates a new TestSuite with the given name.
26
- def initialize(name="Unnamed TestSuite", test_case=nil)
27
- @name = name
28
- @tests = []
29
- @test_case = test_case
30
- end
31
-
32
- # Runs the tests and/or suites contained in this
33
- # TestSuite.
34
- def run(result, &progress_block)
35
- yield(STARTED, name)
36
- run_startup(result)
37
- @tests.each do |test|
38
- test.run(result, &progress_block)
39
- end
40
- run_shutdown(result)
41
- yield(FINISHED, name)
42
- end
43
-
44
- # Adds the test to the suite.
45
- def <<(test)
46
- @tests << test
47
- self
48
- end
49
-
50
- def delete(test)
51
- @tests.delete(test)
52
- end
53
-
54
- # Retuns the rolled up number of tests in this suite;
55
- # i.e. if the suite contains other suites, it counts the
56
- # tests within those suites, not the suites themselves.
57
- def size
58
- total_size = 0
59
- @tests.each { |test| total_size += test.size }
60
- total_size
61
- end
62
-
63
- def empty?
64
- tests.empty?
65
- end
66
-
67
- # Overridden to return the name given the suite at
68
- # creation.
69
- def to_s
70
- @name
71
- end
72
-
73
- # It's handy to be able to compare TestSuite instances.
74
- def ==(other)
75
- return false unless(other.kind_of?(self.class))
76
- return false unless(@name == other.name)
77
- @tests == other.tests
78
- end
79
-
80
- private
81
- def run_startup(result)
82
- return if @test_case.nil? or !@test_case.respond_to?(:startup)
83
- begin
84
- @test_case.startup
85
- rescue Exception
86
- raise unless handle_exception($!, result)
87
- end
88
- end
89
-
90
- def run_shutdown(result)
91
- return if @test_case.nil? or !@test_case.respond_to?(:shutdown)
92
- begin
93
- @test_case.shutdown
94
- rescue Exception
95
- raise unless handle_exception($!, result)
96
- end
97
- end
98
-
99
- def handle_exception(exception, result)
100
- case exception
101
- when *ErrorHandler::PASS_THROUGH_EXCEPTIONS
102
- false
103
- else
104
- result.add_error(Error.new(@test_case.name, exception))
105
- true
106
- end
107
- end
108
- end
109
- end
110
- end
@@ -1,14 +0,0 @@
1
- module Test
2
- module Unit
3
- module UI
4
- module Console
5
- module OutputLevel
6
- SILENT = 0
7
- PROGRESS_ONLY = 1
8
- NORMAL = 2
9
- VERBOSE = 3
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,430 +0,0 @@
1
- #--
2
- #
3
- # Author:: Nathaniel Talbott.
4
- # Copyright::
5
- # * Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
6
- # * Copyright (c) 2008-2009 Kouhei Sutou <kou@clear-code.com>
7
- # License:: Ruby license.
8
-
9
- require 'test/unit/color-scheme'
10
- require 'test/unit/ui/testrunner'
11
- require 'test/unit/ui/testrunnermediator'
12
- require 'test/unit/ui/console/outputlevel'
13
-
14
- module Test
15
- module Unit
16
- module UI
17
- module Console
18
-
19
- # Runs a Test::Unit::TestSuite on the console.
20
- class TestRunner < UI::TestRunner
21
- include OutputLevel
22
-
23
- # Creates a new TestRunner for running the passed
24
- # suite. If quiet_mode is true, the output while
25
- # running is limited to progress dots, errors and
26
- # failures, and the final result. io specifies
27
- # where runner output should go to; defaults to
28
- # STDOUT.
29
- def initialize(suite, options={})
30
- super
31
- @output_level = @options[:output_level] || NORMAL
32
- @output = @options[:output] || STDOUT
33
- @use_color = @options[:use_color]
34
- @use_color = guess_color_availability if @use_color.nil?
35
- @color_scheme = @options[:color_scheme] || ColorScheme.default
36
- @reset_color = Color.new("reset")
37
- @progress_row = 0
38
- @progress_row_max = @options[:progress_row_max]
39
- @progress_row_max ||= guess_progress_row_max
40
- @already_outputted = false
41
- @indent = 0
42
- @top_level = true
43
- @faults = []
44
- end
45
-
46
- private
47
- def setup_mediator
48
- super
49
- output_setup_end
50
- end
51
-
52
- def output_setup_end
53
- suite_name = @suite.to_s
54
- suite_name = @suite.name if @suite.kind_of?(Module)
55
- output("Loaded suite #{suite_name}")
56
- end
57
-
58
- def attach_to_mediator
59
- @mediator.add_listener(TestResult::FAULT, &method(:add_fault))
60
- @mediator.add_listener(TestRunnerMediator::STARTED, &method(:started))
61
- @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
62
- @mediator.add_listener(TestCase::STARTED, &method(:test_started))
63
- @mediator.add_listener(TestCase::FINISHED, &method(:test_finished))
64
- @mediator.add_listener(TestSuite::STARTED, &method(:test_suite_started))
65
- @mediator.add_listener(TestSuite::FINISHED, &method(:test_suite_finished))
66
- end
67
-
68
- def add_fault(fault)
69
- @faults << fault
70
- output_progress(fault.single_character_display, fault_color(fault))
71
- @already_outputted = true if fault.critical?
72
- end
73
-
74
- def started(result)
75
- @result = result
76
- output_started
77
- end
78
-
79
- def output_started
80
- output("Started")
81
- end
82
-
83
- def finished(elapsed_time)
84
- nl if output?(NORMAL) and !output?(VERBOSE)
85
- @faults.each_with_index do |fault, index|
86
- nl
87
- output_single("%3d) " % (index + 1))
88
- output_fault(fault)
89
- end
90
- nl
91
- output("Finished in #{elapsed_time} seconds.")
92
- nl
93
- output(@result, result_color)
94
- output("%g%% passed" % @result.pass_percentage, result_color)
95
- end
96
-
97
- def output_fault(fault)
98
- if @use_color and fault.is_a?(Failure) and
99
- fault.inspected_expected and fault.inspected_actual
100
- output_single(fault.label, fault_color(fault))
101
- output(":")
102
- output_fault_backtrace(fault)
103
- output_fault_message(fault)
104
- else
105
- label, detail = format_fault(fault).split(/\r?\n/, 2)
106
- output(label, fault_color(fault))
107
- output(detail)
108
- end
109
- end
110
-
111
- def output_fault_backtrace(fault)
112
- backtrace = fault.location
113
- if backtrace.size == 1
114
- output(fault.test_name +
115
- backtrace[0].sub(/\A(.+:\d+).*/, ' [\\1]') +
116
- ":")
117
- else
118
- output(fault.test_name)
119
- backtrace.each_with_index do |entry, i|
120
- if i.zero?
121
- prefix = "["
122
- postfix = ""
123
- elsif i == backtrace.size - 1
124
- prefix = " "
125
- postfix = "]:"
126
- else
127
- prefix = " "
128
- postfix = ""
129
- end
130
- output(" #{prefix}#{entry}#{postfix}")
131
- end
132
- end
133
- end
134
-
135
- def output_fault_message(fault)
136
- output(fault.user_message) if fault.user_message
137
- output_single("<")
138
- output_single(fault.inspected_expected, color("pass"))
139
- output("> expected but was")
140
- output_single("<")
141
- output_single(fault.inspected_actual, color("failure"))
142
- output(">")
143
- from, to = prepare_for_diff(fault.expected, fault.actual)
144
- if from and to
145
- differ = ColorizedReadableDiffer.new(from.split(/\r?\n/),
146
- to.split(/\r?\n/),
147
- self)
148
- if differ.need_diff?
149
- output("")
150
- output("diff:")
151
- differ.diff
152
- end
153
- end
154
- end
155
-
156
- def format_fault(fault)
157
- fault.long_display
158
- end
159
-
160
- def test_started(name)
161
- return unless output?(VERBOSE)
162
-
163
- name = name.sub(/\(.+?\)\z/, '')
164
- right_space = 8 * 2
165
- left_space = @progress_row_max - right_space
166
- left_space = left_space - indent.size - name.size
167
- tab_stop = "\t" * ([left_space - 1, 0].max / 8)
168
- output_single("#{indent}#{name}:#{tab_stop}", nil, VERBOSE)
169
- @test_start = Time.now
170
- end
171
-
172
- def test_finished(name)
173
- unless @already_outputted
174
- output_progress(".", color("pass"))
175
- end
176
- @already_outputted = false
177
-
178
- return unless output?(VERBOSE)
179
-
180
- output(": (%f)" % (Time.now - @test_start), nil, VERBOSE)
181
- end
182
-
183
- def test_suite_started(name)
184
- if @top_level
185
- @top_level = false
186
- return
187
- end
188
-
189
- output_single(indent, nil, VERBOSE)
190
- if /\A[A-Z]/ =~ name
191
- _color = color("case")
192
- else
193
- _color = color("suite")
194
- end
195
- output_single(name, _color, VERBOSE)
196
- output(": ", nil, VERBOSE)
197
- @indent += 2
198
- end
199
-
200
- def test_suite_finished(name)
201
- @indent -= 2
202
- end
203
-
204
- def indent
205
- if output?(VERBOSE)
206
- " " * @indent
207
- else
208
- ""
209
- end
210
- end
211
-
212
- def nl(level=NORMAL)
213
- output("", nil, level)
214
- end
215
-
216
- def output(something, color=nil, level=NORMAL)
217
- return unless output?(level)
218
- output_single(something, color, level)
219
- @output.puts
220
- end
221
-
222
- def output_single(something, color=nil, level=NORMAL)
223
- return false unless output?(level)
224
- if @use_color and color
225
- something = "%s%s%s" % [color.escape_sequence,
226
- something,
227
- @reset_color.escape_sequence]
228
- end
229
- @output.write(something)
230
- @output.flush
231
- true
232
- end
233
-
234
- def output_progress(mark, color=nil)
235
- if output_single(mark, color, PROGRESS_ONLY)
236
- return unless @progress_row_max > 0
237
- @progress_row += mark.size
238
- if @progress_row >= @progress_row_max
239
- nl unless @output_level == VERBOSE
240
- @progress_row = 0
241
- end
242
- end
243
- end
244
-
245
- def output?(level)
246
- level <= @output_level
247
- end
248
-
249
- def color(name)
250
- _color = @color_scheme[name]
251
- _color ||= @color_scheme["success"] if name == "pass"
252
- _color ||= ColorScheme.default[name]
253
- _color
254
- end
255
-
256
- def fault_color(fault)
257
- color(fault.class.name.split(/::/).last.downcase)
258
- end
259
-
260
- def result_color
261
- color(@result.status)
262
- end
263
-
264
- def guess_color_availability
265
- return false unless @output.tty?
266
- case ENV["TERM"]
267
- when /term(?:-color)?\z/, "screen"
268
- true
269
- else
270
- return true if ENV["EMACS"] == "t"
271
- false
272
- end
273
- end
274
-
275
- def guess_progress_row_max
276
- term_width = guess_term_width
277
- if term_width.zero?
278
- if ENV["EMACS"] == "t"
279
- -1
280
- else
281
- 79
282
- end
283
- else
284
- term_width
285
- end
286
- end
287
-
288
- def guess_term_width
289
- Integer(ENV["TERM_WIDTH"] || 0)
290
- rescue ArgumentError
291
- 0
292
- end
293
- end
294
-
295
- class ColorizedReadableDiffer < Diff::ReadableDiffer
296
- def initialize(from, to, runner)
297
- @runner = runner
298
- super(from, to)
299
- end
300
-
301
- def need_diff?(options={})
302
- operations.each do |tag,|
303
- return true if [:replace, :equal].include?(tag)
304
- end
305
- false
306
- end
307
-
308
- private
309
- def output_single(something, color=nil)
310
- @runner.send(:output_single, something, color)
311
- end
312
-
313
- def output(something, color=nil)
314
- @runner.send(:output, something, color)
315
- end
316
-
317
- def color(name)
318
- @runner.send(:color, name)
319
- end
320
-
321
- def cut_off_ratio
322
- 0
323
- end
324
-
325
- def default_ratio
326
- 0
327
- end
328
-
329
- def tag(mark, color_name, contents)
330
- _color = color(color_name)
331
- contents.each do |content|
332
- output_single(mark, _color)
333
- output_single(" ")
334
- output(content)
335
- end
336
- end
337
-
338
- def tag_deleted(contents)
339
- tag("-", "diff-deleted-tag", contents)
340
- end
341
-
342
- def tag_inserted(contents)
343
- tag("+", "diff-inserted-tag", contents)
344
- end
345
-
346
- def tag_equal(contents)
347
- tag(" ", "normal", contents)
348
- end
349
-
350
- def tag_difference(contents)
351
- tag("?", "diff-difference-tag", contents)
352
- end
353
-
354
- def diff_line(from_line, to_line)
355
- to_operations = []
356
- from_line, to_line, _operations = line_operations(from_line, to_line)
357
-
358
- no_replace = true
359
- _operations.each do |tag,|
360
- if tag == :replace
361
- no_replace = false
362
- break
363
- end
364
- end
365
-
366
- output_single("?", color("diff-difference-tag"))
367
- output_single(" ")
368
- _operations.each do |tag, from_start, from_end, to_start, to_end|
369
- from_width = compute_width(from_line, from_start, from_end)
370
- to_width = compute_width(to_line, to_start, to_end)
371
- case tag
372
- when :replace
373
- output_single(from_line[from_start...from_end],
374
- color("diff-deleted"))
375
- if (from_width < to_width)
376
- output_single(" " * (to_width - from_width))
377
- end
378
- to_operations << Proc.new do
379
- output_single(to_line[to_start...to_end],
380
- color("diff-inserted"))
381
- if (to_width < from_width)
382
- output_single(" " * (from_width - to_width))
383
- end
384
- end
385
- when :delete
386
- output_single(from_line[from_start...from_end],
387
- color("diff-deleted"))
388
- unless no_replace
389
- to_operations << Proc.new {output_single(" " * from_width)}
390
- end
391
- when :insert
392
- if no_replace
393
- output_single(to_line[to_start...to_end],
394
- color("diff-inserted"))
395
- else
396
- output_single(" " * to_width)
397
- to_operations << Proc.new do
398
- output_single(to_line[to_start...to_end],
399
- color("diff-inserted"))
400
- end
401
- end
402
- when :equal
403
- output_single(from_line[from_start...from_end])
404
- unless no_replace
405
- to_operations << Proc.new {output_single(" " * to_width)}
406
- end
407
- else
408
- raise "unknown tag: #{tag}"
409
- end
410
- end
411
- output("")
412
-
413
- unless to_operations.empty?
414
- output_single("?", color("diff-difference-tag"))
415
- output_single(" ")
416
- to_operations.each do |operation|
417
- operation.call
418
- end
419
- output("")
420
- end
421
- end
422
- end
423
- end
424
- end
425
- end
426
- end
427
-
428
- if __FILE__ == $0
429
- Test::Unit::UI::Console::TestRunner.start_command_line_test
430
- end