cybrid_api_id_ruby 0.123.229 → 0.123.230
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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +5 -5
- data/cybrid_api_id_ruby.gemspec +1 -1
- data/lib/cybrid_api_id_ruby/api/bank_applications_idp_api.rb +1 -1
- data/lib/cybrid_api_id_ruby/api/customer_tokens_idp_api.rb +1 -1
- data/lib/cybrid_api_id_ruby/api/organization_applications_idp_api.rb +1 -1
- data/lib/cybrid_api_id_ruby/api/users_idp_api.rb +1 -1
- data/lib/cybrid_api_id_ruby/api_client.rb +1 -1
- data/lib/cybrid_api_id_ruby/api_error.rb +1 -1
- data/lib/cybrid_api_id_ruby/configuration.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/application_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/application_list_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/application_with_secret_all_of_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/application_with_secret_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/customer_token_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/error_response_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/post_bank_application_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/post_customer_token_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/post_organization_application_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/post_user_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/user_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/user_list_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/version.rb +2 -2
- data/lib/cybrid_api_id_ruby.rb +1 -1
- data/spec/api/bank_applications_idp_api_spec.rb +1 -1
- data/spec/api/customer_tokens_idp_api_spec.rb +1 -1
- data/spec/api/organization_applications_idp_api_spec.rb +1 -1
- data/spec/api/users_idp_api_spec.rb +1 -1
- data/spec/api_client_spec.rb +1 -1
- data/spec/configuration_spec.rb +1 -1
- data/spec/models/application_idp_model_spec.rb +1 -1
- data/spec/models/application_list_idp_model_spec.rb +1 -1
- data/spec/models/application_with_secret_all_of_idp_model_spec.rb +1 -1
- data/spec/models/application_with_secret_idp_model_spec.rb +1 -1
- data/spec/models/customer_token_idp_model_spec.rb +1 -1
- data/spec/models/error_response_idp_model_spec.rb +1 -1
- data/spec/models/post_bank_application_idp_model_spec.rb +1 -1
- data/spec/models/post_customer_token_idp_model_spec.rb +1 -1
- data/spec/models/post_organization_application_idp_model_spec.rb +1 -1
- data/spec/models/post_user_idp_model_spec.rb +1 -1
- data/spec/models/user_idp_model_spec.rb +1 -1
- data/spec/models/user_list_idp_model_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/vendor/bundle/ruby/3.3.0/cache/diff-lcs-1.6.0.gem +0 -0
- data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/byebug-11.1.3/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/date-3.4.1/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/jaro_winkler-1.5.6/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/psych-5.2.3/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/racc-1.8.1/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/stringio-3.1.2/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.6.0/CHANGELOG.md +491 -0
- data/vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.6.0/CODE_OF_CONDUCT.md +128 -0
- data/vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.6.0/CONTRIBUTING.md +74 -0
- data/vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.6.0/CONTRIBUTORS.md +48 -0
- data/vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.6.0/Contributing.md +74 -0
- data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/Manifest.txt +7 -4
- data/vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.6.0/README.md +92 -0
- data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/Rakefile +12 -44
- data/vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.6.0/SECURITY.md +41 -0
- data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/docs/artistic.txt +1 -1
- data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/lib/diff/lcs/change.rb +1 -1
- data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/lib/diff/lcs/htmldiff.rb +2 -0
- data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/lib/diff/lcs/hunk.rb +38 -22
- data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/lib/diff/lcs/ldiff.rb +60 -50
- data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/lib/diff/lcs.rb +10 -9
- data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/hunk_spec.rb +1 -1
- data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/issues_spec.rb +32 -32
- data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/ldiff_spec.rb +21 -10
- data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/patch_spec.rb +1 -1
- data/vendor/bundle/ruby/3.3.0/specifications/{diff-lcs-1.5.1.gemspec → diff-lcs-1.6.0.gemspec} +11 -10
- metadata +66 -63
- data/vendor/bundle/ruby/3.3.0/cache/diff-lcs-1.5.1.gem +0 -0
- data/vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/Code-of-Conduct.md +0 -74
- data/vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/Contributing.md +0 -121
- data/vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/History.md +0 -431
- data/vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/README.rdoc +0 -84
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/.rspec +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1/License.md → diff-lcs-1.6.0/LICENCE.md} +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/bin/htmldiff +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/bin/ldiff +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/docs/COPYING.txt +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/lib/diff/lcs/array.rb +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/lib/diff/lcs/backports.rb +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/lib/diff/lcs/block.rb +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/lib/diff/lcs/callbacks.rb +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/lib/diff/lcs/internals.rb +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/lib/diff/lcs/string.rb +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/lib/diff-lcs.rb +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/change_spec.rb +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/diff_spec.rb +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/aX +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/bXaX +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ds1.csv +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ds2.csv +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff-c +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff-e +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff-f +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff-u +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff.chef +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff.chef-c +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff.chef-e +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff.chef-f +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff.chef-u +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff.chef2 +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff.chef2-c +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff.chef2-d +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff.chef2-e +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff.chef2-f +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/ldiff/output.diff.chef2-u +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/new-chef +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/new-chef2 +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/old-chef +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/fixtures/old-chef2 +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/lcs_spec.rb +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/sdiff_spec.rb +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/spec_helper.rb +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/traverse_balanced_spec.rb +0 -0
- /data/vendor/bundle/ruby/3.3.0/gems/{diff-lcs-1.5.1 → diff-lcs-1.6.0}/spec/traverse_sequences_spec.rb +0 -0
@@ -22,11 +22,13 @@ class Diff::LCS::Hunk
|
|
22
22
|
end
|
23
23
|
|
24
24
|
if String.method_defined?(:encoding)
|
25
|
-
@preferred_data_encoding = data_old.fetch(0) { data_new.fetch(0
|
25
|
+
@preferred_data_encoding = data_old.fetch(0) { data_new.fetch(0) { "" } }.encoding
|
26
26
|
end
|
27
27
|
|
28
28
|
@data_old = data_old
|
29
29
|
@data_new = data_new
|
30
|
+
@old_empty = data_old.empty? || (data_old.size == 1 && data_old[0].empty?)
|
31
|
+
@new_empty = data_new.empty? || (data_new.size == 1 && data_new[0].empty?)
|
30
32
|
|
31
33
|
before = after = file_length_difference
|
32
34
|
after += @blocks[0].diff_size
|
@@ -79,14 +81,12 @@ class Diff::LCS::Hunk
|
|
79
81
|
old_size = @data_old.size
|
80
82
|
|
81
83
|
add_end =
|
82
|
-
if (@end_old + context)
|
83
|
-
old_size - @end_old
|
84
|
+
if (@end_old + context) >= old_size
|
85
|
+
old_size - @end_old - 1
|
84
86
|
else
|
85
87
|
context
|
86
88
|
end
|
87
89
|
|
88
|
-
add_end = @max_diff_size if add_end >= old_size
|
89
|
-
|
90
90
|
@end_old += add_end
|
91
91
|
@end_new += add_end
|
92
92
|
end
|
@@ -131,11 +131,16 @@ class Diff::LCS::Hunk
|
|
131
131
|
|
132
132
|
# Note that an old diff can't have any context. Therefore, we know that
|
133
133
|
# there's only one block in the hunk.
|
134
|
-
def old_diff(
|
134
|
+
def old_diff(last = false)
|
135
135
|
warn "Expecting only one block in an old diff hunk!" if @blocks.size > 1
|
136
136
|
|
137
137
|
block = @blocks[0]
|
138
138
|
|
139
|
+
if last
|
140
|
+
old_missing_newline = !@old_empty && missing_last_newline?(@data_old)
|
141
|
+
new_missing_newline = !@new_empty && missing_last_newline?(@data_new)
|
142
|
+
end
|
143
|
+
|
139
144
|
# Calculate item number range. Old diff range is just like a context
|
140
145
|
# diff range, except the ranges are on one line with the action between
|
141
146
|
# them.
|
@@ -146,19 +151,22 @@ class Diff::LCS::Hunk
|
|
146
151
|
@data_old[@start_old..@end_old].each { |e| s << encode("< ") + e.chomp + encode("\n") }
|
147
152
|
end
|
148
153
|
|
154
|
+
s << encode("\\n") if old_missing_newline && !new_missing_newline
|
149
155
|
s << encode("---\n") if block.op == "!"
|
150
156
|
|
151
157
|
unless block.insert.empty?
|
152
158
|
@data_new[@start_new..@end_new].each { |e| s << encode("> ") + e.chomp + encode("\n") }
|
153
159
|
end
|
154
160
|
|
161
|
+
s << encode("\\n") if new_missing_newline && !old_missing_newline
|
162
|
+
|
155
163
|
s
|
156
164
|
end
|
157
165
|
private :old_diff
|
158
166
|
|
159
167
|
def unified_diff(last = false)
|
160
168
|
# Calculate item number range.
|
161
|
-
s = encode("@@ -#{unified_range(:old
|
169
|
+
s = encode("@@ -#{unified_range(:old)} +#{unified_range(:new)} @@\n")
|
162
170
|
|
163
171
|
# Outlist starts containing the hunk of the old file. Removing an item
|
164
172
|
# just means putting a '-' in front of it. Inserting an item requires
|
@@ -178,8 +186,8 @@ class Diff::LCS::Hunk
|
|
178
186
|
last_block = blocks[-1]
|
179
187
|
|
180
188
|
if last
|
181
|
-
old_missing_newline = missing_last_newline?(@data_old)
|
182
|
-
new_missing_newline = missing_last_newline?(@data_new)
|
189
|
+
old_missing_newline = !@old_empty && missing_last_newline?(@data_old)
|
190
|
+
new_missing_newline = !@new_empty && missing_last_newline?(@data_new)
|
183
191
|
end
|
184
192
|
|
185
193
|
@blocks.each do |block|
|
@@ -213,8 +221,8 @@ class Diff::LCS::Hunk
|
|
213
221
|
|
214
222
|
def context_diff(last = false)
|
215
223
|
s = encode("***************\n")
|
216
|
-
s << encode("*** #{context_range(:old, ","
|
217
|
-
r = context_range(:new, ","
|
224
|
+
s << encode("*** #{context_range(:old, ",")} ****\n")
|
225
|
+
r = context_range(:new, ",")
|
218
226
|
|
219
227
|
if last
|
220
228
|
old_missing_newline = missing_last_newline?(@data_old)
|
@@ -273,14 +281,24 @@ class Diff::LCS::Hunk
|
|
273
281
|
end
|
274
282
|
private :context_diff
|
275
283
|
|
276
|
-
def ed_diff(format,
|
284
|
+
def ed_diff(format, last)
|
277
285
|
warn "Expecting only one block in an old diff hunk!" if @blocks.size > 1
|
286
|
+
if last
|
287
|
+
# ed script doesn't support well incomplete lines
|
288
|
+
warn "<old_file>: No newline at end of file\n" if !@old_empty && missing_last_newline?(@data_old)
|
289
|
+
warn "<new_file>: No newline at end of file\n" if !@new_empty && missing_last_newline?(@data_new)
|
290
|
+
|
291
|
+
if @blocks[0].op == "!"
|
292
|
+
return +"" if @blocks[0].changes[0].element == @blocks[0].changes[1].element + "\n"
|
293
|
+
return +"" if @blocks[0].changes[0].element + "\n" == @blocks[0].changes[1].element
|
294
|
+
end
|
295
|
+
end
|
278
296
|
|
279
297
|
s =
|
280
298
|
if format == :reverse_ed
|
281
|
-
encode("#{ED_DIFF_OP_ACTION[@blocks[0].op]}#{context_range(:old, "
|
299
|
+
encode("#{ED_DIFF_OP_ACTION[@blocks[0].op]}#{context_range(:old, " ")}\n")
|
282
300
|
else
|
283
|
-
encode("#{context_range(:old, "
|
301
|
+
encode("#{context_range(:old, ",")}#{ED_DIFF_OP_ACTION[@blocks[0].op]}\n")
|
284
302
|
end
|
285
303
|
|
286
304
|
unless @blocks[0].insert.empty?
|
@@ -295,7 +313,7 @@ class Diff::LCS::Hunk
|
|
295
313
|
|
296
314
|
# Generate a range of item numbers to print. Only print 1 number if the
|
297
315
|
# range has only one item in it. Otherwise, it's 'start,end'
|
298
|
-
def context_range(mode, op
|
316
|
+
def context_range(mode, op)
|
299
317
|
case mode
|
300
318
|
when :old
|
301
319
|
s, e = (@start_old + 1), (@end_old + 1)
|
@@ -303,9 +321,6 @@ class Diff::LCS::Hunk
|
|
303
321
|
s, e = (@start_new + 1), (@end_new + 1)
|
304
322
|
end
|
305
323
|
|
306
|
-
e -= 1 if last
|
307
|
-
e = 1 if e.zero?
|
308
|
-
|
309
324
|
(s < e) ? "#{s}#{op}#{e}" : e.to_s
|
310
325
|
end
|
311
326
|
private :context_range
|
@@ -313,18 +328,19 @@ class Diff::LCS::Hunk
|
|
313
328
|
# Generate a range of item numbers to print for unified diff. Print number
|
314
329
|
# where block starts, followed by number of lines in the block
|
315
330
|
# (don't print number of lines if it's 1)
|
316
|
-
def unified_range(mode
|
331
|
+
def unified_range(mode)
|
317
332
|
case mode
|
318
333
|
when :old
|
334
|
+
return "0,0" if @old_empty
|
319
335
|
s, e = (@start_old + 1), (@end_old + 1)
|
320
336
|
when :new
|
337
|
+
return "0,0" if @new_empty
|
321
338
|
s, e = (@start_new + 1), (@end_new + 1)
|
322
339
|
end
|
323
340
|
|
324
|
-
length = e - s +
|
341
|
+
length = e - s + 1
|
325
342
|
|
326
|
-
|
327
|
-
(length <= 1) ? first.to_s : "#{first},#{length}"
|
343
|
+
(length <= 1) ? e.to_s : "#{s},#{length}"
|
328
344
|
end
|
329
345
|
private :unified_range
|
330
346
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "optparse"
|
4
|
-
require "ostruct"
|
5
4
|
require "diff/lcs/hunk"
|
6
5
|
|
7
6
|
module Diff::LCS::Ldiff # :nodoc:
|
@@ -18,14 +17,20 @@ ldiff #{Diff::LCS::VERSION}
|
|
18
17
|
MIT licence.
|
19
18
|
COPYRIGHT
|
20
19
|
# standard:enable Layout/HeredocIndentation
|
21
|
-
end
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
InputInfo = Struct.new(:filename, :data, :stat) do
|
22
|
+
def initialize(filename)
|
23
|
+
super(filename, ::File.read(filename), ::File.stat(filename))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class << self
|
28
|
+
attr_reader :format, :lines # :nodoc:
|
29
|
+
attr_reader :file_old, :file_new # :nodoc:
|
30
|
+
attr_reader :data_old, :data_new # :nodoc:
|
31
|
+
end
|
27
32
|
|
28
|
-
def run(args, _input = $stdin, output = $stdout, error = $stderr) # :nodoc:
|
33
|
+
def self.run(args, _input = $stdin, output = $stdout, error = $stderr) # :nodoc:
|
29
34
|
@binary = nil
|
30
35
|
|
31
36
|
args.options do |o|
|
@@ -86,8 +91,18 @@ class << Diff::LCS::Ldiff
|
|
86
91
|
@lines ||= 0
|
87
92
|
|
88
93
|
file_old, file_new = *ARGV
|
94
|
+
diff?(
|
95
|
+
InputInfo.new(file_old),
|
96
|
+
InputInfo.new(file_new),
|
97
|
+
@format,
|
98
|
+
output,
|
99
|
+
binary: @binary,
|
100
|
+
lines: @lines
|
101
|
+
) ? 1 : 0
|
102
|
+
end
|
89
103
|
|
90
|
-
|
104
|
+
def self.diff?(info_old, info_new, format, output, binary: nil, lines: 0)
|
105
|
+
case format
|
91
106
|
when :context
|
92
107
|
char_old = "*" * 3
|
93
108
|
char_new = "-" * 3
|
@@ -100,74 +115,69 @@ class << Diff::LCS::Ldiff
|
|
100
115
|
# items we've read from each file will differ by FLD (could be 0).
|
101
116
|
file_length_difference = 0
|
102
117
|
|
103
|
-
data_old = File.read(file_old)
|
104
|
-
data_new = File.read(file_new)
|
105
|
-
|
106
118
|
# Test binary status
|
107
|
-
if
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
unless @binary
|
114
|
-
data_old = data_old.lines.to_a
|
115
|
-
data_new = data_new.lines.to_a
|
119
|
+
if binary.nil?
|
120
|
+
old_bin = info_old.data[0, 4096].include?("\0")
|
121
|
+
new_bin = info_new.data[0, 4096].include?("\0")
|
122
|
+
binary = old_bin || new_bin
|
116
123
|
end
|
117
124
|
|
118
125
|
# diff yields lots of pieces, each of which is basically a Block object
|
119
|
-
if
|
120
|
-
|
126
|
+
if binary
|
127
|
+
has_diffs = (info_old.data != info_new.data)
|
128
|
+
if format != :report
|
129
|
+
if has_diffs
|
130
|
+
output << "Binary files #{info_old.filename} and #{info_new.filename} differ\n"
|
131
|
+
return true
|
132
|
+
end
|
133
|
+
return false
|
134
|
+
end
|
121
135
|
else
|
136
|
+
data_old = info_old.data.lines.to_a
|
137
|
+
data_new = info_new.data.lines.to_a
|
122
138
|
diffs = Diff::LCS.diff(data_old, data_new)
|
123
|
-
|
139
|
+
return false if diffs.empty?
|
124
140
|
end
|
125
141
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
output
|
142
|
+
case format
|
143
|
+
when :report
|
144
|
+
output << "Files #{info_old.filename} and #{info_new.filename} differ\n"
|
145
|
+
return true
|
146
|
+
when :unified, :context
|
147
|
+
ft = info_old.stat.mtime.localtime.strftime("%Y-%m-%d %H:%M:%S.000000000 %z")
|
148
|
+
output << "#{char_old} #{info_old.filename}\t#{ft}\n"
|
149
|
+
ft = info_new.stat.mtime.localtime.strftime("%Y-%m-%d %H:%M:%S.000000000 %z")
|
150
|
+
output << "#{char_new} #{info_new.filename}\t#{ft}\n"
|
151
|
+
when :ed
|
152
|
+
real_output = output
|
153
|
+
output = []
|
138
154
|
end
|
139
155
|
|
140
156
|
# Loop over hunks. If a hunk overlaps with the last hunk, join them.
|
141
157
|
# Otherwise, print out the old one.
|
142
158
|
oldhunk = hunk = nil
|
143
|
-
|
144
|
-
if @format == :ed
|
145
|
-
real_output = output
|
146
|
-
output = []
|
147
|
-
end
|
148
|
-
|
149
159
|
diffs.each do |piece|
|
150
|
-
begin
|
151
|
-
hunk = Diff::LCS::Hunk.new(data_old, data_new, piece,
|
160
|
+
begin
|
161
|
+
hunk = Diff::LCS::Hunk.new(data_old, data_new, piece, lines, file_length_difference)
|
152
162
|
file_length_difference = hunk.file_length_difference
|
153
163
|
|
154
164
|
next unless oldhunk
|
155
|
-
next if
|
165
|
+
next if lines.positive? && hunk.merge(oldhunk)
|
156
166
|
|
157
|
-
output << oldhunk.diff(
|
158
|
-
output << "\n" if
|
167
|
+
output << oldhunk.diff(format)
|
168
|
+
output << "\n" if format == :unified
|
159
169
|
ensure
|
160
170
|
oldhunk = hunk
|
161
171
|
end
|
162
172
|
end
|
163
173
|
|
164
|
-
last = oldhunk.diff(
|
165
|
-
last << "\n"
|
174
|
+
last = oldhunk.diff(format, true)
|
175
|
+
last << "\n" unless last.is_a?(Diff::LCS::Hunk) || last.empty? || last.end_with?("\n")
|
166
176
|
|
167
177
|
output << last
|
168
178
|
|
169
|
-
output.reverse_each { |e| real_output << e.diff(:ed_finish) } if
|
179
|
+
output.reverse_each { |e| real_output << e.diff(:ed_finish, e == output[0]) } if format == :ed
|
170
180
|
|
171
|
-
|
181
|
+
true
|
172
182
|
end
|
173
183
|
end
|
@@ -49,7 +49,7 @@ module Diff; end unless defined? Diff
|
|
49
49
|
# a x b y c z p d q
|
50
50
|
# a b c a x b y c z
|
51
51
|
module Diff::LCS
|
52
|
-
VERSION = "1.
|
52
|
+
VERSION = "1.6.0"
|
53
53
|
end
|
54
54
|
|
55
55
|
require "diff/lcs/callbacks"
|
@@ -62,11 +62,12 @@ module Diff::LCS
|
|
62
62
|
# lcs = seq1.lcs(seq2)
|
63
63
|
#
|
64
64
|
# A note when using objects: Diff::LCS only works properly when each object
|
65
|
-
# can be used as a key in a Hash
|
66
|
-
#
|
67
|
-
# identically for key purposes. That is:
|
65
|
+
# can be used as a key in a Hash. This means that those objects must implement
|
66
|
+
# the methods +#hash+ and +#eql?+ such that two objects containing identical values
|
67
|
+
# compare identically for key purposes. That is:
|
68
68
|
#
|
69
|
-
# O.new('a').eql?(O.new('a')) == true
|
69
|
+
# O.new('a').eql?(O.new('a')) == true &&
|
70
|
+
# O.new('a').hash == O.new('a').hash
|
70
71
|
def lcs(other, &block) # :yields: self[i] if there are matched subsequences
|
71
72
|
Diff::LCS.lcs(self, other, &block)
|
72
73
|
end
|
@@ -256,7 +257,7 @@ class << Diff::LCS
|
|
256
257
|
#
|
257
258
|
# The methods for <tt>callbacks#match</tt>, <tt>callbacks#discard_a</tt>, and
|
258
259
|
# <tt>callbacks#discard_b</tt> are invoked with an event comprising the
|
259
|
-
# action ("=", "+", or "-", respectively), the
|
260
|
+
# action ("=", "+", or "-", respectively), the indexes +i+ and +j+, and the
|
260
261
|
# elements <tt>A[i]</tt> and <tt>B[j]</tt>. Return values are discarded by
|
261
262
|
# #traverse_sequences.
|
262
263
|
#
|
@@ -421,7 +422,7 @@ class << Diff::LCS
|
|
421
422
|
# occurred.
|
422
423
|
#
|
423
424
|
# #traverse_balanced might be a bit slower than #traverse_sequences,
|
424
|
-
#
|
425
|
+
# noticeable only while processing huge amounts of data.
|
425
426
|
#
|
426
427
|
# == Algorithm
|
427
428
|
#
|
@@ -465,7 +466,7 @@ class << Diff::LCS
|
|
465
466
|
# The methods for <tt>callbacks#match</tt>, <tt>callbacks#discard_a</tt>,
|
466
467
|
# <tt>callbacks#discard_b</tt>, and <tt>callbacks#change</tt> are invoked
|
467
468
|
# with an event comprising the action ("=", "+", "-", or "!", respectively),
|
468
|
-
# the
|
469
|
+
# the indexes +i+ and +j+, and the elements <tt>A[i]</tt> and <tt>B[j]</tt>.
|
469
470
|
# Return values are discarded by #traverse_balanced.
|
470
471
|
#
|
471
472
|
# === Context
|
@@ -482,7 +483,7 @@ class << Diff::LCS
|
|
482
483
|
|
483
484
|
# Process all the lines in the match vector.
|
484
485
|
loop do
|
485
|
-
# Find next match
|
486
|
+
# Find next match indexes +ma+ and +mb+
|
486
487
|
loop do
|
487
488
|
ma += 1
|
488
489
|
break unless ma < matches.size && matches[ma].nil?
|
@@ -68,38 +68,6 @@ describe "Diff::LCS Issues" do
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
describe "issue #60" do
|
72
|
-
it "should produce unified output with correct context" do
|
73
|
-
# standard:disable Layout/HeredocIndentation
|
74
|
-
old_data = <<-DATA_OLD.strip.split("\n").map(&:chomp)
|
75
|
-
{
|
76
|
-
"name": "x",
|
77
|
-
"description": "hi"
|
78
|
-
}
|
79
|
-
DATA_OLD
|
80
|
-
|
81
|
-
new_data = <<-DATA_NEW.strip.split("\n").map(&:chomp)
|
82
|
-
{
|
83
|
-
"name": "x",
|
84
|
-
"description": "lo"
|
85
|
-
}
|
86
|
-
DATA_NEW
|
87
|
-
|
88
|
-
diff = ::Diff::LCS.diff(old_data, new_data)
|
89
|
-
hunk = ::Diff::LCS::Hunk.new(old_data, new_data, diff.first, 3, 0)
|
90
|
-
|
91
|
-
expect(hunk.diff(:unified)).to eq(<<-EXPECTED.chomp)
|
92
|
-
@@ -1,5 +1,5 @@
|
93
|
-
{
|
94
|
-
"name": "x",
|
95
|
-
- "description": "hi"
|
96
|
-
+ "description": "lo"
|
97
|
-
}
|
98
|
-
EXPECTED
|
99
|
-
# standard:enable Layout/HeredocIndentation
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
71
|
describe "issue #65" do
|
104
72
|
def diff_lines(old_lines, new_lines)
|
105
73
|
file_length_difference = 0
|
@@ -157,4 +125,36 @@ describe "Diff::LCS Issues" do
|
|
157
125
|
# standard:enable Layout/HeredocIndentation
|
158
126
|
end
|
159
127
|
end
|
128
|
+
|
129
|
+
describe "issue #107 (replaces issue #60)" do
|
130
|
+
it "should produce unified output with correct context" do
|
131
|
+
# standard:disable Layout/HeredocIndentation
|
132
|
+
old_data = <<-DATA_OLD.strip.split("\n").map(&:chomp)
|
133
|
+
{
|
134
|
+
"name": "x",
|
135
|
+
"description": "hi"
|
136
|
+
}
|
137
|
+
DATA_OLD
|
138
|
+
|
139
|
+
new_data = <<-DATA_NEW.strip.split("\n").map(&:chomp)
|
140
|
+
{
|
141
|
+
"name": "x",
|
142
|
+
"description": "lo"
|
143
|
+
}
|
144
|
+
DATA_NEW
|
145
|
+
|
146
|
+
diff = ::Diff::LCS.diff(old_data, new_data)
|
147
|
+
hunk = ::Diff::LCS::Hunk.new(old_data, new_data, diff.first, 3, 0)
|
148
|
+
|
149
|
+
expect(hunk.diff(:unified)).to eq(<<-EXPECTED.chomp)
|
150
|
+
@@ -1,4 +1,4 @@
|
151
|
+
{
|
152
|
+
"name": "x",
|
153
|
+
- "description": "hi"
|
154
|
+
+ "description": "lo"
|
155
|
+
}
|
156
|
+
EXPECTED
|
157
|
+
# standard:enable Layout/HeredocIndentation
|
158
|
+
end
|
159
|
+
end
|
160
160
|
end
|
@@ -7,9 +7,16 @@ RSpec.describe "bin/ldiff" do
|
|
7
7
|
|
8
8
|
# standard:disable Style/HashSyntax
|
9
9
|
fixtures = [
|
10
|
-
{:name => "
|
11
|
-
{:name => "
|
12
|
-
{:name => "
|
10
|
+
{:name => "diff", :left => "aX", :right => "bXaX", :diff => 1},
|
11
|
+
{:name => "diff.missing_new_line1", :left => "four_lines", :right => "four_lines_with_missing_new_line", :diff => 1},
|
12
|
+
{:name => "diff.missing_new_line2", :left => "four_lines_with_missing_new_line", :right => "four_lines", :diff => 1},
|
13
|
+
{:name => "diff.issue95_trailing_context", :left => "123_x", :right => "456_x", :diff => 1},
|
14
|
+
{:name => "diff.four_lines.vs.empty", :left => "four_lines", :right => "empty", :diff => 1},
|
15
|
+
{:name => "diff.empty.vs.four_lines", :left => "empty", :right => "four_lines", :diff => 1},
|
16
|
+
{:name => "diff.bin1", :left => "file1.bin", :right => "file1.bin", :diff => 0},
|
17
|
+
{:name => "diff.bin2", :left => "file1.bin", :right => "file2.bin", :diff => 1},
|
18
|
+
{:name => "diff.chef", :left => "old-chef", :right => "new-chef", :diff => 1},
|
19
|
+
{:name => "diff.chef2", :left => "old-chef2", :right => "new-chef2", :diff => 1}
|
13
20
|
].product([nil, "-e", "-f", "-c", "-u"]).map { |(fixture, flag)|
|
14
21
|
fixture = fixture.dup
|
15
22
|
fixture[:flag] = flag
|
@@ -24,11 +31,14 @@ RSpec.describe "bin/ldiff" do
|
|
24
31
|
"spec/fixtures/#{fixture[:right]}",
|
25
32
|
"#",
|
26
33
|
"=>",
|
27
|
-
"spec/fixtures/ldiff
|
34
|
+
"spec/fixtures/ldiff/output.#{fixture[:name]}#{fixture[:flag]}"
|
28
35
|
].join(" ")
|
29
36
|
|
30
37
|
it desc do
|
31
|
-
|
38
|
+
stdout, stderr, status = run_ldiff(fixture)
|
39
|
+
expect(status).to eq(fixture[:diff])
|
40
|
+
expect(stderr).to eq(read_fixture(fixture, mode: "error", allow_missing: true))
|
41
|
+
expect(stdout).to eq(read_fixture(fixture, mode: "output", allow_missing: false))
|
32
42
|
end
|
33
43
|
end
|
34
44
|
|
@@ -36,10 +46,13 @@ RSpec.describe "bin/ldiff" do
|
|
36
46
|
test_ldiff(fixture)
|
37
47
|
end
|
38
48
|
|
39
|
-
def read_fixture(options)
|
49
|
+
def read_fixture(options, mode: "output", allow_missing: false)
|
40
50
|
fixture = options.fetch(:name)
|
41
51
|
flag = options.fetch(:flag)
|
42
|
-
name = "spec/fixtures/ldiff/#{fixture}#{flag}"
|
52
|
+
name = "spec/fixtures/ldiff/#{mode}.#{fixture}#{flag}"
|
53
|
+
|
54
|
+
return "" if !::File.exist?(name) && allow_missing
|
55
|
+
|
43
56
|
data = IO.__send__(IO.respond_to?(:binread) ? :binread : :read, name)
|
44
57
|
clean_data(data, flag)
|
45
58
|
end
|
@@ -82,8 +95,6 @@ RSpec.describe "bin/ldiff" do
|
|
82
95
|
system("ruby -Ilib bin/ldiff #{flag} spec/fixtures/#{left} spec/fixtures/#{right}")
|
83
96
|
end
|
84
97
|
|
85
|
-
|
86
|
-
expect(stdout).not_to be_empty
|
87
|
-
clean_data(stdout, flag)
|
98
|
+
[clean_data(stdout, flag), stderr, $?.exitstatus]
|
88
99
|
end
|
89
100
|
end
|
@@ -181,7 +181,7 @@ describe "Diff::LCS.patch" do
|
|
181
181
|
# above.
|
182
182
|
describe "fix bug 891: patchsets do not contain the last equal part" do
|
183
183
|
before :each do
|
184
|
-
@s1 = %w[a b c d e f g h i j k] #
|
184
|
+
@s1 = %w[a b c d e f g h i j k] # standard:disable Layout/SpaceInsideArrayPercentLiteral
|
185
185
|
@s2 = %w[a b c d D e f g h i j k]
|
186
186
|
end
|
187
187
|
|
data/vendor/bundle/ruby/3.3.0/specifications/{diff-lcs-1.5.1.gemspec → diff-lcs-1.6.0.gemspec}
RENAMED
@@ -1,25 +1,25 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: diff-lcs 1.
|
2
|
+
# stub: diff-lcs 1.6.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "diff-lcs".freeze
|
6
|
-
s.version = "1.
|
6
|
+
s.version = "1.6.0".freeze
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
|
-
s.metadata = { "
|
9
|
+
s.metadata = { "changelog_uri" => "https://github.com/halostatue/diff-lcs/blob/main/CHANGELOG.md", "rubygems_mfa_required" => "true" } if s.respond_to? :metadata=
|
10
10
|
s.require_paths = ["lib".freeze]
|
11
11
|
s.authors = ["Austin Ziegler".freeze]
|
12
|
-
s.date = "
|
13
|
-
s.description = "Diff::LCS computes the difference between two Enumerable sequences using the\nMcIlroy-Hunt longest common subsequence (LCS) algorithm. It includes utilities\nto create a simple HTML diff output format and a standard diff-like tool.\n\nThis is release 1.4.3, providing a simple extension that allows for\nDiff::LCS::Change objects to be treated implicitly as arrays and fixes a\
|
12
|
+
s.date = "2025-02-13"
|
13
|
+
s.description = "Diff::LCS computes the difference between two Enumerable sequences using the\nMcIlroy-Hunt longest common subsequence (LCS) algorithm. It includes utilities\nto create a simple HTML diff output format and a standard diff-like tool.\n\nThis is release 1.4.3, providing a simple extension that allows for\nDiff::LCS::Change objects to be treated implicitly as arrays and fixes a number\nof formatting issues.\n\nRuby versions below 2.5 are soft-deprecated, which means that older versions are\nno longer part of the CI test suite. If any changes have been introduced that\nbreak those versions, bug reports and patches will be accepted, but it will be\nup to the reporter to verify any fixes prior to release. The next major release\nwill completely break compatibility.".freeze
|
14
14
|
s.email = ["halostatue@gmail.com".freeze]
|
15
15
|
s.executables = ["htmldiff".freeze, "ldiff".freeze]
|
16
|
-
s.extra_rdoc_files = ["
|
17
|
-
s.files = ["
|
16
|
+
s.extra_rdoc_files = ["CHANGELOG.md".freeze, "CODE_OF_CONDUCT.md".freeze, "CONTRIBUTING.md".freeze, "CONTRIBUTORS.md".freeze, "Contributing.md".freeze, "LICENCE.md".freeze, "Manifest.txt".freeze, "README.md".freeze, "SECURITY.md".freeze, "docs/COPYING.txt".freeze, "docs/artistic.txt".freeze]
|
17
|
+
s.files = ["CHANGELOG.md".freeze, "CODE_OF_CONDUCT.md".freeze, "CONTRIBUTING.md".freeze, "CONTRIBUTORS.md".freeze, "Contributing.md".freeze, "LICENCE.md".freeze, "Manifest.txt".freeze, "README.md".freeze, "SECURITY.md".freeze, "bin/htmldiff".freeze, "bin/ldiff".freeze, "docs/COPYING.txt".freeze, "docs/artistic.txt".freeze]
|
18
18
|
s.homepage = "https://github.com/halostatue/diff-lcs".freeze
|
19
|
-
s.licenses = ["MIT".freeze, "Artistic-
|
20
|
-
s.rdoc_options = ["--main".freeze, "README.
|
19
|
+
s.licenses = ["MIT".freeze, "Artistic-1.0-Perl".freeze, "GPL-2.0-or-later".freeze]
|
20
|
+
s.rdoc_options = ["--main".freeze, "README.md".freeze]
|
21
21
|
s.required_ruby_version = Gem::Requirement.new(">= 1.8".freeze)
|
22
|
-
s.rubygems_version = "3.5.
|
22
|
+
s.rubygems_version = "3.5.22".freeze
|
23
23
|
s.summary = "Diff::LCS computes the difference between two Enumerable sequences using the McIlroy-Hunt longest common subsequence (LCS) algorithm".freeze
|
24
24
|
|
25
25
|
s.installed_by_version = "3.5.23".freeze
|
@@ -34,4 +34,5 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.add_development_dependency(%q<rspec>.freeze, [">= 2.0".freeze, "< 4".freeze])
|
35
35
|
s.add_development_dependency(%q<rake>.freeze, [">= 10.0".freeze, "< 14".freeze])
|
36
36
|
s.add_development_dependency(%q<rdoc>.freeze, [">= 6.3.1".freeze, "< 7".freeze])
|
37
|
+
s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.21".freeze])
|
37
38
|
end
|