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