active_cached_resource 0.1.0 → 0.1.1

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