roast-ai 0.4.4 → 0.4.5

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.
Files changed (231) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +2 -0
  3. data/.github/workflows/ci.yaml +1 -0
  4. data/.gitignore +0 -26
  5. data/.rubocop.yml +13 -0
  6. data/.rubocop_todo.yml +21 -0
  7. data/CHANGELOG.md +29 -0
  8. data/Gemfile +4 -0
  9. data/Gemfile.lock +43 -1
  10. data/bin/rubocop +27 -0
  11. data/bin/spoom +27 -0
  12. data/bin/srb +27 -0
  13. data/bin/srb-rbi +27 -0
  14. data/bin/tapioca +27 -0
  15. data/docs/INSTRUMENTATION.md +3 -3
  16. data/dsl/simple.rb +10 -0
  17. data/lib/roast/dsl/executor.rb +26 -0
  18. data/lib/roast/dsl.rb +7 -0
  19. data/lib/roast/errors.rb +1 -0
  20. data/lib/roast/factories/api_provider_factory.rb +1 -0
  21. data/lib/roast/helpers/function_caching_interceptor.rb +3 -0
  22. data/lib/roast/helpers/logger.rb +6 -9
  23. data/lib/roast/helpers/metadata_access.rb +1 -0
  24. data/lib/roast/helpers/minitest_coverage_runner.rb +1 -0
  25. data/lib/roast/helpers/path_resolver.rb +8 -18
  26. data/lib/roast/helpers/prompt_loader.rb +3 -2
  27. data/lib/roast/helpers/timeout_handler.rb +3 -5
  28. data/lib/roast/initializers.rb +1 -0
  29. data/lib/roast/resources/api_resource.rb +4 -3
  30. data/lib/roast/resources/base_resource.rb +1 -0
  31. data/lib/roast/resources/directory_resource.rb +1 -0
  32. data/lib/roast/resources/file_resource.rb +1 -0
  33. data/lib/roast/resources/none_resource.rb +1 -0
  34. data/lib/roast/resources/url_resource.rb +2 -1
  35. data/lib/roast/resources.rb +1 -2
  36. data/lib/roast/services/context_threshold_checker.rb +1 -0
  37. data/lib/roast/services/token_counting_service.rb +1 -0
  38. data/lib/roast/tools/apply_diff.rb +1 -0
  39. data/lib/roast/tools/ask_user.rb +1 -0
  40. data/lib/roast/tools/bash.rb +1 -0
  41. data/lib/roast/tools/cmd.rb +1 -0
  42. data/lib/roast/tools/coding_agent.rb +1 -0
  43. data/lib/roast/tools/context_summarizer.rb +1 -0
  44. data/lib/roast/tools/grep.rb +1 -0
  45. data/lib/roast/tools/helpers/coding_agent_message_formatter.rb +1 -0
  46. data/lib/roast/tools/read_file.rb +1 -0
  47. data/lib/roast/tools/search_file.rb +1 -0
  48. data/lib/roast/tools/swarm.rb +1 -0
  49. data/lib/roast/tools/update_files.rb +1 -0
  50. data/lib/roast/tools/write_file.rb +1 -0
  51. data/lib/roast/tools.rb +2 -0
  52. data/lib/roast/value_objects/api_token.rb +1 -0
  53. data/lib/roast/value_objects/step_name.rb +1 -0
  54. data/lib/roast/value_objects/uri_base.rb +1 -0
  55. data/lib/roast/value_objects/workflow_path.rb +1 -0
  56. data/lib/roast/value_objects.rb +1 -0
  57. data/lib/roast/version.rb +2 -1
  58. data/lib/roast/workflow/agent_step.rb +1 -0
  59. data/lib/roast/workflow/api_configuration.rb +1 -0
  60. data/lib/roast/workflow/base_iteration_step.rb +1 -0
  61. data/lib/roast/workflow/base_step.rb +1 -0
  62. data/lib/roast/workflow/base_workflow.rb +1 -0
  63. data/lib/roast/workflow/case_executor.rb +1 -0
  64. data/lib/roast/workflow/case_step.rb +1 -0
  65. data/lib/roast/workflow/command_executor.rb +1 -0
  66. data/lib/roast/workflow/conditional_executor.rb +1 -0
  67. data/lib/roast/workflow/conditional_step.rb +1 -0
  68. data/lib/roast/workflow/configuration.rb +9 -0
  69. data/lib/roast/workflow/configuration_loader.rb +4 -1
  70. data/lib/roast/workflow/context_manager.rb +1 -0
  71. data/lib/roast/workflow/context_path_resolver.rb +1 -0
  72. data/lib/roast/workflow/dot_access_hash.rb +1 -0
  73. data/lib/roast/workflow/each_step.rb +1 -0
  74. data/lib/roast/workflow/error_handler.rb +7 -1
  75. data/lib/roast/workflow/expression_evaluator.rb +1 -0
  76. data/lib/roast/workflow/expression_utils.rb +1 -0
  77. data/lib/roast/workflow/file_state_repository.rb +2 -1
  78. data/lib/roast/workflow/input_executor.rb +1 -0
  79. data/lib/roast/workflow/input_step.rb +1 -0
  80. data/lib/roast/workflow/interpolator.rb +2 -1
  81. data/lib/roast/workflow/iteration_executor.rb +1 -0
  82. data/lib/roast/workflow/llm_boolean_coercer.rb +1 -0
  83. data/lib/roast/workflow/metadata_manager.rb +1 -0
  84. data/lib/roast/workflow/output_handler.rb +1 -0
  85. data/lib/roast/workflow/output_manager.rb +1 -0
  86. data/lib/roast/workflow/parallel_executor.rb +1 -0
  87. data/lib/roast/workflow/prompt_step.rb +1 -0
  88. data/lib/roast/workflow/repeat_step.rb +1 -0
  89. data/lib/roast/workflow/replay_handler.rb +1 -0
  90. data/lib/roast/workflow/resource_resolver.rb +2 -6
  91. data/lib/roast/workflow/session_manager.rb +1 -0
  92. data/lib/roast/workflow/shell_script_step.rb +1 -0
  93. data/lib/roast/workflow/sqlite_state_repository.rb +1 -0
  94. data/lib/roast/workflow/state_manager.rb +1 -0
  95. data/lib/roast/workflow/state_repository.rb +1 -0
  96. data/lib/roast/workflow/state_repository_factory.rb +4 -2
  97. data/lib/roast/workflow/step_completion_reporter.rb +1 -0
  98. data/lib/roast/workflow/step_executor_coordinator.rb +9 -5
  99. data/lib/roast/workflow/step_executor_factory.rb +1 -0
  100. data/lib/roast/workflow/step_executor_registry.rb +2 -3
  101. data/lib/roast/workflow/step_executor_with_reporting.rb +1 -0
  102. data/lib/roast/workflow/step_executors/base_step_executor.rb +1 -0
  103. data/lib/roast/workflow/step_executors/hash_step_executor.rb +1 -0
  104. data/lib/roast/workflow/step_executors/parallel_step_executor.rb +1 -0
  105. data/lib/roast/workflow/step_executors/string_step_executor.rb +1 -0
  106. data/lib/roast/workflow/step_factory.rb +1 -0
  107. data/lib/roast/workflow/step_finder.rb +1 -0
  108. data/lib/roast/workflow/step_loader.rb +1 -0
  109. data/lib/roast/workflow/step_name_extractor.rb +1 -0
  110. data/lib/roast/workflow/step_runner.rb +1 -0
  111. data/lib/roast/workflow/step_type_resolver.rb +1 -0
  112. data/lib/roast/workflow/validation_command.rb +1 -0
  113. data/lib/roast/workflow/validator.rb +1 -0
  114. data/lib/roast/workflow/validators/base_validator.rb +1 -0
  115. data/lib/roast/workflow/validators/dependency_validator.rb +1 -0
  116. data/lib/roast/workflow/validators/linting_validator.rb +1 -0
  117. data/lib/roast/workflow/validators/schema_validator.rb +1 -0
  118. data/lib/roast/workflow/validators/step_collector.rb +1 -0
  119. data/lib/roast/workflow/validators/validation_orchestrator.rb +1 -0
  120. data/lib/roast/workflow/workflow_context.rb +1 -0
  121. data/lib/roast/workflow/workflow_execution_context.rb +1 -0
  122. data/lib/roast/workflow/workflow_executor.rb +2 -1
  123. data/lib/roast/workflow/workflow_initializer.rb +1 -0
  124. data/lib/roast/workflow/workflow_runner.rb +66 -55
  125. data/lib/roast/workflow.rb +1 -0
  126. data/lib/roast/workflow_diagram_generator.rb +3 -2
  127. data/lib/roast.rb +23 -8
  128. data/sorbet/config +8 -0
  129. data/sorbet/rbi/dsl/.gitattributes +1 -0
  130. data/sorbet/rbi/dsl/active_support/callbacks.rbi +21 -0
  131. data/sorbet/rbi/gems/.gitattributes +1 -0
  132. data/sorbet/rbi/gems/activesupport@8.0.2.rbi +19107 -0
  133. data/sorbet/rbi/gems/addressable@2.8.7.rbi +1994 -0
  134. data/sorbet/rbi/gems/ast@2.4.3.rbi +585 -0
  135. data/sorbet/rbi/gems/base64@0.3.0.rbi +545 -0
  136. data/sorbet/rbi/gems/benchmark@0.4.1.rbi +619 -0
  137. data/sorbet/rbi/gems/bigdecimal@3.2.2.rbi +62 -0
  138. data/sorbet/rbi/gems/cgi@0.5.0.rbi +2961 -0
  139. data/sorbet/rbi/gems/claude_swarm@0.1.19.rbi +568 -0
  140. data/sorbet/rbi/gems/cli-kit@5.0.1.rbi +1991 -0
  141. data/sorbet/rbi/gems/cli-ui@2.3.0.rbi +3181 -0
  142. data/sorbet/rbi/gems/coderay@1.1.3.rbi +9 -0
  143. data/sorbet/rbi/gems/concurrent-ruby@1.3.5.rbi +11657 -0
  144. data/sorbet/rbi/gems/connection_pool@2.5.3.rbi +9 -0
  145. data/sorbet/rbi/gems/crack@1.0.0.rbi +145 -0
  146. data/sorbet/rbi/gems/diff-lcs@1.6.2.rbi +972 -0
  147. data/sorbet/rbi/gems/dotenv@3.1.8.rbi +295 -0
  148. data/sorbet/rbi/gems/drb@2.2.3.rbi +1661 -0
  149. data/sorbet/rbi/gems/dry-configurable@1.3.0.rbi +672 -0
  150. data/sorbet/rbi/gems/dry-core@1.1.0.rbi +1894 -0
  151. data/sorbet/rbi/gems/dry-inflector@1.2.0.rbi +659 -0
  152. data/sorbet/rbi/gems/dry-initializer@3.2.0.rbi +781 -0
  153. data/sorbet/rbi/gems/dry-logic@1.6.0.rbi +1127 -0
  154. data/sorbet/rbi/gems/dry-schema@1.14.1.rbi +3727 -0
  155. data/sorbet/rbi/gems/dry-types@1.8.3.rbi +3969 -0
  156. data/sorbet/rbi/gems/erubi@1.13.1.rbi +155 -0
  157. data/sorbet/rbi/gems/event_stream_parser@1.0.0.rbi +49 -0
  158. data/sorbet/rbi/gems/faraday-multipart@1.1.1.rbi +283 -0
  159. data/sorbet/rbi/gems/faraday-net_http@3.4.1.rbi +147 -0
  160. data/sorbet/rbi/gems/faraday-retry@2.3.2.rbi +9 -0
  161. data/sorbet/rbi/gems/faraday@2.13.1.rbi +2977 -0
  162. data/sorbet/rbi/gems/fast-mcp-annotations@1.5.3.rbi +1588 -0
  163. data/sorbet/rbi/gems/ffi@1.17.2.rbi +9 -0
  164. data/sorbet/rbi/gems/formatador@1.1.0.rbi +9 -0
  165. data/sorbet/rbi/gems/guard-compat@1.2.1.rbi +102 -0
  166. data/sorbet/rbi/gems/guard-minitest@2.4.6.rbi +402 -0
  167. data/sorbet/rbi/gems/guard@2.19.1.rbi +2283 -0
  168. data/sorbet/rbi/gems/hashdiff@1.2.0.rbi +355 -0
  169. data/sorbet/rbi/gems/i18n@1.14.7.rbi +2359 -0
  170. data/sorbet/rbi/gems/json-schema@5.1.1.rbi +1466 -0
  171. data/sorbet/rbi/gems/json@2.12.2.rbi +2051 -0
  172. data/sorbet/rbi/gems/language_server-protocol@3.17.0.5.rbi +9 -0
  173. data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +9 -0
  174. data/sorbet/rbi/gems/listen@3.9.0.rbi +1206 -0
  175. data/sorbet/rbi/gems/logger@1.7.0.rbi +963 -0
  176. data/sorbet/rbi/gems/lumberjack@1.2.10.rbi +1830 -0
  177. data/sorbet/rbi/gems/method_source@1.1.0.rbi +9 -0
  178. data/sorbet/rbi/gems/mime-types-data@3.2025.0617.rbi +136 -0
  179. data/sorbet/rbi/gems/mime-types@3.7.0.rbi +1342 -0
  180. data/sorbet/rbi/gems/minitest-rg@5.3.0.rbi +160 -0
  181. data/sorbet/rbi/gems/minitest@5.25.5.rbi +1640 -0
  182. data/sorbet/rbi/gems/mocha@2.7.1.rbi +12 -0
  183. data/sorbet/rbi/gems/multipart-post@2.4.1.rbi +244 -0
  184. data/sorbet/rbi/gems/nenv@0.3.0.rbi +147 -0
  185. data/sorbet/rbi/gems/net-http@0.6.0.rbi +4247 -0
  186. data/sorbet/rbi/gems/netrc@0.11.0.rbi +159 -0
  187. data/sorbet/rbi/gems/notiffany@0.1.3.rbi +1079 -0
  188. data/sorbet/rbi/gems/open_router@0.3.3.rbi +230 -0
  189. data/sorbet/rbi/gems/ostruct@0.6.2.rbi +354 -0
  190. data/sorbet/rbi/gems/parallel@1.27.0.rbi +291 -0
  191. data/sorbet/rbi/gems/parser@3.3.8.0.rbi +5535 -0
  192. data/sorbet/rbi/gems/prism@1.4.0.rbi +41732 -0
  193. data/sorbet/rbi/gems/pry@0.15.2.rbi +9 -0
  194. data/sorbet/rbi/gems/public_suffix@6.0.2.rbi +936 -0
  195. data/sorbet/rbi/gems/racc@1.8.1.rbi +158 -0
  196. data/sorbet/rbi/gems/rack@2.2.17.rbi +5659 -0
  197. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +9 -0
  198. data/sorbet/rbi/gems/raix@1.0.2.rbi +1104 -0
  199. data/sorbet/rbi/gems/rake@13.3.0.rbi +3036 -0
  200. data/sorbet/rbi/gems/rb-fsevent@0.11.2.rbi +9 -0
  201. data/sorbet/rbi/gems/rb-inotify@0.11.1.rbi +9 -0
  202. data/sorbet/rbi/gems/rbi@0.3.6.rbi +6893 -0
  203. data/sorbet/rbi/gems/rbs@3.9.4.rbi +6978 -0
  204. data/sorbet/rbi/gems/regexp_parser@2.10.0.rbi +9 -0
  205. data/sorbet/rbi/gems/rexml@3.4.1.rbi +5346 -0
  206. data/sorbet/rbi/gems/rubocop-ast@1.45.1.rbi +9 -0
  207. data/sorbet/rbi/gems/rubocop-shopify@2.17.1.rbi +9 -0
  208. data/sorbet/rbi/gems/rubocop@1.77.0.rbi +9 -0
  209. data/sorbet/rbi/gems/ruby-graphviz@1.2.5.rbi +1333 -0
  210. data/sorbet/rbi/gems/ruby-openai@8.1.0.rbi +758 -0
  211. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +9 -0
  212. data/sorbet/rbi/gems/ruby2_keywords@0.0.5.rbi +9 -0
  213. data/sorbet/rbi/gems/securerandom@0.4.1.rbi +75 -0
  214. data/sorbet/rbi/gems/shellany@0.0.1.rbi +102 -0
  215. data/sorbet/rbi/gems/spoom@1.6.3.rbi +6985 -0
  216. data/sorbet/rbi/gems/sqlite3@2.7.0.rbi +1900 -0
  217. data/sorbet/rbi/gems/tapioca@0.16.11.rbi +3628 -0
  218. data/sorbet/rbi/gems/thor@1.4.0.rbi +4399 -0
  219. data/sorbet/rbi/gems/tzinfo@2.0.6.rbi +5918 -0
  220. data/sorbet/rbi/gems/unicode-display_width@3.1.4.rbi +9 -0
  221. data/sorbet/rbi/gems/unicode-emoji@4.0.4.rbi +9 -0
  222. data/sorbet/rbi/gems/uri@1.0.3.rbi +2349 -0
  223. data/sorbet/rbi/gems/vcr@6.3.1.rbi +3040 -0
  224. data/sorbet/rbi/gems/webmock@3.25.1.rbi +1792 -0
  225. data/sorbet/rbi/gems/yard-sorbet@0.9.0.rbi +435 -0
  226. data/sorbet/rbi/gems/yard@0.9.37.rbi +18492 -0
  227. data/sorbet/rbi/gems/zeitwerk@2.7.3.rbi +1429 -0
  228. data/sorbet/tapioca/config.yml +13 -0
  229. data/sorbet/tapioca/require.rb +36 -0
  230. metadata +113 -2
  231. data/lib/roast/workflow/configuration_parser.rb +0 -54
