repeatable 1.0.0 → 1.2.0

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