packwerk 2.2.0 → 2.2.1

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