optimistic-json 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -0
  3. data/.ruby-version +1 -0
  4. data/CHANGELOG.md +10 -0
  5. data/README.md +4 -0
  6. data/Rakefile +5 -1
  7. data/lib/optimistic/json/parser.rb +28 -7
  8. data/lib/optimistic/json/version.rb +2 -1
  9. data/lib/optimistic/json.rb +1 -1
  10. data/sorbet/config +4 -0
  11. data/sorbet/rbi/annotations/.gitattributes +1 -0
  12. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  13. data/sorbet/rbi/gems/.gitattributes +1 -0
  14. data/sorbet/rbi/gems/ast@2.4.2.rbi +550 -0
  15. data/sorbet/rbi/gems/benchmark@0.5.0.rbi +621 -0
  16. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +1068 -0
  17. data/sorbet/rbi/gems/erubi@1.13.1.rbi +155 -0
  18. data/sorbet/rbi/gems/gem-release@2.2.2.rbi +1335 -0
  19. data/sorbet/rbi/gems/io-console@0.6.0.rbi +9 -0
  20. data/sorbet/rbi/gems/json@2.7.0.rbi +1797 -0
  21. data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +12986 -0
  22. data/sorbet/rbi/gems/logger@1.6.0.rbi +845 -0
  23. data/sorbet/rbi/gems/multi_json@1.15.0.rbi +218 -0
  24. data/sorbet/rbi/gems/netrc@0.11.0.rbi +147 -0
  25. data/sorbet/rbi/gems/parallel@1.28.0.rbi +270 -0
  26. data/sorbet/rbi/gems/parser@3.2.2.4.rbi +5154 -0
  27. data/sorbet/rbi/gems/prism@1.9.0.rbi +42224 -0
  28. data/sorbet/rbi/gems/psych@5.1.1.1.rbi +2321 -0
  29. data/sorbet/rbi/gems/racc@1.7.3.rbi +169 -0
  30. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +362 -0
  31. data/sorbet/rbi/gems/rake@13.1.0.rbi +3025 -0
  32. data/sorbet/rbi/gems/rbi@0.3.11.rbi +5505 -0
  33. data/sorbet/rbi/gems/rbs@4.0.2.rbi +6908 -0
  34. data/sorbet/rbi/gems/rdoc@6.6.0.rbi +9 -0
  35. data/sorbet/rbi/gems/regexp_parser@2.8.2.rbi +3268 -0
  36. data/sorbet/rbi/gems/reline@0.4.1.rbi +9 -0
  37. data/sorbet/rbi/gems/require-hooks@0.4.0.rbi +152 -0
  38. data/sorbet/rbi/gems/rexml@3.2.6.rbi +4798 -0
  39. data/sorbet/rbi/gems/rspec-core@3.12.2.rbi +9405 -0
  40. data/sorbet/rbi/gems/rspec-expectations@3.12.3.rbi +6013 -0
  41. data/sorbet/rbi/gems/rspec-mocks@3.12.6.rbi +4750 -0
  42. data/sorbet/rbi/gems/rspec-support@3.12.1.rbi +1261 -0
  43. data/sorbet/rbi/gems/rspec@3.12.0.rbi +15 -0
  44. data/sorbet/rbi/gems/rubocop-ast@1.30.0.rbi +6750 -0
  45. data/sorbet/rbi/gems/rubocop-capybara@2.19.0.rbi +1058 -0
  46. data/sorbet/rbi/gems/rubocop-factory_bot@2.24.0.rbi +875 -0
  47. data/sorbet/rbi/gems/rubocop-rspec@2.25.0.rbi +7696 -0
  48. data/sorbet/rbi/gems/rubocop@1.58.0.rbi +53790 -0
  49. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +988 -0
  50. data/sorbet/rbi/gems/rubydex@0.2.3.rbi +787 -0
  51. data/sorbet/rbi/gems/spoom@1.7.14.rbi +6151 -0
  52. data/sorbet/rbi/gems/stringio@3.1.0.rbi +9 -0
  53. data/sorbet/rbi/gems/tapioca@0.19.1.rbi +3558 -0
  54. data/sorbet/rbi/gems/thor@1.5.0.rbi +3870 -0
  55. data/sorbet/rbi/gems/tsort@0.2.0.rbi +387 -0
  56. data/sorbet/rbi/gems/unicode-display_width@2.5.0.rbi +64 -0
  57. data/sorbet/tapioca/config.yml +13 -0
  58. data/sorbet/tapioca/require.rb +4 -0
  59. metadata +55 -23
  60. data/sig/optimistic/json.rbs +0 -6
