model-to-schema 0.1.0

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