active_cached_resource 0.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +22 -0
- data/.standard.yml +2 -0
- data/CHANGELOG.md +5 -0
- data/README.md +45 -0
- data/Rakefile +21 -0
- data/example/consumer/.dockerignore +41 -0
- data/example/consumer/.gitattributes +9 -0
- data/example/consumer/.gitignore +36 -0
- data/example/consumer/.kamal/hooks/docker-setup.sample +3 -0
- data/example/consumer/.kamal/hooks/post-deploy.sample +14 -0
- data/example/consumer/.kamal/hooks/post-proxy-reboot.sample +3 -0
- data/example/consumer/.kamal/hooks/pre-build.sample +51 -0
- data/example/consumer/.kamal/hooks/pre-connect.sample +47 -0
- data/example/consumer/.kamal/hooks/pre-deploy.sample +109 -0
- data/example/consumer/.kamal/hooks/pre-proxy-reboot.sample +3 -0
- data/example/consumer/.kamal/secrets +17 -0
- data/example/consumer/Dockerfile +65 -0
- data/example/consumer/Gemfile +17 -0
- data/example/consumer/Rakefile +6 -0
- data/example/consumer/app/controllers/application_controller.rb +2 -0
- data/example/consumer/app/controllers/concerns/.keep +0 -0
- data/example/consumer/app/jobs/application_job.rb +7 -0
- data/example/consumer/app/mailers/application_mailer.rb +4 -0
- data/example/consumer/app/models/application_record.rb +3 -0
- data/example/consumer/app/models/concerns/.keep +0 -0
- data/example/consumer/app/models/person.rb +9 -0
- data/example/consumer/app/views/layouts/mailer.html.erb +13 -0
- data/example/consumer/app/views/layouts/mailer.text.erb +1 -0
- data/example/consumer/bin/brakeman +7 -0
- data/example/consumer/bin/bundle +109 -0
- data/example/consumer/bin/dev +2 -0
- data/example/consumer/bin/docker-entrypoint +14 -0
- data/example/consumer/bin/jobs +6 -0
- data/example/consumer/bin/kamal +27 -0
- data/example/consumer/bin/rails +4 -0
- data/example/consumer/bin/rake +4 -0
- data/example/consumer/bin/rubocop +8 -0
- data/example/consumer/bin/setup +34 -0
- data/example/consumer/bin/thrust +5 -0
- data/example/consumer/config/application.rb +20 -0
- data/example/consumer/config/boot.rb +3 -0
- data/example/consumer/config/cache.yml +16 -0
- data/example/consumer/config/credentials.yml.enc +1 -0
- data/example/consumer/config/database.yml +14 -0
- data/example/consumer/config/deploy.yml +116 -0
- data/example/consumer/config/environment.rb +5 -0
- data/example/consumer/config/environments/development.rb +64 -0
- data/example/consumer/config/environments/production.rb +85 -0
- data/example/consumer/config/environments/test.rb +50 -0
- data/example/consumer/config/initializers/cors.rb +16 -0
- data/example/consumer/config/initializers/filter_parameter_logging.rb +8 -0
- data/example/consumer/config/initializers/inflections.rb +16 -0
- data/example/consumer/config/locales/en.yml +31 -0
- data/example/consumer/config/puma.rb +41 -0
- data/example/consumer/config/queue.yml +18 -0
- data/example/consumer/config/recurring.yml +10 -0
- data/example/consumer/config/routes.rb +10 -0
- data/example/consumer/config.ru +6 -0
- data/example/consumer/db/cache_schema.rb +14 -0
- data/example/consumer/db/queue_schema.rb +129 -0
- data/example/consumer/db/seeds.rb +0 -0
- data/example/consumer/lib/tasks/.keep +0 -0
- data/example/consumer/log/.keep +0 -0
- data/example/consumer/public/robots.txt +1 -0
- data/example/consumer/script/.keep +0 -0
- data/example/consumer/storage/.keep +0 -0
- data/example/consumer/tmp/.keep +0 -0
- data/example/consumer/tmp/cache/.keep +0 -0
- data/example/consumer/tmp/pids/.keep +0 -0
- data/example/consumer/tmp/storage/.keep +0 -0
- data/example/consumer/vendor/.keep +0 -0
- data/example/provider/.dockerignore +41 -0
- data/example/provider/.gitattributes +9 -0
- data/example/provider/.gitignore +32 -0
- data/example/provider/.kamal/hooks/docker-setup.sample +3 -0
- data/example/provider/.kamal/hooks/post-deploy.sample +14 -0
- data/example/provider/.kamal/hooks/post-proxy-reboot.sample +3 -0
- data/example/provider/.kamal/hooks/pre-build.sample +51 -0
- data/example/provider/.kamal/hooks/pre-connect.sample +47 -0
- data/example/provider/.kamal/hooks/pre-deploy.sample +109 -0
- data/example/provider/.kamal/hooks/pre-proxy-reboot.sample +3 -0
- data/example/provider/.kamal/secrets +17 -0
- data/example/provider/Dockerfile +65 -0
- data/example/provider/Gemfile +14 -0
- data/example/provider/Rakefile +6 -0
- data/example/provider/app/controllers/application_controller.rb +2 -0
- data/example/provider/app/controllers/concerns/.keep +0 -0
- data/example/provider/app/controllers/people_controller.rb +68 -0
- data/example/provider/app/jobs/application_job.rb +7 -0
- data/example/provider/app/mailers/application_mailer.rb +4 -0
- data/example/provider/app/models/address.rb +3 -0
- data/example/provider/app/models/application_record.rb +3 -0
- data/example/provider/app/models/company.rb +3 -0
- data/example/provider/app/models/concerns/.keep +0 -0
- data/example/provider/app/models/person.rb +6 -0
- data/example/provider/app/views/layouts/mailer.html.erb +13 -0
- data/example/provider/app/views/layouts/mailer.text.erb +1 -0
- data/example/provider/bin/brakeman +7 -0
- data/example/provider/bin/bundle +109 -0
- data/example/provider/bin/dev +2 -0
- data/example/provider/bin/docker-entrypoint +14 -0
- data/example/provider/bin/jobs +6 -0
- data/example/provider/bin/kamal +27 -0
- data/example/provider/bin/rails +4 -0
- data/example/provider/bin/rake +4 -0
- data/example/provider/bin/rubocop +8 -0
- data/example/provider/bin/setup +34 -0
- data/example/provider/bin/thrust +5 -0
- data/example/provider/config/application.rb +44 -0
- data/example/provider/config/boot.rb +3 -0
- data/example/provider/config/cache.yml +16 -0
- data/example/provider/config/credentials.yml.enc +1 -0
- data/example/provider/config/database.yml +20 -0
- data/example/provider/config/deploy.yml +116 -0
- data/example/provider/config/environment.rb +5 -0
- data/example/provider/config/environments/development.rb +64 -0
- data/example/provider/config/environments/production.rb +85 -0
- data/example/provider/config/environments/test.rb +50 -0
- data/example/provider/config/initializers/cors.rb +16 -0
- data/example/provider/config/initializers/filter_parameter_logging.rb +8 -0
- data/example/provider/config/initializers/inflections.rb +16 -0
- data/example/provider/config/locales/en.yml +31 -0
- data/example/provider/config/puma.rb +41 -0
- data/example/provider/config/queue.yml +18 -0
- data/example/provider/config/recurring.yml +10 -0
- data/example/provider/config/routes.rb +4 -0
- data/example/provider/config.ru +6 -0
- data/example/provider/db/cache_schema.rb +14 -0
- data/example/provider/db/migrate/20241202183937_create_people.rb +11 -0
- data/example/provider/db/migrate/20241202183955_create_addresses.rb +13 -0
- data/example/provider/db/migrate/20241202184017_create_companies.rb +14 -0
- data/example/provider/db/queue_schema.rb +129 -0
- data/example/provider/db/schema.rb +47 -0
- data/example/provider/db/seeds.rb +18 -0
- data/example/provider/lib/tasks/.keep +0 -0
- data/example/provider/log/.keep +0 -0
- data/example/provider/public/robots.txt +1 -0
- data/example/provider/script/.keep +0 -0
- data/example/provider/storage/.keep +0 -0
- data/example/provider/tmp/.keep +0 -0
- data/example/provider/tmp/pids/.keep +0 -0
- data/example/provider/tmp/storage/.keep +0 -0
- data/example/provider/vendor/.keep +0 -0
- data/lib/active_cached_resource/caching.rb +176 -0
- data/lib/active_cached_resource/caching_strategies/active_support_cache.rb +31 -0
- data/lib/active_cached_resource/caching_strategies/base.rb +114 -0
- data/lib/active_cached_resource/caching_strategies/sql_cache.rb +32 -0
- data/lib/active_cached_resource/configuration.rb +50 -0
- data/lib/active_cached_resource/logger.rb +22 -0
- data/lib/active_cached_resource/model.rb +33 -0
- data/lib/active_cached_resource/version.rb +12 -0
- data/lib/active_cached_resource.rb +64 -0
- data/lib/activeresource/.gitignore +15 -0
- data/lib/activeresource/README.md +283 -0
- data/lib/activeresource/examples/performance.rb +72 -0
- data/lib/activeresource/lib/active_resource/active_job_serializer.rb +26 -0
- data/lib/activeresource/lib/active_resource/associations/builder/association.rb +32 -0
- data/lib/activeresource/lib/active_resource/associations/builder/belongs_to.rb +16 -0
- data/lib/activeresource/lib/active_resource/associations/builder/has_many.rb +14 -0
- data/lib/activeresource/lib/active_resource/associations/builder/has_one.rb +14 -0
- data/lib/activeresource/lib/active_resource/associations.rb +175 -0
- data/lib/activeresource/lib/active_resource/base.rb +1741 -0
- data/lib/activeresource/lib/active_resource/callbacks.rb +22 -0
- data/lib/activeresource/lib/active_resource/collection.rb +214 -0
- data/lib/activeresource/lib/active_resource/connection.rb +298 -0
- data/lib/activeresource/lib/active_resource/custom_methods.rb +129 -0
- data/lib/activeresource/lib/active_resource/exceptions.rb +98 -0
- data/lib/activeresource/lib/active_resource/formats/json_format.rb +28 -0
- data/lib/activeresource/lib/active_resource/formats/xml_format.rb +27 -0
- data/lib/activeresource/lib/active_resource/formats.rb +24 -0
- data/lib/activeresource/lib/active_resource/http_mock.rb +386 -0
- data/lib/activeresource/lib/active_resource/inheriting_hash.rb +34 -0
- data/lib/activeresource/lib/active_resource/log_subscriber.rb +26 -0
- data/lib/activeresource/lib/active_resource/railtie.rb +31 -0
- data/lib/activeresource/lib/active_resource/reflection.rb +78 -0
- data/lib/activeresource/lib/active_resource/schema.rb +60 -0
- data/lib/activeresource/lib/active_resource/singleton.rb +111 -0
- data/lib/activeresource/lib/active_resource/threadsafe_attributes.rb +65 -0
- data/lib/activeresource/lib/active_resource/validations.rb +176 -0
- data/lib/activeresource/lib/active_resource.rb +49 -0
- data/lib/activeresource/lib/activeresource.rb +3 -0
- data/lib/activeresource/test/abstract_unit.rb +153 -0
- data/lib/activeresource/test/cases/active_job_serializer_test.rb +53 -0
- data/lib/activeresource/test/cases/association_test.rb +104 -0
- data/lib/activeresource/test/cases/associations/builder/belongs_to_test.rb +42 -0
- data/lib/activeresource/test/cases/associations/builder/has_many_test.rb +28 -0
- data/lib/activeresource/test/cases/associations/builder/has_one_test.rb +28 -0
- data/lib/activeresource/test/cases/authorization_test.rb +276 -0
- data/lib/activeresource/test/cases/base/custom_methods_test.rb +155 -0
- data/lib/activeresource/test/cases/base/equality_test.rb +53 -0
- data/lib/activeresource/test/cases/base/load_test.rb +249 -0
- data/lib/activeresource/test/cases/base/schema_test.rb +428 -0
- data/lib/activeresource/test/cases/base_errors_test.rb +129 -0
- data/lib/activeresource/test/cases/base_test.rb +1622 -0
- data/lib/activeresource/test/cases/callbacks_test.rb +155 -0
- data/lib/activeresource/test/cases/collection_test.rb +172 -0
- data/lib/activeresource/test/cases/connection_test.rb +357 -0
- data/lib/activeresource/test/cases/finder_test.rb +217 -0
- data/lib/activeresource/test/cases/format_test.rb +137 -0
- data/lib/activeresource/test/cases/http_mock_test.rb +213 -0
- data/lib/activeresource/test/cases/inheritence_test.rb +19 -0
- data/lib/activeresource/test/cases/inheriting_hash_test.rb +25 -0
- data/lib/activeresource/test/cases/log_subscriber_test.rb +63 -0
- data/lib/activeresource/test/cases/reflection_test.rb +65 -0
- data/lib/activeresource/test/cases/validations_test.rb +78 -0
- data/lib/activeresource/test/fixtures/address.rb +20 -0
- data/lib/activeresource/test/fixtures/beast.rb +16 -0
- data/lib/activeresource/test/fixtures/comment.rb +5 -0
- data/lib/activeresource/test/fixtures/customer.rb +5 -0
- data/lib/activeresource/test/fixtures/inventory.rb +14 -0
- data/lib/activeresource/test/fixtures/person.rb +15 -0
- data/lib/activeresource/test/fixtures/pet.rb +6 -0
- data/lib/activeresource/test/fixtures/post.rb +5 -0
- data/lib/activeresource/test/fixtures/product.rb +11 -0
- data/lib/activeresource/test/fixtures/project.rb +19 -0
- data/lib/activeresource/test/fixtures/proxy.rb +6 -0
- data/lib/activeresource/test/fixtures/sound.rb +11 -0
- data/lib/activeresource/test/fixtures/street_address.rb +6 -0
- data/lib/activeresource/test/fixtures/subscription_plan.rb +7 -0
- data/lib/activeresource/test/fixtures/weather.rb +21 -0
- data/lib/activeresource/test/setter_trap.rb +28 -0
- data/lib/activeresource/test/singleton_test.rb +138 -0
- data/lib/activeresource/test/threadsafe_attributes_test.rb +91 -0
- data/lib/generators/active_cached_resource/install_generator.rb +31 -0
- data/lib/generators/active_cached_resource/templates/migration.erb +16 -0
- data/sorbet/config +4 -0
- data/sorbet/rbi/annotations/.gitattributes +1 -0
- data/sorbet/rbi/annotations/activemodel.rbi +89 -0
- data/sorbet/rbi/annotations/activesupport.rbi +457 -0
- data/sorbet/rbi/annotations/minitest.rbi +119 -0
- data/sorbet/rbi/annotations/rainbow.rbi +269 -0
- data/sorbet/rbi/dsl/.gitattributes +1 -0
- data/sorbet/rbi/dsl/active_support/callbacks.rbi +21 -0
- data/sorbet/rbi/gems/.gitattributes +1 -0
- data/sorbet/rbi/gems/actioncable@8.0.0.rbi +252 -0
- data/sorbet/rbi/gems/actionmailbox@8.0.0.rbi +9 -0
- data/sorbet/rbi/gems/actionmailer@8.0.0.rbi +9 -0
- data/sorbet/rbi/gems/actionpack@8.0.0.rbi +20909 -0
- data/sorbet/rbi/gems/actiontext@8.0.0.rbi +9 -0
- data/sorbet/rbi/gems/actionview@8.0.0.rbi +16207 -0
- data/sorbet/rbi/gems/activejob@8.0.0.rbi +9 -0
- data/sorbet/rbi/gems/activemodel-serializers-xml@1.0.3.rbi +166 -0
- data/sorbet/rbi/gems/activemodel@8.0.0.rbi +6857 -0
- data/sorbet/rbi/gems/activerecord@8.0.0.rbi +42896 -0
- data/sorbet/rbi/gems/activeresource@6.1.4.rbi +3944 -0
- data/sorbet/rbi/gems/activestorage@8.0.0.rbi +9 -0
- data/sorbet/rbi/gems/activesupport@8.0.0.rbi +21251 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +585 -0
- data/sorbet/rbi/gems/base64@0.2.0.rbi +509 -0
- data/sorbet/rbi/gems/benchmark@0.4.0.rbi +618 -0
- data/sorbet/rbi/gems/bigdecimal@3.1.8.rbi +78 -0
- data/sorbet/rbi/gems/builder@3.3.0.rbi +9 -0
- data/sorbet/rbi/gems/bump@0.10.0.rbi +169 -0
- data/sorbet/rbi/gems/byebug@11.1.3.rbi +3607 -0
- data/sorbet/rbi/gems/coderay@1.1.3.rbi +3427 -0
- data/sorbet/rbi/gems/concurrent-ruby@1.3.4.rbi +11645 -0
- data/sorbet/rbi/gems/connection_pool@2.4.1.rbi +9 -0
- data/sorbet/rbi/gems/crass@1.0.6.rbi +623 -0
- data/sorbet/rbi/gems/date@3.4.0.rbi +75 -0
- data/sorbet/rbi/gems/diff-lcs@1.5.1.rbi +1131 -0
- data/sorbet/rbi/gems/docile@1.4.1.rbi +377 -0
- data/sorbet/rbi/gems/drb@2.2.1.rbi +1347 -0
- data/sorbet/rbi/gems/erubi@1.13.0.rbi +150 -0
- data/sorbet/rbi/gems/globalid@1.2.1.rbi +9 -0
- data/sorbet/rbi/gems/i18n@1.14.6.rbi +2359 -0
- data/sorbet/rbi/gems/io-console@0.7.2.rbi +9 -0
- data/sorbet/rbi/gems/json@2.8.2.rbi +1901 -0
- data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +14238 -0
- data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +240 -0
- data/sorbet/rbi/gems/logger@1.6.1.rbi +920 -0
- data/sorbet/rbi/gems/loofah@2.23.1.rbi +1081 -0
- data/sorbet/rbi/gems/mail@2.8.1.rbi +9 -0
- data/sorbet/rbi/gems/marcel@1.0.4.rbi +9 -0
- data/sorbet/rbi/gems/method_source@1.1.0.rbi +304 -0
- data/sorbet/rbi/gems/mini_mime@1.1.5.rbi +9 -0
- data/sorbet/rbi/gems/minitest@5.25.2.rbi +1547 -0
- data/sorbet/rbi/gems/net-imap@0.5.1.rbi +9 -0
- data/sorbet/rbi/gems/net-pop@0.1.2.rbi +9 -0
- data/sorbet/rbi/gems/net-protocol@0.2.2.rbi +292 -0
- data/sorbet/rbi/gems/net-smtp@0.5.0.rbi +9 -0
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +159 -0
- data/sorbet/rbi/gems/nio4r@2.7.4.rbi +9 -0
- data/sorbet/rbi/gems/nokogiri@1.16.7.rbi +7311 -0
- data/sorbet/rbi/gems/parallel@1.26.3.rbi +291 -0
- data/sorbet/rbi/gems/parser@3.3.6.0.rbi +5519 -0
- data/sorbet/rbi/gems/prism@1.2.0.rbi +39085 -0
- data/sorbet/rbi/gems/pry-byebug@3.10.1.rbi +1151 -0
- data/sorbet/rbi/gems/pry@0.14.2.rbi +10076 -0
- data/sorbet/rbi/gems/psych@5.2.0.rbi +1785 -0
- data/sorbet/rbi/gems/racc@1.8.1.rbi +162 -0
- data/sorbet/rbi/gems/rack-session@2.0.0.rbi +727 -0
- data/sorbet/rbi/gems/rack-test@2.1.0.rbi +747 -0
- data/sorbet/rbi/gems/rack@3.1.8.rbi +4905 -0
- data/sorbet/rbi/gems/rackup@2.2.1.rbi +230 -0
- data/sorbet/rbi/gems/rails-dom-testing@2.2.0.rbi +758 -0
- data/sorbet/rbi/gems/rails-html-sanitizer@1.6.0.rbi +785 -0
- data/sorbet/rbi/gems/rails@8.0.0.rbi +9 -0
- data/sorbet/rbi/gems/railties@8.0.0.rbi +6287 -0
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +403 -0
- data/sorbet/rbi/gems/rake@13.2.1.rbi +3091 -0
- data/sorbet/rbi/gems/rbi@0.2.1.rbi +4535 -0
- data/sorbet/rbi/gems/rdoc@6.8.1.rbi +12572 -0
- data/sorbet/rbi/gems/regexp_parser@2.9.2.rbi +3772 -0
- data/sorbet/rbi/gems/reline@0.5.12.rbi +2416 -0
- data/sorbet/rbi/gems/rexml@3.3.9.rbi +4858 -0
- data/sorbet/rbi/gems/rspec-core@3.13.2.rbi +11287 -0
- data/sorbet/rbi/gems/rspec-expectations@3.13.3.rbi +8183 -0
- data/sorbet/rbi/gems/rspec-mocks@3.13.2.rbi +5341 -0
- data/sorbet/rbi/gems/rspec-support@3.13.1.rbi +1630 -0
- data/sorbet/rbi/gems/rspec@3.13.0.rbi +83 -0
- data/sorbet/rbi/gems/rubocop-ast@1.36.1.rbi +7303 -0
- data/sorbet/rbi/gems/rubocop-performance@1.21.1.rbi +9 -0
- data/sorbet/rbi/gems/rubocop@1.65.1.rbi +58170 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1318 -0
- data/sorbet/rbi/gems/securerandom@0.3.2.rbi +395 -0
- data/sorbet/rbi/gems/simplecov-html@0.13.1.rbi +225 -0
- data/sorbet/rbi/gems/simplecov@0.22.0.rbi +2149 -0
- data/sorbet/rbi/gems/simplecov_json_formatter@0.1.4.rbi +9 -0
- data/sorbet/rbi/gems/spoom@1.5.0.rbi +4932 -0
- data/sorbet/rbi/gems/standard-custom@1.0.2.rbi +9 -0
- data/sorbet/rbi/gems/standard-performance@1.4.0.rbi +9 -0
- data/sorbet/rbi/gems/standard@1.40.0.rbi +929 -0
- data/sorbet/rbi/gems/stringio@3.1.2.rbi +9 -0
- data/sorbet/rbi/gems/tapioca@0.16.4.rbi +3597 -0
- data/sorbet/rbi/gems/thor@1.3.2.rbi +4378 -0
- data/sorbet/rbi/gems/timeout@0.4.2.rbi +151 -0
- data/sorbet/rbi/gems/tzinfo@2.0.6.rbi +5918 -0
- data/sorbet/rbi/gems/unicode-display_width@2.6.0.rbi +66 -0
- data/sorbet/rbi/gems/uri@1.0.2.rbi +2377 -0
- data/sorbet/rbi/gems/useragent@0.16.10.rbi +9 -0
- data/sorbet/rbi/gems/websocket-driver@0.7.6.rbi +9 -0
- data/sorbet/rbi/gems/websocket-extensions@0.1.5.rbi +9 -0
- data/sorbet/rbi/gems/yard-sorbet@0.9.0.rbi +435 -0
- data/sorbet/rbi/gems/yard@0.9.37.rbi +18504 -0
- data/sorbet/rbi/gems/zeitwerk@2.7.1.rbi +9 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +12 -0
- metadata +543 -0
@@ -0,0 +1,1131 @@
|
|
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)
|