@@ -0,0 +1,1068 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `diff-lcs` gem.
5
+ # Please instead update this file by running `bin/tapioca gem diff-lcs`.
6
+
7
+
8
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:3
9
+ module Diff; end
10
+
11
+ # == How Diff Works (by Mark-Jason Dominus)
12
+ #
13
+ # I once read an article written by the authors of +diff+; they said that they
14
+ # hard worked very hard on the algorithm until they found the right one.
15
+ #
16
+ # I think what they ended up using (and I hope someone will correct me, because
17
+ # I am not very confident about this) was the `longest common subsequence'
18
+ # method. In the LCS problem, you have two sequences of items:
19
+ #
20
+ # a b c d f g h j q z
21
+ # a b c d e f g i j k r x y z
22
+ #
23
+ # and you want to find the longest sequence of items that is present in both
24
+ # original sequences in the same order. That is, you want to find a new
25
+ # sequence *S* which can be obtained from the first sequence by deleting some
26
+ # items, and from the second sequence by deleting other items. You also want
27
+ # *S* to be as long as possible. In this case *S* is:
28
+ #
29
+ # a b c d f g j z
30
+ #
31
+ # From there it's only a small step to get diff-like output:
32
+ #
33
+ # e h i k q r x y
34
+ # + - + + - + + +
35
+ #
36
+ # This module solves the LCS problem. It also includes a canned function to
37
+ # generate +diff+-like output.
38
+ #
39
+ # It might seem from the example above that the LCS of two sequences is always
40
+ # pretty obvious, but that's not always the case, especially when the two
41
+ # sequences have many repeated elements. For example, consider
42
+ #
43
+ # a x b y c z p d q
44
+ # a b c a x b y c z
45
+ #
46
+ # A naive approach might start by matching up the +a+ and +b+ that appear at
47
+ # the beginning of each sequence, like this:
48
+ #
49
+ # a x b y c z p d q
50
+ # a b c a b y c z
51
+ #
52
+ # This finds the common subsequence +a b c z+. But actually, the LCS is +a x b
53
+ # y c z+:
54
+ #
55
+ # a x b y c z p d q
56
+ # a b c a x b y c z
57
+ #
58
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:51
59
+ module Diff::LCS
60
+ # Returns the difference set between +self+ and +other+. See Diff::LCS#diff.
61
+ #
62
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:75
63
+ def diff(other, callbacks = T.unsafe(nil), &block); end
64
+
65
+ # Returns an Array containing the longest common subsequence(s) between
66
+ # +self+ and +other+. See Diff::LCS#lcs.
67
+ #
68
+ # lcs = seq1.lcs(seq2)
69
+ #
70
+ # A note when using objects: Diff::LCS only works properly when each object
71
+ # can be used as a key in a Hash, which typically means that the objects must
72
+ # implement Object#eql? in a way that two identical values compare
73
+ # identically for key purposes. That is:
74
+ #
75
+ # O.new('a').eql?(O.new('a')) == true
76
+ #
77
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:70
78
+ def lcs(other, &block); end
79
+
80
+ # Attempts to patch +self+ with the provided +patchset+. A new sequence based
81
+ # on +self+ and the +patchset+ will be created. See Diff::LCS#patch. Attempts
82
+ # to autodiscover the direction of the patch.
83
+ #
84
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:101
85
+ def patch(patchset); end
86
+
87
+ # Attempts to patch +self+ with the provided +patchset+. A new sequence based
88
+ # on +self+ and the +patchset+ will be created. See Diff::LCS#patch. Does no
89
+ # patch direction autodiscovery.
90
+ #
91
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:109
92
+ def patch!(patchset); end
93
+
94
+ # Attempts to patch +self+ with the provided +patchset+, using #patch!. If
95
+ # the sequence this is used on supports #replace, the value of +self+ will be
96
+ # replaced. See Diff::LCS#patch. Does no patch direction autodiscovery.
97
+ #
98
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:123
99
+ def patch_me(patchset); end
100
+
101
+ # Returns the balanced ("side-by-side") difference set between +self+ and
102
+ # +other+. See Diff::LCS#sdiff.
103
+ #
104
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:81
105
+ def sdiff(other, callbacks = T.unsafe(nil), &block); end
106
+
107
+ # Traverses the discovered longest common subsequences between +self+ and
108
+ # +other+ using the alternate, balanced algorithm. See
109
+ # Diff::LCS#traverse_balanced.
110
+ #
111
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:94
112
+ def traverse_balanced(other, callbacks = T.unsafe(nil), &block); end
113
+
114
+ # Traverses the discovered longest common subsequences between +self+ and
115
+ # +other+. See Diff::LCS#traverse_sequences.
116
+ #
117
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:87
118
+ def traverse_sequences(other, callbacks = T.unsafe(nil), &block); end
119
+
120
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:104
121
+ def unpatch(patchset); end
122
+
123
+ # Attempts to unpatch +self+ with the provided +patchset+. A new sequence
124
+ # based on +self+ and the +patchset+ will be created. See Diff::LCS#unpatch.
125
+ # Does no patch direction autodiscovery.
126
+ #
127
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:116
128
+ def unpatch!(patchset); end
129
+
130
+ # Attempts to unpatch +self+ with the provided +patchset+, using #unpatch!.
131
+ # If the sequence this is used on supports #replace, the value of +self+ will
132
+ # be replaced. See Diff::LCS#unpatch. Does no patch direction autodiscovery.
133
+ #
134
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:134
135
+ def unpatch_me(patchset); end
136
+
137
+ class << self
138
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:157
139
+ def LCS(seq1, seq2, &block); end
140
+
141
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:52
142
+ def callbacks_for(callbacks); end
143
+
144
+ # #diff computes the smallest set of additions and deletions necessary to
145
+ # turn the first sequence into the second, and returns a description of these
146
+ # changes.
147
+ #
148
+ # See Diff::LCS::DiffCallbacks for the default behaviour. An alternate
149
+ # behaviour may be implemented with Diff::LCS::ContextDiffCallbacks. If a
150
+ # Class argument is provided for +callbacks+, #diff will attempt to
151
+ # initialise it. If the +callbacks+ object (possibly initialised) responds to
152
+ # #finish, it will be called.
153
+ #
154
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:168
155
+ def diff(seq1, seq2, callbacks = T.unsafe(nil), &block); end
156
+
157
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:144
158
+ def lcs(seq1, seq2, &block); end
159
+
160
+ # Applies a +patchset+ to the sequence +src+ according to the +direction+
161
+ # (<tt>:patch</tt> or <tt>:unpatch</tt>), producing a new sequence.
162
+ #
163
+ # If the +direction+ is not specified, Diff::LCS::patch will attempt to
164
+ # discover the direction of the +patchset+.
165
+ #
166
+ # A +patchset+ can be considered to apply forward (<tt>:patch</tt>) if the
167
+ # following expression is true:
168
+ #
169
+ # patch(s1, diff(s1, s2)) -> s2
170
+ #
171
+ # A +patchset+ can be considered to apply backward (<tt>:unpatch</tt>) if the
172
+ # following expression is true:
173
+ #
174
+ # patch(s2, diff(s1, s2)) -> s1
175
+ #
176
+ # If the +patchset+ contains no changes, the +src+ value will be returned as
177
+ # either <tt>src.dup</tt> or +src+. A +patchset+ can be deemed as having no
178
+ # changes if the following predicate returns true:
179
+ #
180
+ # patchset.empty? or
181
+ # patchset.flatten(1).all? { |change| change.unchanged? }
182
+ #
183
+ # === Patchsets
184
+ #
185
+ # A +patchset+ is always an enumerable sequence of changes, hunks of changes,
186
+ # or a mix of the two. A hunk of changes is an enumerable sequence of
187
+ # changes:
188
+ #
189
+ # [ # patchset
190
+ # # change
191
+ # [ # hunk
192
+ # # change
193
+ # ]
194
+ # ]
195
+ #
196
+ # The +patch+ method accepts <tt>patchset</tt>s that are enumerable sequences
197
+ # containing either Diff::LCS::Change objects (or a subclass) or the array
198
+ # representations of those objects. Prior to application, array
199
+ # representations of Diff::LCS::Change objects will be reified.
200
+ #
201
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:624
202
+ def patch(src, patchset, direction = T.unsafe(nil)); end
203
+
204
+ # Given a set of patchset, convert the current version to the next version.
205
+ # Does no auto-discovery.
206
+ #
207
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:734
208
+ def patch!(src, patchset); end
209
+
210
+ # #sdiff computes all necessary components to show two sequences and their
211
+ # minimized differences side by side, just like the Unix utility
212
+ # <em>sdiff</em> does:
213
+ #
214
+ # old < -
215
+ # same same
216
+ # before | after
217
+ # - > new
218
+ #
219
+ # See Diff::LCS::SDiffCallbacks for the default behaviour. An alternate
220
+ # behaviour may be implemented with Diff::LCS::ContextDiffCallbacks. If a
221
+ # Class argument is provided for +callbacks+, #diff will attempt to
222
+ # initialise it. If the +callbacks+ object (possibly initialised) responds to
223
+ # #finish, it will be called.
224
+ #
225
+ # Each element of a returned array is a Diff::LCS::ContextChange object,
226
+ # which can be implicitly converted to an array.
227
+ #
228
+ # Diff::LCS.sdiff(a, b).each do |action, (old_pos, old_element), (new_pos, new_element)|
229
+ # case action
230
+ # when '!'
231
+ # # replace
232
+ # when '-'
233
+ # # delete
234
+ # when '+'
235
+ # # insert
236
+ # end
237
+ # end
238
+ #
239
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:200
240
+ def sdiff(seq1, seq2, callbacks = T.unsafe(nil), &block); end
241
+
242
+ # #traverse_balanced is an alternative to #traverse_sequences. It uses a
243
+ # different algorithm to iterate through the entries in the computed longest
244
+ # common subsequence. Instead of viewing the changes as insertions or
245
+ # deletions from one of the sequences, #traverse_balanced will report
246
+ # <em>changes</em> between the sequences.
247
+ #
248
+ # The arguments to #traverse_balanced are the two sequences to traverse and a
249
+ # callback object, like this:
250
+ #
251
+ # traverse_balanced(seq1, seq2, Diff::LCS::ContextDiffCallbacks.new)
252
+ #
253
+ # #sdiff is implemented with #traverse_balanced.
254
+ #
255
+ # == Callback Methods
256
+ #
257
+ # Optional callback methods are <em>emphasized</em>.
258
+ #
259
+ # callbacks#match:: Called when +a+ and +b+ are pointing to
260
+ # common elements in +A+ and +B+.
261
+ # callbacks#discard_a:: Called when +a+ is pointing to an
262
+ # element not in +B+.
263
+ # callbacks#discard_b:: Called when +b+ is pointing to an
264
+ # element not in +A+.
265
+ # <em>callbacks#change</em>:: Called when +a+ and +b+ are pointing to
266
+ # the same relative position, but
267
+ # <tt>A[a]</tt> and <tt>B[b]</tt> are not
268
+ # the same; a <em>change</em> has
269
+ # occurred.
270
+ #
271
+ # #traverse_balanced might be a bit slower than #traverse_sequences,
272
+ # noticable only while processing huge amounts of data.
273
+ #
274
+ # == Algorithm
275
+ #
276
+ # a---+
277
+ # v
278
+ # A = a b c e h j l m n p
279
+ # B = b c d e f j k l m r s t
280
+ # ^
281
+ # b---+
282
+ #
283
+ # === Matches
284
+ #
285
+ # If there are two arrows (+a+ and +b+) pointing to elements of sequences +A+
286
+ # and +B+, the arrows will initially point to the first elements of their
287
+ # respective sequences. #traverse_sequences will advance the arrows through
288
+ # the sequences one element at a time, calling a method on the user-specified
289
+ # callback object before each advance. It will advance the arrows in such a
290
+ # way that if there are elements <tt>A[i]</tt> and <tt>B[j]</tt> which are
291
+ # both equal and part of the longest common subsequence, there will be some
292
+ # moment during the execution of #traverse_sequences when arrow +a+ is
293
+ # pointing to <tt>A[i]</tt> and arrow +b+ is pointing to <tt>B[j]</tt>. When
294
+ # this happens, #traverse_sequences will call <tt>callbacks#match</tt> and
295
+ # then it will advance both arrows.
296
+ #
297
+ # === Discards
298
+ #
299
+ # Otherwise, one of the arrows is pointing to an element of its sequence that
300
+ # is not part of the longest common subsequence. #traverse_sequences will
301
+ # advance that arrow and will call <tt>callbacks#discard_a</tt> or
302
+ # <tt>callbacks#discard_b</tt>, depending on which arrow it advanced.
303
+ #
304
+ # === Changes
305
+ #
306
+ # If both +a+ and +b+ point to elements that are not part of the longest
307
+ # common subsequence, then #traverse_sequences will try to call
308
+ # <tt>callbacks#change</tt> and advance both arrows. If
309
+ # <tt>callbacks#change</tt> is not implemented, then
310
+ # <tt>callbacks#discard_a</tt> and <tt>callbacks#discard_b</tt> will be
311
+ # called in turn.
312
+ #
313
+ # The methods for <tt>callbacks#match</tt>, <tt>callbacks#discard_a</tt>,
314
+ # <tt>callbacks#discard_b</tt>, and <tt>callbacks#change</tt> are invoked
315
+ # with an event comprising the action ("=", "+", "-", or "!", respectively),
316
+ # the indicies +i+ and +j+, and the elements <tt>A[i]</tt> and <tt>B[j]</tt>.
317
+ # Return values are discarded by #traverse_balanced.
318
+ #
319
+ # === Context
320
+ #
321
+ # Note that +i+ and +j+ may not be the same index position, even if +a+ and
322
+ # +b+ are considered to be pointing to matching or changed elements.
323
+ #
324
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:475
325
+ def traverse_balanced(seq1, seq2, callbacks = T.unsafe(nil)); end
326
+
327
+ # #traverse_sequences is the most general facility provided by this module;
328
+ # #diff and #lcs are implemented as calls to it.
329
+ #
330
+ # The arguments to #traverse_sequences are the two sequences to traverse, and
331
+ # a callback object, like this:
332
+ #
333
+ # traverse_sequences(seq1, seq2, Diff::LCS::ContextDiffCallbacks.new)
334
+ #
335
+ # == Callback Methods
336
+ #
337
+ # Optional callback methods are <em>emphasized</em>.
338
+ #
339
+ # callbacks#match:: Called when +a+ and +b+ are pointing to
340
+ # common elements in +A+ and +B+.
341
+ # callbacks#discard_a:: Called when +a+ is pointing to an
342
+ # element not in +B+.
343
+ # callbacks#discard_b:: Called when +b+ is pointing to an
344
+ # element not in +A+.
345
+ # <em>callbacks#finished_a</em>:: Called when +a+ has reached the end of
346
+ # sequence +A+.
347
+ # <em>callbacks#finished_b</em>:: Called when +b+ has reached the end of
348
+ # sequence +B+.
349
+ #
350
+ # == Algorithm
351
+ #
352
+ # a---+
353
+ # v
354
+ # A = a b c e h j l m n p
355
+ # B = b c d e f j k l m r s t
356
+ # ^
357
+ # b---+
358
+ #
359
+ # If there are two arrows (+a+ and +b+) pointing to elements of sequences +A+
360
+ # and +B+, the arrows will initially point to the first elements of their
361
+ # respective sequences. #traverse_sequences will advance the arrows through
362
+ # the sequences one element at a time, calling a method on the user-specified
363
+ # callback object before each advance. It will advance the arrows in such a
364
+ # way that if there are elements <tt>A[i]</tt> and <tt>B[j]</tt> which are
365
+ # both equal and part of the longest common subsequence, there will be some
366
+ # moment during the execution of #traverse_sequences when arrow +a+ is
367
+ # pointing to <tt>A[i]</tt> and arrow +b+ is pointing to <tt>B[j]</tt>. When
368
+ # this happens, #traverse_sequences will call <tt>callbacks#match</tt> and
369
+ # then it will advance both arrows.
370
+ #
371
+ # Otherwise, one of the arrows is pointing to an element of its sequence that
372
+ # is not part of the longest common subsequence. #traverse_sequences will
373
+ # advance that arrow and will call <tt>callbacks#discard_a</tt> or
374
+ # <tt>callbacks#discard_b</tt>, depending on which arrow it advanced. If both
375
+ # arrows point to elements that are not part of the longest common
376
+ # subsequence, then #traverse_sequences will advance arrow +a+ and call the
377
+ # appropriate callback, then it will advance arrow +b+ and call the appropriate
378
+ # callback.
379
+ #
380
+ # The methods for <tt>callbacks#match</tt>, <tt>callbacks#discard_a</tt>, and
381
+ # <tt>callbacks#discard_b</tt> are invoked with an event comprising the
382
+ # action ("=", "+", or "-", respectively), the indicies +i+ and +j+, and the
383
+ # elements <tt>A[i]</tt> and <tt>B[j]</tt>. Return values are discarded by
384
+ # #traverse_sequences.
385
+ #
386
+ # === End of Sequences
387
+ #
388
+ # If arrow +a+ reaches the end of its sequence before arrow +b+ does,
389
+ # #traverse_sequence will try to call <tt>callbacks#finished_a</tt> with the
390
+ # last index and element of +A+ (<tt>A[-1]</tt>) and the current index and
391
+ # element of +B+ (<tt>B[j]</tt>). If <tt>callbacks#finished_a</tt> does not
392
+ # exist, then <tt>callbacks#discard_b</tt> will be called on each element of
393
+ # +B+ until the end of the sequence is reached (the call will be done with
394
+ # <tt>A[-1]</tt> and <tt>B[j]</tt> for each element).
395
+ #
396
+ # If +b+ reaches the end of +B+ before +a+ reaches the end of +A+,
397
+ # <tt>callbacks#finished_b</tt> will be called with the current index and
398
+ # element of +A+ (<tt>A[i]</tt>) and the last index and element of +B+
399
+ # (<tt>A[-1]</tt>). Again, if <tt>callbacks#finished_b</tt> does not exist on
400
+ # the callback object, then <tt>callbacks#discard_a</tt> will be called on
401
+ # each element of +A+ until the end of the sequence is reached (<tt>A[i]</tt>
402
+ # and <tt>B[-1]</tt>).
403
+ #
404
+ # There is a chance that one additional <tt>callbacks#discard_a</tt> or
405
+ # <tt>callbacks#discard_b</tt> will be called after the end of the sequence
406
+ # is reached, if +a+ has not yet reached the end of +A+ or +b+ has not yet
407
+ # reached the end of +B+.
408
+ #
409
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:285
410
+ def traverse_sequences(seq1, seq2, callbacks = T.unsafe(nil)); end
411
+
412
+ # Given a set of patchset, convert the current version to the prior version.
413
+ # Does no auto-discovery.
414
+ #
415
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:728
416
+ def unpatch!(src, patchset); end
417
+
418
+ private
419
+
420
+ # pkg:gem/diff-lcs#lib/diff/lcs/internals.rb:4
421
+ def diff_traversal(method, seq1, seq2, callbacks, &block); end
422
+ end
423
+ end
424
+
425
+ # An alias for DefaultCallbacks that is used in
426
+ # Diff::LCS#traverse_balanced.
427
+ #
428
+ # Diff::LCS.LCS(seq1, seq2, Diff::LCS::BalancedCallbacks)
429
+ #
430
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:50
431
+ Diff::LCS::BalancedCallbacks = Diff::LCS::DefaultCallbacks
432
+
433
+ # A block is an operation removing, adding, or changing a group of items.
434
+ # Basically, this is just a list of changes, where each change adds or
435
+ # deletes a single item. Used by bin/ldiff.
436
+ #
437
+ # pkg:gem/diff-lcs#lib/diff/lcs/block.rb:6
438
+ class Diff::LCS::Block
439
+ # pkg:gem/diff-lcs#lib/diff/lcs/block.rb:9
440
+ def initialize(chunk); end
441
+
442
+ # pkg:gem/diff-lcs#lib/diff/lcs/block.rb:7
443
+ def changes; end
444
+
445
+ # pkg:gem/diff-lcs#lib/diff/lcs/block.rb:21
446
+ def diff_size; end
447
+
448
+ # pkg:gem/diff-lcs#lib/diff/lcs/block.rb:7
449
+ def insert; end
450
+
451
+ # pkg:gem/diff-lcs#lib/diff/lcs/block.rb:25
452
+ def op; end
453
+
454
+ # pkg:gem/diff-lcs#lib/diff/lcs/block.rb:7
455
+ def remove; end
456
+ end
457
+
458
+ # Represents a simplistic (non-contextual) change. Represents the removal or
459
+ # addition of an element from either the old or the new sequenced
460
+ # enumerable.
461
+ #
462
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:6
463
+ class Diff::LCS::Change
464
+ include ::Comparable
465
+
466
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:27
467
+ def initialize(*args); end
468
+
469
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:65
470
+ def <=>(other); end
471
+
472
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:58
473
+ def ==(other); end
474
+
475
+ # Returns the action this Change represents.
476
+ #
477
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:20
478
+ def action; end
479
+
480
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:72
481
+ def adding?; end
482
+
483
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:84
484
+ def changed?; end
485
+
486
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:76
487
+ def deleting?; end
488
+
489
+ # Returns the sequence element of the Change.
490
+ #
491
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:25
492
+ def element; end
493
+
494
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:88
495
+ def finished_a?; end
496
+
497
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:92
498
+ def finished_b?; end
499
+
500
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:34
501
+ def inspect(*_args); end
502
+
503
+ # Returns the position of the Change.
504
+ #
505
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:23
506
+ def position; end
507
+
508
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:38
509
+ def to_a; end
510
+
511
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:42
512
+ def to_ary; end
513
+
514
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:80
515
+ def unchanged?; end
516
+
517
+ class << self
518
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:44
519
+ def from_a(arr); end
520
+
521
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:15
522
+ def valid_action?(action); end
523
+ end
524
+ end
525
+
526
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:7
527
+ Diff::LCS::Change::IntClass = Integer
528
+
529
+ # The only actions valid for changes are '+' (add), '-' (delete), '='
530
+ # (no change), '!' (changed), '<' (tail changes from first sequence), or
531
+ # '>' (tail changes from second sequence). The last two ('<>') are only
532
+ # found with Diff::LCS::diff and Diff::LCS::sdiff.
533
+ #
534
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:13
535
+ Diff::LCS::Change::VALID_ACTIONS = T.let(T.unsafe(nil), Array)
536
+
537
+ # Represents a contextual change. Contains the position and values of the
538
+ # elements in the old and the new sequenced enumerables as well as the action
539
+ # taken.
540
+ #
541
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:100
542
+ class Diff::LCS::ContextChange < ::Diff::LCS::Change
543
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:114
544
+ def initialize(*args); end
545
+
546
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:166
547
+ def <=>(other); end
548
+
549
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:157
550
+ def ==(other); end
551
+
552
+ # Returns the new element being changed.
553
+ #
554
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:112
555
+ def new_element; end
556
+
557
+ # Returns the new position being changed.
558
+ #
559
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:108
560
+ def new_position; end
561
+
562
+ # Returns the old element being changed.
563
+ #
564
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:110
565
+ def old_element; end
566
+
567
+ # Returns the old position being changed.
568
+ #
569
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:106
570
+ def old_position; end
571
+
572
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:122
573
+ def to_a; end
574
+
575
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:130
576
+ def to_ary; end
577
+
578
+ class << self
579
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:132
580
+ def from_a(arr); end
581
+
582
+ # Simplifies a context change for use in some diff callbacks. '<' actions
583
+ # are converted to '-' and '>' actions are converted to '+'.
584
+ #
585
+ # pkg:gem/diff-lcs#lib/diff/lcs/change.rb:138
586
+ def simplify(event); end
587
+ end
588
+ end
589
+
590
+ # This will produce a compound array of contextual diff change objects. Each
591
+ # element in the #diffs array is a "hunk" array, where each element in each
592
+ # "hunk" array is a single change. Each change is a Diff::LCS::ContextChange
593
+ # that contains both the old index and new index values for the change. The
594
+ # "hunk" provides the full context for the changes. Both old and new objects
595
+ # will be presented for changed objects. +nil+ will be substituted for a
596
+ # discarded object.
597
+ #
598
+ # seq1 = %w(a b c e h j l m n p)
599
+ # seq2 = %w(b c d e f j k l m r s t)
600
+ #
601
+ # diffs = Diff::LCS.diff(seq1, seq2, Diff::LCS::ContextDiffCallbacks)
602
+ # # This example shows a simplified array format.
603
+ # # [ [ [ '-', [ 0, 'a' ], [ 0, nil ] ] ], # 1
604
+ # # [ [ '+', [ 3, nil ], [ 2, 'd' ] ] ], # 2
605
+ # # [ [ '-', [ 4, 'h' ], [ 4, nil ] ], # 3
606
+ # # [ '+', [ 5, nil ], [ 4, 'f' ] ] ],
607
+ # # [ [ '+', [ 6, nil ], [ 6, 'k' ] ] ], # 4
608
+ # # [ [ '-', [ 8, 'n' ], [ 9, nil ] ], # 5
609
+ # # [ '+', [ 9, nil ], [ 9, 'r' ] ],
610
+ # # [ '-', [ 9, 'p' ], [ 10, nil ] ],
611
+ # # [ '+', [ 10, nil ], [ 10, 's' ] ],
612
+ # # [ '+', [ 10, nil ], [ 11, 't' ] ] ] ]
613
+ #
614
+ # The five hunks shown are comprised of individual changes; if there is a
615
+ # related set of changes, they are still shown individually.
616
+ #
617
+ # This callback can also be used with Diff::LCS#sdiff, which will produce
618
+ # results like:
619
+ #
620
+ # diffs = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextCallbacks)
621
+ # # This example shows a simplified array format.
622
+ # # [ [ [ "-", [ 0, "a" ], [ 0, nil ] ] ], # 1
623
+ # # [ [ "+", [ 3, nil ], [ 2, "d" ] ] ], # 2
624
+ # # [ [ "!", [ 4, "h" ], [ 4, "f" ] ] ], # 3
625
+ # # [ [ "+", [ 6, nil ], [ 6, "k" ] ] ], # 4
626
+ # # [ [ "!", [ 8, "n" ], [ 9, "r" ] ], # 5
627
+ # # [ "!", [ 9, "p" ], [ 10, "s" ] ],
628
+ # # [ "+", [ 10, nil ], [ 11, "t" ] ] ] ]
629
+ #
630
+ # The five hunks are still present, but are significantly shorter in total
631
+ # presentation, because changed items are shown as changes ("!") instead of
632
+ # potentially "mismatched" pairs of additions and deletions.
633
+ #
634
+ # The result of this operation is similar to that of
635
+ # Diff::LCS::SDiffCallbacks. They may be compared as:
636
+ #
637
+ # s = Diff::LCS.sdiff(seq1, seq2).reject { |e| e.action == "=" }
638
+ # c = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextDiffCallbacks).flatten(1)
639
+ #
640
+ # s == c # -> true
641
+ #
642
+ # === Use
643
+ #
644
+ # This callback object must be initialised and can be used by the
645
+ # Diff::LCS#diff or Diff::LCS#sdiff methods.
646
+ #
647
+ # cbo = Diff::LCS::ContextDiffCallbacks.new
648
+ # Diff::LCS.LCS(seq1, seq2, cbo)
649
+ # cbo.finish
650
+ #
651
+ # Note that the call to #finish is absolutely necessary, or the last set of
652
+ # changes will not be visible. Alternatively, can be used as:
653
+ #
654
+ # cbo = Diff::LCS::ContextDiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) }
655
+ #
656
+ # The necessary #finish call will be made.
657
+ #
658
+ # === Simplified Array Format
659
+ #
660
+ # The simplified array format used in the example above can be obtained
661
+ # with:
662
+ #
663
+ # require 'pp'
664
+ # pp diffs.map { |e| e.map { |f| f.to_a } }
665
+ #
666
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:223
667
+ class Diff::LCS::ContextDiffCallbacks < ::Diff::LCS::DiffCallbacks
668
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:232
669
+ def change(event); end
670
+
671
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:224
672
+ def discard_a(event); end
673
+
674
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:228
675
+ def discard_b(event); end
676
+ end
677
+
678
+ # This callback object implements the default set of callback events,
679
+ # which only returns the event itself. Note that #finished_a and
680
+ # #finished_b are not implemented -- I haven't yet figured out where they
681
+ # would be useful.
682
+ #
683
+ # Note that this is intended to be called as is, e.g.,
684
+ #
685
+ # Diff::LCS.LCS(seq1, seq2, Diff::LCS::DefaultCallbacks)
686
+ #
687
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:14
688
+ class Diff::LCS::DefaultCallbacks
689
+ class << self
690
+ # Called when both the old and new values have changed.
691
+ #
692
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:32
693
+ def change(event); end
694
+
695
+ # Called when the old value is discarded in favour of the new value.
696
+ #
697
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:22
698
+ def discard_a(event); end
699
+
700
+ # Called when the new value is discarded in favour of the old value.
701
+ #
702
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:27
703
+ def discard_b(event); end
704
+
705
+ # Called when two items match.
706
+ #
707
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:17
708
+ def match(event); end
709
+
710
+ private
711
+
712
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:36
713
+ def new(*_arg0); end
714
+ end
715
+ end
716
+
717
+ # This will produce a compound array of simple diff change objects. Each
718
+ # element in the #diffs array is a +hunk+ or +hunk+ array, where each
719
+ # element in each +hunk+ array is a single Change object representing the
720
+ # addition or removal of a single element from one of the two tested
721
+ # sequences. The +hunk+ provides the full context for the changes.
722
+ #
723
+ # diffs = Diff::LCS.diff(seq1, seq2)
724
+ # # This example shows a simplified array format.
725
+ # # [ [ [ '-', 0, 'a' ] ], # 1
726
+ # # [ [ '+', 2, 'd' ] ], # 2
727
+ # # [ [ '-', 4, 'h' ], # 3
728
+ # # [ '+', 4, 'f' ] ],
729
+ # # [ [ '+', 6, 'k' ] ], # 4
730
+ # # [ [ '-', 8, 'n' ], # 5
731
+ # # [ '-', 9, 'p' ],
732
+ # # [ '+', 9, 'r' ],
733
+ # # [ '+', 10, 's' ],
734
+ # # [ '+', 11, 't' ] ] ]
735
+ #
736
+ # There are five hunks here. The first hunk says that the +a+ at position 0
737
+ # of the first sequence should be deleted (<tt>'-'</tt>). The second hunk
738
+ # says that the +d+ at position 2 of the second sequence should be inserted
739
+ # (<tt>'+'</tt>). The third hunk says that the +h+ at position 4 of the
740
+ # first sequence should be removed and replaced with the +f+ from position 4
741
+ # of the second sequence. The other two hunks are described similarly.
742
+ #
743
+ # === Use
744
+ #
745
+ # This callback object must be initialised and is used by the Diff::LCS#diff
746
+ # method.
747
+ #
748
+ # cbo = Diff::LCS::DiffCallbacks.new
749
+ # Diff::LCS.LCS(seq1, seq2, cbo)
750
+ # cbo.finish
751
+ #
752
+ # Note that the call to #finish is absolutely necessary, or the last set of
753
+ # changes will not be visible. Alternatively, can be used as:
754
+ #
755
+ # cbo = Diff::LCS::DiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) }
756
+ #
757
+ # The necessary #finish call will be made.
758
+ #
759
+ # === Simplified Array Format
760
+ #
761
+ # The simplified array format used in the example above can be obtained
762
+ # with:
763
+ #
764
+ # require 'pp'
765
+ # pp diffs.map { |e| e.map { |f| f.to_a } }
766
+ #
767
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:106
768
+ class Diff::LCS::DiffCallbacks
769
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:110
770
+ def initialize; end
771
+
772
+ # Returns the difference set collected during the diff process.
773
+ #
774
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:108
775
+ def diffs; end
776
+
777
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:133
778
+ def discard_a(event); end
779
+
780
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:137
781
+ def discard_b(event); end
782
+
783
+ # Finalizes the diff process. If an unprocessed hunk still exists, then it
784
+ # is appended to the diff list.
785
+ #
786
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:125
787
+ def finish; end
788
+
789
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:129
790
+ def match(_event); end
791
+
792
+ private
793
+
794
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:141
795
+ def finish_hunk; end
796
+ end
797
+
798
+ # A Hunk is a group of Blocks which overlap because of the context surrounding
799
+ # each block. (So if we're not using context, every hunk will contain one
800
+ # block.) Used in the diff program (bin/ldiff).
801
+ #
802
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:8
803
+ class Diff::LCS::Hunk
804
+ # Create a hunk using references to both the old and new data, as well as the
805
+ # piece of data.
806
+ #
807
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:16
808
+ def initialize(data_old, data_new, piece, flag_context, file_length_difference); end
809
+
810
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:63
811
+ def blocks; end
812
+
813
+ # Returns a diff string based on a format.
814
+ #
815
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:116
816
+ def diff(format, last = T.unsafe(nil)); end
817
+
818
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:65
819
+ def end_new; end
820
+
821
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:65
822
+ def end_old; end
823
+
824
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:66
825
+ def file_length_difference; end
826
+
827
+ # Change the "start" and "end" fields to note that context should be added
828
+ # to this hunk.
829
+ #
830
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:70
831
+ def flag_context; end
832
+
833
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:70
834
+ def flag_context=(context); end
835
+
836
+ # Merges this hunk and the provided hunk together if they overlap. Returns
837
+ # a truthy value so that if there is no overlap, you can know the merge
838
+ # was skipped.
839
+ #
840
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:98
841
+ def merge(hunk); end
842
+
843
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:326
844
+ def missing_last_newline?(data); end
845
+
846
+ # Determines whether there is an overlap between this hunk and the
847
+ # provided hunk. This will be true if the difference between the two hunks
848
+ # start or end positions is within one position of each other.
849
+ #
850
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:110
851
+ def overlaps?(hunk); end
852
+
853
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:64
854
+ def start_new; end
855
+
856
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:64
857
+ def start_old; end
858
+
859
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:105
860
+ def unshift(hunk); end
861
+
862
+ private
863
+
864
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:213
865
+ def context_diff(last = T.unsafe(nil)); end
866
+
867
+ # Generate a range of item numbers to print. Only print 1 number if the
868
+ # range has only one item in it. Otherwise, it's 'start,end'
869
+ #
870
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:293
871
+ def context_range(mode, op, last = T.unsafe(nil)); end
872
+
873
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:271
874
+ def ed_diff(format, _last = T.unsafe(nil)); end
875
+
876
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:339
877
+ def encode(literal, target_encoding = T.unsafe(nil)); end
878
+
879
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:343
880
+ def encode_as(string, *args); end
881
+
882
+ # Note that an old diff can't have any context. Therefore, we know that
883
+ # there's only one block in the hunk.
884
+ #
885
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:135
886
+ def old_diff(_last = T.unsafe(nil)); end
887
+
888
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:160
889
+ def unified_diff(last = T.unsafe(nil)); end
890
+
891
+ # Generate a range of item numbers to print for unified diff. Print number
892
+ # where block starts, followed by number of lines in the block
893
+ # (don't print number of lines if it's 1)
894
+ #
895
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:311
896
+ def unified_range(mode, last); end
897
+ end
898
+
899
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:10
900
+ Diff::LCS::Hunk::ED_DIFF_OP_ACTION = T.let(T.unsafe(nil), Hash)
901
+
902
+ # pkg:gem/diff-lcs#lib/diff/lcs/hunk.rb:9
903
+ Diff::LCS::Hunk::OLD_DIFF_OP_ACTION = T.let(T.unsafe(nil), Hash)
904
+
905
+ # pkg:gem/diff-lcs#lib/diff/lcs/internals.rb:29
906
+ module Diff::LCS::Internals
907
+ class << self
908
+ # This method will analyze the provided patchset to provide a single-pass
909
+ # normalization (conversion of the array form of Diff::LCS::Change objects to
910
+ # the object form of same) and detection of whether the patchset represents
911
+ # changes to be made.
912
+ #
913
+ # pkg:gem/diff-lcs#lib/diff/lcs/internals.rb:102
914
+ def analyze_patchset(patchset, depth = T.unsafe(nil)); end
915
+
916
+ # Examine the patchset and the source to see in which direction the
917
+ # patch should be applied.
918
+ #
919
+ # WARNING: By default, this examines the whole patch, so this could take
920
+ # some time. This also works better with Diff::LCS::ContextChange or
921
+ # Diff::LCS::Change as its source, as an array will cause the creation
922
+ # of one of the above.
923
+ #
924
+ # pkg:gem/diff-lcs#lib/diff/lcs/internals.rb:147
925
+ def intuit_diff_direction(src, patchset, limit = T.unsafe(nil)); end
926
+
927
+ # Compute the longest common subsequence between the sequenced
928
+ # Enumerables +a+ and +b+. The result is an array whose contents is such
929
+ # that
930
+ #
931
+ # result = Diff::LCS::Internals.lcs(a, b)
932
+ # result.each_with_index do |e, i|
933
+ # assert_equal(a[i], b[e]) unless e.nil?
934
+ # end
935
+ #
936
+ # pkg:gem/diff-lcs#lib/diff/lcs/internals.rb:41
937
+ def lcs(a, b); end
938
+
939
+ private
940
+
941
+ # If +vector+ maps the matching elements of another collection onto this
942
+ # Enumerable, compute the inverse of +vector+ that maps this Enumerable
943
+ # onto the collection. (Currently unused.)
944
+ #
945
+ # pkg:gem/diff-lcs#lib/diff/lcs/internals.rb:286
946
+ def inverse_vector(a, vector); end
947
+
948
+ # Returns a hash mapping each element of an Enumerable to the set of
949
+ # positions it occupies in the Enumerable, optionally restricted to the
950
+ # elements specified in the range of indexes specified by +interval+.
951
+ #
952
+ # pkg:gem/diff-lcs#lib/diff/lcs/internals.rb:298
953
+ def position_hash(enum, interval); end
954
+
955
+ # Find the place at which +value+ would normally be inserted into the
956
+ # Enumerable. If that place is already occupied by +value+, do nothing
957
+ # and return +nil+. If the place does not exist (i.e., it is off the end
958
+ # of the Enumerable), add it to the end. Otherwise, replace the element
959
+ # at that point with +value+. It is assumed that the Enumerable's values
960
+ # are numeric.
961
+ #
962
+ # This operation preserves the sort order.
963
+ #
964
+ # pkg:gem/diff-lcs#lib/diff/lcs/internals.rb:252
965
+ def replace_next_larger(enum, value, last_index = T.unsafe(nil)); end
966
+ end
967
+ end
968
+
969
+ # This will produce a simple array of diff change objects. Each element in
970
+ # the #diffs array is a single ContextChange. In the set of #diffs provided
971
+ # by SDiffCallbacks, both old and new objects will be presented for both
972
+ # changed <strong>and unchanged</strong> objects. +nil+ will be substituted
973
+ # for a discarded object.
974
+ #
975
+ # The diffset produced by this callback, when provided to Diff::LCS#sdiff,
976
+ # will compute and display the necessary components to show two sequences
977
+ # and their minimized differences side by side, just like the Unix utility
978
+ # +sdiff+.
979
+ #
980
+ # same same
981
+ # before | after
982
+ # old < -
983
+ # - > new
984
+ #
985
+ # seq1 = %w(a b c e h j l m n p)
986
+ # seq2 = %w(b c d e f j k l m r s t)
987
+ #
988
+ # diffs = Diff::LCS.sdiff(seq1, seq2)
989
+ # # This example shows a simplified array format.
990
+ # # [ [ "-", [ 0, "a"], [ 0, nil ] ],
991
+ # # [ "=", [ 1, "b"], [ 0, "b" ] ],
992
+ # # [ "=", [ 2, "c"], [ 1, "c" ] ],
993
+ # # [ "+", [ 3, nil], [ 2, "d" ] ],
994
+ # # [ "=", [ 3, "e"], [ 3, "e" ] ],
995
+ # # [ "!", [ 4, "h"], [ 4, "f" ] ],
996
+ # # [ "=", [ 5, "j"], [ 5, "j" ] ],
997
+ # # [ "+", [ 6, nil], [ 6, "k" ] ],
998
+ # # [ "=", [ 6, "l"], [ 7, "l" ] ],
999
+ # # [ "=", [ 7, "m"], [ 8, "m" ] ],
1000
+ # # [ "!", [ 8, "n"], [ 9, "r" ] ],
1001
+ # # [ "!", [ 9, "p"], [ 10, "s" ] ],
1002
+ # # [ "+", [ 10, nil], [ 11, "t" ] ] ]
1003
+ #
1004
+ # The result of this operation is similar to that of
1005
+ # Diff::LCS::ContextDiffCallbacks. They may be compared as:
1006
+ #
1007
+ # s = Diff::LCS.sdiff(seq1, seq2).reject { |e| e.action == "=" }
1008
+ # c = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextDiffCallbacks).flatten(1)
1009
+ #
1010
+ # s == c # -> true
1011
+ #
1012
+ # === Use
1013
+ #
1014
+ # This callback object must be initialised and is used by the Diff::LCS#sdiff
1015
+ # method.
1016
+ #
1017
+ # cbo = Diff::LCS::SDiffCallbacks.new
1018
+ # Diff::LCS.LCS(seq1, seq2, cbo)
1019
+ #
1020
+ # As with the other initialisable callback objects,
1021
+ # Diff::LCS::SDiffCallbacks can be initialised with a block. As there is no
1022
+ # "fininishing" to be done, this has no effect on the state of the object.
1023
+ #
1024
+ # cbo = Diff::LCS::SDiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) }
1025
+ #
1026
+ # === Simplified Array Format
1027
+ #
1028
+ # The simplified array format used in the example above can be obtained
1029
+ # with:
1030
+ #
1031
+ # require 'pp'
1032
+ # pp diffs.map { |e| e.to_a }
1033
+ #
1034
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:301
1035
+ class Diff::LCS::SDiffCallbacks
1036
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:305
1037
+ def initialize; end
1038
+
1039
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:322
1040
+ def change(event); end
1041
+
1042
+ # Returns the difference set collected during the diff process.
1043
+ #
1044
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:303
1045
+ def diffs; end
1046
+
1047
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:314
1048
+ def discard_a(event); end
1049
+
1050
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:318
1051
+ def discard_b(event); end
1052
+
1053
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:310
1054
+ def match(event); end
1055
+ end
1056
+
1057
+ # An alias for DefaultCallbacks that is used in
1058
+ # Diff::LCS#traverse_sequences.
1059
+ #
1060
+ # Diff::LCS.LCS(seq1, seq2, Diff::LCS::SequenceCallbacks)
1061
+ #
1062
+ # pkg:gem/diff-lcs#lib/diff/lcs/callbacks.rb:44
1063
+ Diff::LCS::SequenceCallbacks = Diff::LCS::DefaultCallbacks
1064
+
1065
+ # pkg:gem/diff-lcs#lib/diff/lcs.rb:52
1066
+ Diff::LCS::VERSION = T.let(T.unsafe(nil), String)
1067
+
1068
+ Integer::GMP_VERSION = T.let(T.unsafe(nil), String)