@@ -0,0 +1,972 @@
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
+ # Represents a simplistic (non-contextual) change. Represents the removal or
443
+ # addition of an element from either the old or the new sequenced
444
+ # enumerable.
445
+ #
446
+ # source://diff-lcs//lib/diff/lcs/change.rb#6
447
+ class Diff::LCS::Change
448
+ include ::Comparable
449
+
450
+ # @return [Change] a new instance of Change
451
+ #
452
+ # source://diff-lcs//lib/diff/lcs/change.rb#27
453
+ def initialize(*args); end
454
+
455
+ # source://diff-lcs//lib/diff/lcs/change.rb#65
456
+ def <=>(other); end
457
+
458
+ # source://diff-lcs//lib/diff/lcs/change.rb#58
459
+ def ==(other); end
460
+
461
+ # Returns the action this Change represents.
462
+ #
463
+ # source://diff-lcs//lib/diff/lcs/change.rb#20
464
+ def action; end
465
+
466
+ # @return [Boolean]
467
+ #
468
+ # source://diff-lcs//lib/diff/lcs/change.rb#72
469
+ def adding?; end
470
+
471
+ # @return [Boolean]
472
+ #
473
+ # source://diff-lcs//lib/diff/lcs/change.rb#84
474
+ def changed?; end
475
+
476
+ # @return [Boolean]
477
+ #
478
+ # source://diff-lcs//lib/diff/lcs/change.rb#76
479
+ def deleting?; end
480
+
481
+ # Returns the sequence element of the Change.
482
+ #
483
+ # source://diff-lcs//lib/diff/lcs/change.rb#25
484
+ def element; end
485
+
486
+ # @return [Boolean]
487
+ #
488
+ # source://diff-lcs//lib/diff/lcs/change.rb#88
489
+ def finished_a?; end
490
+
491
+ # @return [Boolean]
492
+ #
493
+ # source://diff-lcs//lib/diff/lcs/change.rb#92
494
+ def finished_b?; end
495
+
496
+ # source://diff-lcs//lib/diff/lcs/change.rb#34
497
+ def inspect(*_args); end
498
+
499
+ # Returns the position of the Change.
500
+ #
501
+ # source://diff-lcs//lib/diff/lcs/change.rb#23
502
+ def position; end
503
+
504
+ # source://diff-lcs//lib/diff/lcs/change.rb#38
505
+ def to_a; end
506
+
507
+ # source://diff-lcs//lib/diff/lcs/change.rb#38
508
+ def to_ary; end
509
+
510
+ # @return [Boolean]
511
+ #
512
+ # source://diff-lcs//lib/diff/lcs/change.rb#80
513
+ def unchanged?; end
514
+
515
+ class << self
516
+ # source://diff-lcs//lib/diff/lcs/change.rb#44
517
+ def from_a(arr); end
518
+
519
+ # @return [Boolean]
520
+ #
521
+ # source://diff-lcs//lib/diff/lcs/change.rb#15
522
+ def valid_action?(action); end
523
+ end
524
+ end
525
+
526
+ # Fixnum is deprecated in Ruby 2.4 # standard:disable Naming/ConstantName
527
+ #
528
+ # source://diff-lcs//lib/diff/lcs/change.rb#7
529
+ Diff::LCS::Change::IntClass = Integer
530
+
531
+ # The only actions valid for changes are '+' (add), '-' (delete), '='
532
+ # (no change), '!' (changed), '<' (tail changes from first sequence), or
533
+ # '>' (tail changes from second sequence). The last two ('<>') are only
534
+ # found with Diff::LCS::diff and Diff::LCS::sdiff.
535
+ #
536
+ # source://diff-lcs//lib/diff/lcs/change.rb#13
537
+ Diff::LCS::Change::VALID_ACTIONS = T.let(T.unsafe(nil), Array)
538
+
539
+ # Represents a contextual change. Contains the position and values of the
540
+ # elements in the old and the new sequenced enumerables as well as the action
541
+ # taken.
542
+ #
543
+ # source://diff-lcs//lib/diff/lcs/change.rb#100
544
+ class Diff::LCS::ContextChange < ::Diff::LCS::Change
545
+ # @return [ContextChange] a new instance of ContextChange
546
+ #
547
+ # source://diff-lcs//lib/diff/lcs/change.rb#114
548
+ def initialize(*args); end
549
+
550
+ # source://diff-lcs//lib/diff/lcs/change.rb#166
551
+ def <=>(other); end
552
+
553
+ # source://diff-lcs//lib/diff/lcs/change.rb#157
554
+ def ==(other); end
555
+
556
+ # Returns the new element being changed.
557
+ #
558
+ # source://diff-lcs//lib/diff/lcs/change.rb#112
559
+ def new_element; end
560
+
561
+ # Returns the new position being changed.
562
+ #
563
+ # source://diff-lcs//lib/diff/lcs/change.rb#108
564
+ def new_position; end
565
+
566
+ # Returns the old element being changed.
567
+ #
568
+ # source://diff-lcs//lib/diff/lcs/change.rb#110
569
+ def old_element; end
570
+
571
+ # Returns the old position being changed.
572
+ #
573
+ # source://diff-lcs//lib/diff/lcs/change.rb#106
574
+ def old_position; end
575
+
576
+ # source://diff-lcs//lib/diff/lcs/change.rb#122
577
+ def to_a; end
578
+
579
+ # source://diff-lcs//lib/diff/lcs/change.rb#122
580
+ def to_ary; end
581
+
582
+ class << self
583
+ # source://diff-lcs//lib/diff/lcs/change.rb#132
584
+ def from_a(arr); end
585
+
586
+ # Simplifies a context change for use in some diff callbacks. '<' actions
587
+ # are converted to '-' and '>' actions are converted to '+'.
588
+ #
589
+ # source://diff-lcs//lib/diff/lcs/change.rb#138
590
+ def simplify(event); end
591
+ end
592
+ end
593
+
594
+ # This will produce a compound array of contextual diff change objects. Each
595
+ # element in the #diffs array is a "hunk" array, where each element in each
596
+ # "hunk" array is a single change. Each change is a Diff::LCS::ContextChange
597
+ # that contains both the old index and new index values for the change. The
598
+ # "hunk" provides the full context for the changes. Both old and new objects
599
+ # will be presented for changed objects. +nil+ will be substituted for a
600
+ # discarded object.
601
+ #
602
+ # seq1 = %w(a b c e h j l m n p)
603
+ # seq2 = %w(b c d e f j k l m r s t)
604
+ #
605
+ # diffs = Diff::LCS.diff(seq1, seq2, Diff::LCS::ContextDiffCallbacks)
606
+ # # This example shows a simplified array format.
607
+ # # [ [ [ '-', [ 0, 'a' ], [ 0, nil ] ] ], # 1
608
+ # # [ [ '+', [ 3, nil ], [ 2, 'd' ] ] ], # 2
609
+ # # [ [ '-', [ 4, 'h' ], [ 4, nil ] ], # 3
610
+ # # [ '+', [ 5, nil ], [ 4, 'f' ] ] ],
611
+ # # [ [ '+', [ 6, nil ], [ 6, 'k' ] ] ], # 4
612
+ # # [ [ '-', [ 8, 'n' ], [ 9, nil ] ], # 5
613
+ # # [ '+', [ 9, nil ], [ 9, 'r' ] ],
614
+ # # [ '-', [ 9, 'p' ], [ 10, nil ] ],
615
+ # # [ '+', [ 10, nil ], [ 10, 's' ] ],
616
+ # # [ '+', [ 10, nil ], [ 11, 't' ] ] ] ]
617
+ #
618
+ # The five hunks shown are comprised of individual changes; if there is a
619
+ # related set of changes, they are still shown individually.
620
+ #
621
+ # This callback can also be used with Diff::LCS#sdiff, which will produce
622
+ # results like:
623
+ #
624
+ # diffs = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextCallbacks)
625
+ # # This example shows a simplified array format.
626
+ # # [ [ [ "-", [ 0, "a" ], [ 0, nil ] ] ], # 1
627
+ # # [ [ "+", [ 3, nil ], [ 2, "d" ] ] ], # 2
628
+ # # [ [ "!", [ 4, "h" ], [ 4, "f" ] ] ], # 3
629
+ # # [ [ "+", [ 6, nil ], [ 6, "k" ] ] ], # 4
630
+ # # [ [ "!", [ 8, "n" ], [ 9, "r" ] ], # 5
631
+ # # [ "!", [ 9, "p" ], [ 10, "s" ] ],
632
+ # # [ "+", [ 10, nil ], [ 11, "t" ] ] ] ]
633
+ #
634
+ # The five hunks are still present, but are significantly shorter in total
635
+ # presentation, because changed items are shown as changes ("!") instead of
636
+ # potentially "mismatched" pairs of additions and deletions.
637
+ #
638
+ # The result of this operation is similar to that of
639
+ # Diff::LCS::SDiffCallbacks. They may be compared as:
640
+ #
641
+ # s = Diff::LCS.sdiff(seq1, seq2).reject { |e| e.action == "=" }
642
+ # c = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextDiffCallbacks).flatten(1)
643
+ #
644
+ # s == c # -> true
645
+ #
646
+ # === Use
647
+ #
648
+ # This callback object must be initialised and can be used by the
649
+ # Diff::LCS#diff or Diff::LCS#sdiff methods.
650
+ #
651
+ # cbo = Diff::LCS::ContextDiffCallbacks.new
652
+ # Diff::LCS.LCS(seq1, seq2, cbo)
653
+ # cbo.finish
654
+ #
655
+ # Note that the call to #finish is absolutely necessary, or the last set of
656
+ # changes will not be visible. Alternatively, can be used as:
657
+ #
658
+ # cbo = Diff::LCS::ContextDiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) }
659
+ #
660
+ # The necessary #finish call will be made.
661
+ #
662
+ # === Simplified Array Format
663
+ #
664
+ # The simplified array format used in the example above can be obtained
665
+ # with:
666
+ #
667
+ # require 'pp'
668
+ # pp diffs.map { |e| e.map { |f| f.to_a } }
669
+ #
670
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#225
671
+ class Diff::LCS::ContextDiffCallbacks < ::Diff::LCS::DiffCallbacks
672
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#234
673
+ def change(event); end
674
+
675
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#226
676
+ def discard_a(event); end
677
+
678
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#230
679
+ def discard_b(event); end
680
+ end
681
+
682
+ # This callback object implements the default set of callback events,
683
+ # which only returns the event itself. Note that #finished_a and
684
+ # #finished_b are not implemented -- I haven't yet figured out where they
685
+ # would be useful.
686
+ #
687
+ # Note that this is intended to be called as is, e.g.,
688
+ #
689
+ # Diff::LCS.LCS(seq1, seq2, Diff::LCS::DefaultCallbacks)
690
+ #
691
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#14
692
+ class Diff::LCS::DefaultCallbacks
693
+ class << self
694
+ # Called when both the old and new values have changed.
695
+ #
696
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#32
697
+ def change(event); end
698
+
699
+ # Called when the old value is discarded in favour of the new value.
700
+ #
701
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#22
702
+ def discard_a(event); end
703
+
704
+ # Called when the new value is discarded in favour of the old value.
705
+ #
706
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#27
707
+ def discard_b(event); end
708
+
709
+ # Called when two items match.
710
+ #
711
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#17
712
+ def match(event); end
713
+
714
+ private
715
+
716
+ def new(*_arg0); end
717
+ end
718
+ end
719
+
720
+ # This will produce a compound array of simple diff change objects. Each
721
+ # element in the #diffs array is a +hunk+ or +hunk+ array, where each
722
+ # element in each +hunk+ array is a single Change object representing the
723
+ # addition or removal of a single element from one of the two tested
724
+ # sequences. The +hunk+ provides the full context for the changes.
725
+ #
726
+ # diffs = Diff::LCS.diff(seq1, seq2)
727
+ # # This example shows a simplified array format.
728
+ # # [ [ [ '-', 0, 'a' ] ], # 1
729
+ # # [ [ '+', 2, 'd' ] ], # 2
730
+ # # [ [ '-', 4, 'h' ], # 3
731
+ # # [ '+', 4, 'f' ] ],
732
+ # # [ [ '+', 6, 'k' ] ], # 4
733
+ # # [ [ '-', 8, 'n' ], # 5
734
+ # # [ '-', 9, 'p' ],
735
+ # # [ '+', 9, 'r' ],
736
+ # # [ '+', 10, 's' ],
737
+ # # [ '+', 11, 't' ] ] ]
738
+ #
739
+ # There are five hunks here. The first hunk says that the +a+ at position 0
740
+ # of the first sequence should be deleted (<tt>'-'</tt>). The second hunk
741
+ # says that the +d+ at position 2 of the second sequence should be inserted
742
+ # (<tt>'+'</tt>). The third hunk says that the +h+ at position 4 of the
743
+ # first sequence should be removed and replaced with the +f+ from position 4
744
+ # of the second sequence. The other two hunks are described similarly.
745
+ #
746
+ # === Use
747
+ #
748
+ # This callback object must be initialised and is used by the Diff::LCS#diff
749
+ # method.
750
+ #
751
+ # cbo = Diff::LCS::DiffCallbacks.new
752
+ # Diff::LCS.LCS(seq1, seq2, cbo)
753
+ # cbo.finish
754
+ #
755
+ # Note that the call to #finish is absolutely necessary, or the last set of
756
+ # changes will not be visible. Alternatively, can be used as:
757
+ #
758
+ # cbo = Diff::LCS::DiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) }
759
+ #
760
+ # The necessary #finish call will be made.
761
+ #
762
+ # === Simplified Array Format
763
+ #
764
+ # The simplified array format used in the example above can be obtained
765
+ # with:
766
+ #
767
+ # require 'pp'
768
+ # pp diffs.map { |e| e.map { |f| f.to_a } }
769
+ #
770
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#108
771
+ class Diff::LCS::DiffCallbacks
772
+ # :yields: self
773
+ #
774
+ # @return [DiffCallbacks] a new instance of DiffCallbacks
775
+ #
776
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#112
777
+ def initialize; end
778
+
779
+ # Returns the difference set collected during the diff process.
780
+ #
781
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#110
782
+ def diffs; end
783
+
784
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#135
785
+ def discard_a(event); end
786
+
787
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#139
788
+ def discard_b(event); end
789
+
790
+ # Finalizes the diff process. If an unprocessed hunk still exists, then it
791
+ # is appended to the diff list.
792
+ #
793
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#127
794
+ def finish; end
795
+
796
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#131
797
+ def match(_event); end
798
+
799
+ private
800
+
801
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#143
802
+ def finish_hunk; end
803
+ end
804
+
805
+ # source://diff-lcs//lib/diff/lcs/internals.rb#29
806
+ module Diff::LCS::Internals
807
+ class << self
808
+ # This method will analyze the provided patchset to provide a single-pass
809
+ # normalization (conversion of the array form of Diff::LCS::Change objects to
810
+ # the object form of same) and detection of whether the patchset represents
811
+ # changes to be made.
812
+ #
813
+ # source://diff-lcs//lib/diff/lcs/internals.rb#102
814
+ def analyze_patchset(patchset, depth = T.unsafe(nil)); end
815
+
816
+ # Examine the patchset and the source to see in which direction the
817
+ # patch should be applied.
818
+ #
819
+ # WARNING: By default, this examines the whole patch, so this could take
820
+ # some time. This also works better with Diff::LCS::ContextChange or
821
+ # Diff::LCS::Change as its source, as an array will cause the creation
822
+ # of one of the above.
823
+ #
824
+ # source://diff-lcs//lib/diff/lcs/internals.rb#147
825
+ def intuit_diff_direction(src, patchset, limit = T.unsafe(nil)); end
826
+
827
+ # Compute the longest common subsequence between the sequenced
828
+ # Enumerables +a+ and +b+. The result is an array whose contents is such
829
+ # that
830
+ #
831
+ # result = Diff::LCS::Internals.lcs(a, b)
832
+ # result.each_with_index do |e, i|
833
+ # assert_equal(a[i], b[e]) unless e.nil?
834
+ # end
835
+ #
836
+ # source://diff-lcs//lib/diff/lcs/internals.rb#41
837
+ def lcs(a, b); end
838
+
839
+ private
840
+
841
+ # If +vector+ maps the matching elements of another collection onto this
842
+ # Enumerable, compute the inverse of +vector+ that maps this Enumerable
843
+ # onto the collection. (Currently unused.)
844
+ #
845
+ # source://diff-lcs//lib/diff/lcs/internals.rb#286
846
+ def inverse_vector(a, vector); end
847
+
848
+ # Returns a hash mapping each element of an Enumerable to the set of
849
+ # positions it occupies in the Enumerable, optionally restricted to the
850
+ # elements specified in the range of indexes specified by +interval+.
851
+ #
852
+ # source://diff-lcs//lib/diff/lcs/internals.rb#298
853
+ def position_hash(enum, interval); end
854
+
855
+ # Find the place at which +value+ would normally be inserted into the
856
+ # Enumerable. If that place is already occupied by +value+, do nothing
857
+ # and return +nil+. If the place does not exist (i.e., it is off the end
858
+ # of the Enumerable), add it to the end. Otherwise, replace the element
859
+ # at that point with +value+. It is assumed that the Enumerable's values
860
+ # are numeric.
861
+ #
862
+ # This operation preserves the sort order.
863
+ #
864
+ # source://diff-lcs//lib/diff/lcs/internals.rb#252
865
+ def replace_next_larger(enum, value, last_index = T.unsafe(nil)); end
866
+ end
867
+ end
868
+
869
+ # This will produce a simple array of diff change objects. Each element in
870
+ # the #diffs array is a single ContextChange. In the set of #diffs provided
871
+ # by SDiffCallbacks, both old and new objects will be presented for both
872
+ # changed <strong>and unchanged</strong> objects. +nil+ will be substituted
873
+ # for a discarded object.
874
+ #
875
+ # The diffset produced by this callback, when provided to Diff::LCS#sdiff,
876
+ # will compute and display the necessary components to show two sequences
877
+ # and their minimized differences side by side, just like the Unix utility
878
+ # +sdiff+.
879
+ #
880
+ # same same
881
+ # before | after
882
+ # old < -
883
+ # - > new
884
+ #
885
+ # seq1 = %w(a b c e h j l m n p)
886
+ # seq2 = %w(b c d e f j k l m r s t)
887
+ #
888
+ # diffs = Diff::LCS.sdiff(seq1, seq2)
889
+ # # This example shows a simplified array format.
890
+ # # [ [ "-", [ 0, "a"], [ 0, nil ] ],
891
+ # # [ "=", [ 1, "b"], [ 0, "b" ] ],
892
+ # # [ "=", [ 2, "c"], [ 1, "c" ] ],
893
+ # # [ "+", [ 3, nil], [ 2, "d" ] ],
894
+ # # [ "=", [ 3, "e"], [ 3, "e" ] ],
895
+ # # [ "!", [ 4, "h"], [ 4, "f" ] ],
896
+ # # [ "=", [ 5, "j"], [ 5, "j" ] ],
897
+ # # [ "+", [ 6, nil], [ 6, "k" ] ],
898
+ # # [ "=", [ 6, "l"], [ 7, "l" ] ],
899
+ # # [ "=", [ 7, "m"], [ 8, "m" ] ],
900
+ # # [ "!", [ 8, "n"], [ 9, "r" ] ],
901
+ # # [ "!", [ 9, "p"], [ 10, "s" ] ],
902
+ # # [ "+", [ 10, nil], [ 11, "t" ] ] ]
903
+ #
904
+ # The result of this operation is similar to that of
905
+ # Diff::LCS::ContextDiffCallbacks. They may be compared as:
906
+ #
907
+ # s = Diff::LCS.sdiff(seq1, seq2).reject { |e| e.action == "=" }
908
+ # c = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextDiffCallbacks).flatten(1)
909
+ #
910
+ # s == c # -> true
911
+ #
912
+ # === Use
913
+ #
914
+ # This callback object must be initialised and is used by the Diff::LCS#sdiff
915
+ # method.
916
+ #
917
+ # cbo = Diff::LCS::SDiffCallbacks.new
918
+ # Diff::LCS.LCS(seq1, seq2, cbo)
919
+ #
920
+ # As with the other initialisable callback objects,
921
+ # Diff::LCS::SDiffCallbacks can be initialised with a block. As there is no
922
+ # "fininishing" to be done, this has no effect on the state of the object.
923
+ #
924
+ # cbo = Diff::LCS::SDiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) }
925
+ #
926
+ # === Simplified Array Format
927
+ #
928
+ # The simplified array format used in the example above can be obtained
929
+ # with:
930
+ #
931
+ # require 'pp'
932
+ # pp diffs.map { |e| e.to_a }
933
+ #
934
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#303
935
+ class Diff::LCS::SDiffCallbacks
936
+ # :yields: self
937
+ #
938
+ # @return [SDiffCallbacks] a new instance of SDiffCallbacks
939
+ # @yield [_self]
940
+ # @yieldparam _self [Diff::LCS::SDiffCallbacks] the object that the method was called on
941
+ #
942
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#307
943
+ def initialize; end
944
+
945
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#324
946
+ def change(event); end
947
+
948
+ # Returns the difference set collected during the diff process.
949
+ #
950
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#305
951
+ def diffs; end
952
+
953
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#316
954
+ def discard_a(event); end
955
+
956
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#320
957
+ def discard_b(event); end
958
+
959
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#312
960
+ def match(event); end
961
+ end
962
+
963
+ # An alias for DefaultCallbacks that is used in
964
+ # Diff::LCS#traverse_sequences.
965
+ #
966
+ # Diff::LCS.LCS(seq1, seq2, Diff::LCS::SequenceCallbacks)
967
+ #
968
+ # source://diff-lcs//lib/diff/lcs/callbacks.rb#44
969
+ Diff::LCS::SequenceCallbacks = Diff::LCS::DefaultCallbacks
970
+
971
+ # source://diff-lcs//lib/diff/lcs/version.rb#5
972
+ Diff::LCS::VERSION = T.let(T.unsafe(nil), String)