sublimetheme 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +230 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/sublimetheme.rb +6832 -0
- data/lib/sublimetheme/version.rb +3 -0
- data/path/bin/htmldiff +25 -0
- data/path/bin/htmldiff.bat +6 -0
- data/path/bin/ldiff +25 -0
- data/path/bin/ldiff.bat +6 -0
- data/path/bin/rspec +23 -0
- data/path/bin/rspec.bat +6 -0
- data/path/cache/diff-lcs-1.2.5.gem +0 -0
- data/path/cache/rspec-3.3.0.gem +0 -0
- data/path/cache/rspec-core-3.3.2.gem +0 -0
- data/path/cache/rspec-expectations-3.3.1.gem +0 -0
- data/path/cache/rspec-mocks-3.3.2.gem +0 -0
- data/path/cache/rspec-support-3.3.0.gem +0 -0
- data/path/gems/diff-lcs-1.2.5/.autotest +3 -0
- data/path/gems/diff-lcs-1.2.5/.gemtest +0 -0
- data/path/gems/diff-lcs-1.2.5/.hoerc +2 -0
- data/path/gems/diff-lcs-1.2.5/.rspec +2 -0
- data/path/gems/diff-lcs-1.2.5/.travis.yml +22 -0
- data/path/gems/diff-lcs-1.2.5/Contributing.rdoc +64 -0
- data/path/gems/diff-lcs-1.2.5/Gemfile +20 -0
- data/path/gems/diff-lcs-1.2.5/History.rdoc +152 -0
- data/path/gems/diff-lcs-1.2.5/License.rdoc +39 -0
- data/path/gems/diff-lcs-1.2.5/Manifest.txt +38 -0
- data/path/gems/diff-lcs-1.2.5/README.rdoc +85 -0
- data/path/gems/diff-lcs-1.2.5/Rakefile +41 -0
- data/path/gems/diff-lcs-1.2.5/autotest/discover.rb +1 -0
- data/path/gems/diff-lcs-1.2.5/bin/htmldiff +32 -0
- data/path/gems/diff-lcs-1.2.5/bin/ldiff +6 -0
- data/path/gems/diff-lcs-1.2.5/docs/COPYING.txt +339 -0
- data/path/gems/diff-lcs-1.2.5/docs/artistic.txt +127 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff-lcs.rb +3 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs.rb +805 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/array.rb +7 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb +37 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/callbacks.rb +322 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/change.rb +177 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/htmldiff.rb +149 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/hunk.rb +276 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/internals.rb +301 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/ldiff.rb +195 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/string.rb +5 -0
- data/path/gems/diff-lcs-1.2.5/spec/change_spec.rb +65 -0
- data/path/gems/diff-lcs-1.2.5/spec/diff_spec.rb +47 -0
- data/path/gems/diff-lcs-1.2.5/spec/hunk_spec.rb +72 -0
- data/path/gems/diff-lcs-1.2.5/spec/issues_spec.rb +24 -0
- data/path/gems/diff-lcs-1.2.5/spec/lcs_spec.rb +54 -0
- data/path/gems/diff-lcs-1.2.5/spec/patch_spec.rb +414 -0
- data/path/gems/diff-lcs-1.2.5/spec/sdiff_spec.rb +214 -0
- data/path/gems/diff-lcs-1.2.5/spec/spec_helper.rb +290 -0
- data/path/gems/diff-lcs-1.2.5/spec/traverse_balanced_spec.rb +310 -0
- data/path/gems/diff-lcs-1.2.5/spec/traverse_sequences_spec.rb +139 -0
- data/path/gems/rspec-3.3.0/License.txt +24 -0
- data/path/gems/rspec-3.3.0/README.md +34 -0
- data/path/gems/rspec-3.3.0/lib/rspec.rb +3 -0
- data/path/gems/rspec-3.3.0/lib/rspec/version.rb +5 -0
- data/path/gems/rspec-core-3.3.2/.document +5 -0
- data/path/gems/rspec-core-3.3.2/.yardopts +8 -0
- data/path/gems/rspec-core-3.3.2/Changelog.md +1856 -0
- data/path/gems/rspec-core-3.3.2/License.txt +25 -0
- data/path/gems/rspec-core-3.3.2/README.md +369 -0
- data/path/gems/rspec-core-3.3.2/exe/rspec +4 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/autorun.rb +3 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core.rb +181 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/backtrace_formatter.rb +64 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/bisect/coordinator.rb +66 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/bisect/example_minimizer.rb +130 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/bisect/runner.rb +139 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/bisect/server.rb +61 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/bisect/subset_enumerator.rb +39 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb +1807 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/configuration_options.rb +191 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/drb.rb +111 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/dsl.rb +96 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/example.rb +573 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/example_group.rb +796 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/example_status_persister.rb +235 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/filter_manager.rb +231 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/flat_map.rb +20 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters.rb +254 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/base_formatter.rb +70 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/base_text_formatter.rb +77 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/bisect_formatter.rb +68 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/bisect_progress_formatter.rb +115 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/console_codes.rb +65 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/deprecation_formatter.rb +223 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/documentation_formatter.rb +70 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/exception_presenter.rb +393 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/fallback_message_formatter.rb +28 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/helpers.rb +109 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/html_formatter.rb +151 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/html_printer.rb +415 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/json_formatter.rb +96 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/profile_formatter.rb +68 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/progress_formatter.rb +28 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/protocol.rb +172 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/snippet_extractor.rb +116 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/hooks.rb +638 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/memoized_helpers.rb +532 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/metadata.rb +490 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/metadata_filter.rb +235 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/minitest_assertions_adapter.rb +31 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/mocking_adapters/flexmock.rb +31 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/mocking_adapters/mocha.rb +57 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/mocking_adapters/null.rb +14 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/mocking_adapters/rr.rb +31 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/mocking_adapters/rspec.rb +32 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/mutex.rb +63 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/notifications.rb +498 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/option_parser.rb +301 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/ordering.rb +158 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/pending.rb +165 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/profiler.rb +32 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/project_initializer.rb +48 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/project_initializer/.rspec +2 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/project_initializer/spec/spec_helper.rb +96 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/rake_task.rb +158 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/reentrant_mutex.rb +52 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/reporter.rb +220 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/ruby_project.rb +53 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb +179 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/sandbox.rb +37 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/set.rb +49 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/shared_context.rb +55 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/shared_example_group.rb +210 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/shell_escape.rb +49 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/version.rb +9 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/warnings.rb +40 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/world.rb +178 -0
- data/path/gems/rspec-expectations-3.3.1/.document +5 -0
- data/path/gems/rspec-expectations-3.3.1/.yardopts +6 -0
- data/path/gems/rspec-expectations-3.3.1/Changelog.md +953 -0
- data/path/gems/rspec-expectations-3.3.1/License.txt +24 -0
- data/path/gems/rspec-expectations-3.3.1/README.md +289 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations.rb +81 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/configuration.rb +164 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/expectation_target.rb +113 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/fail_with.rb +31 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/failure_aggregator.rb +194 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/handler.rb +170 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/minitest_integration.rb +31 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/syntax.rb +132 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/version.rb +8 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers.rb +1009 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/aliased_matcher.rb +116 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in.rb +52 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/all.rb +85 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/base_matcher.rb +181 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/be.rb +285 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/be_between.rb +77 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/be_instance_of.rb +22 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/be_kind_of.rb +16 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/be_within.rb +72 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/change.rb +337 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/compound.rb +293 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/contain_exactly.rb +253 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/cover.rb +24 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/eq.rb +40 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/eql.rb +34 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/equal.rb +81 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/exist.rb +86 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/has.rb +103 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/have_attributes.rb +114 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/include.rb +130 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/match.rb +37 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/operators.rb +128 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/output.rb +200 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/raise_error.rb +216 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/respond_to.rb +90 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/satisfy.rb +37 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/start_or_end_with.rb +94 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/throw_symbol.rb +132 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/yield.rb +418 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/composable.rb +184 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/dsl.rb +453 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/english_phrasing.rb +42 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/expecteds_for_multiple_diffs.rb +73 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/fail_matchers.rb +42 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/generated_descriptions.rb +42 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/matcher_delegator.rb +35 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/matcher_protocol.rb +99 -0
- data/path/gems/rspec-mocks-3.3.2/.document +5 -0
- data/path/gems/rspec-mocks-3.3.2/.yardopts +6 -0
- data/path/gems/rspec-mocks-3.3.2/Changelog.md +965 -0
- data/path/gems/rspec-mocks-3.3.2/License.txt +24 -0
- data/path/gems/rspec-mocks-3.3.2/README.md +430 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks.rb +126 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance.rb +11 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/chain.rb +110 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/error_generator.rb +31 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/expect_chain_chain.rb +35 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/expectation_chain.rb +48 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/message_chains.rb +83 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/proxy.rb +116 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/recorder.rb +264 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/stub_chain.rb +46 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/stub_chain_chain.rb +27 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/argument_list_matcher.rb +100 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/argument_matchers.rb +320 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/configuration.rb +188 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/error_generator.rb +362 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/example_methods.rb +421 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/instance_method_stasher.rb +135 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/marshal_extension.rb +41 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/matchers/expectation_customization.rb +20 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/matchers/have_received.rb +116 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/matchers/receive.rb +130 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/matchers/receive_message_chain.rb +80 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/matchers/receive_messages.rb +75 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/message_chain.rb +87 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/message_expectation.rb +717 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/method_double.rb +287 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/method_reference.rb +192 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/mutate_const.rb +335 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/mutex.rb +73 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/object_reference.rb +149 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/order_group.rb +81 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/proxy.rb +439 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/reentrant_mutex.rb +53 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/space.rb +238 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/standalone.rb +3 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/syntax.rb +325 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/targets.rb +97 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/test_double.rb +170 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/verifying_double.rb +129 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/verifying_message_expecation.rb +54 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/verifying_proxy.rb +213 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/version.rb +9 -0
- data/path/gems/rspec-support-3.3.0/Changelog.md +125 -0
- data/path/gems/rspec-support-3.3.0/LICENSE.txt +22 -0
- data/path/gems/rspec-support-3.3.0/README.md +26 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support.rb +111 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/caller_filter.rb +83 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/differ.rb +215 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/directory_maker.rb +63 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/encoded_string.rb +155 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/fuzzy_matcher.rb +48 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/hunk_generator.rb +47 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/matcher_definition.rb +42 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/method_signature_verifier.rb +273 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/object_formatter.rb +93 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/recursive_const_methods.rb +76 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/ruby_features.rb +118 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec.rb +81 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/deprecation_helpers.rb +64 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/formatting_support.rb +9 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/in_sub_process.rb +52 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/library_wide_checks.rb +145 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/shell_out.rb +71 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/stderr_splitter.rb +63 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/string_matcher.rb +46 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/with_isolated_directory.rb +9 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/with_isolated_stderr.rb +13 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/version.rb +7 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/version_checker.rb +53 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/warnings.rb +39 -0
- data/path/specifications/diff-lcs-1.2.5.gemspec +68 -0
- data/path/specifications/rspec-3.3.0.gemspec +42 -0
- data/path/specifications/rspec-core-3.3.2.gemspec +68 -0
- data/path/specifications/rspec-expectations-3.3.1.gemspec +50 -0
- data/path/specifications/rspec-mocks-3.3.2.gemspec +53 -0
- data/path/specifications/rspec-support-3.3.0.gemspec +38 -0
- data/sublimetheme.gemspec +32 -0
- metadata +363 -0
@@ -0,0 +1,149 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
class Diff::LCS::HTMLDiff
|
6
|
+
class << self
|
7
|
+
attr_accessor :can_expand_tabs #:nodoc:
|
8
|
+
end
|
9
|
+
self.can_expand_tabs = true
|
10
|
+
|
11
|
+
class Callbacks
|
12
|
+
attr_accessor :output
|
13
|
+
attr_accessor :match_class
|
14
|
+
attr_accessor :only_a_class
|
15
|
+
attr_accessor :only_b_class
|
16
|
+
|
17
|
+
def initialize(output, options = {})
|
18
|
+
@output = output
|
19
|
+
options ||= {}
|
20
|
+
|
21
|
+
@match_class = options[:match_class] || "match"
|
22
|
+
@only_a_class = options[:only_a_class] || "only_a"
|
23
|
+
@only_b_class = options[:only_b_class] || "only_b"
|
24
|
+
end
|
25
|
+
|
26
|
+
def htmlize(element, css_class)
|
27
|
+
element = " " if element.empty?
|
28
|
+
%Q|<pre class="#{__send__(css_class)}">#{element}</pre>\n|
|
29
|
+
end
|
30
|
+
private :htmlize
|
31
|
+
|
32
|
+
# This will be called with both lines are the same
|
33
|
+
def match(event)
|
34
|
+
@output << htmlize(event.old_element, :match_class)
|
35
|
+
end
|
36
|
+
|
37
|
+
# This will be called when there is a line in A that isn't in B
|
38
|
+
def discard_a(event)
|
39
|
+
@output << htmlize(event.old_element, :only_a_class)
|
40
|
+
end
|
41
|
+
|
42
|
+
# This will be called when there is a line in B that isn't in A
|
43
|
+
def discard_b(event)
|
44
|
+
@output << htmlize(event.new_element, :only_b_class)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
DEFAULT_OPTIONS = {
|
49
|
+
:expand_tabs => nil,
|
50
|
+
:output => nil,
|
51
|
+
:css => nil,
|
52
|
+
:title => nil,
|
53
|
+
}
|
54
|
+
|
55
|
+
DEFAULT_CSS = <<-CSS
|
56
|
+
body { margin: 0; }
|
57
|
+
.diff
|
58
|
+
{
|
59
|
+
border: 1px solid black;
|
60
|
+
margin: 1em 2em;
|
61
|
+
}
|
62
|
+
p
|
63
|
+
{
|
64
|
+
margin-left: 2em;
|
65
|
+
}
|
66
|
+
pre
|
67
|
+
{
|
68
|
+
padding-left: 1em;
|
69
|
+
margin: 0;
|
70
|
+
font-family: Inconsolata, Consolas, Lucida, Courier, monospaced;
|
71
|
+
white-space: pre;
|
72
|
+
}
|
73
|
+
.match { }
|
74
|
+
.only_a
|
75
|
+
{
|
76
|
+
background-color: #fdd;
|
77
|
+
color: red;
|
78
|
+
text-decoration: line-through;
|
79
|
+
}
|
80
|
+
.only_b
|
81
|
+
{
|
82
|
+
background-color: #ddf;
|
83
|
+
color: blue;
|
84
|
+
border-left: 3px solid blue
|
85
|
+
}
|
86
|
+
h1 { margin-left: 2em; }
|
87
|
+
CSS
|
88
|
+
|
89
|
+
def initialize(left, right, options = nil)
|
90
|
+
@left = left
|
91
|
+
@right = right
|
92
|
+
@options = options
|
93
|
+
|
94
|
+
@options = DEFAULT_OPTIONS.dup if @options.nil?
|
95
|
+
end
|
96
|
+
|
97
|
+
def verify_options
|
98
|
+
@options[:expand_tabs] ||= 4
|
99
|
+
@options[:expand_tabs] = 4 if @options[:expand_tabs] < 0
|
100
|
+
|
101
|
+
@options[:output] ||= $stdout
|
102
|
+
|
103
|
+
@options[:css] ||= DEFAULT_CSS.dup
|
104
|
+
|
105
|
+
@options[:title] ||= "diff"
|
106
|
+
end
|
107
|
+
private :verify_options
|
108
|
+
|
109
|
+
attr_reader :options
|
110
|
+
|
111
|
+
def run
|
112
|
+
verify_options
|
113
|
+
|
114
|
+
if @options[:expand_tabs] > 0 && self.class.can_expand_tabs
|
115
|
+
formatter = Text::Format.new
|
116
|
+
formatter.tabstop = @options[:expand_tabs]
|
117
|
+
|
118
|
+
@left = left.map { |line| formatter.expand(line.chomp) }
|
119
|
+
@right = right.map { |line| formatter.expand(line.chomp) }
|
120
|
+
end
|
121
|
+
|
122
|
+
@left.map! { |line| CGI.escapeHTML(line.chomp) }
|
123
|
+
@right.map! { |line| CGI.escapeHTML(line.chomp) }
|
124
|
+
|
125
|
+
@options[:output] << <<-OUTPUT
|
126
|
+
<html>
|
127
|
+
<head>
|
128
|
+
<title>#{@options[:title]}</title>
|
129
|
+
<style type="text/css">
|
130
|
+
#{@options[:css]}
|
131
|
+
</style>
|
132
|
+
</head>
|
133
|
+
<body>
|
134
|
+
<h1>#{@options[:title]}</h1>
|
135
|
+
<p>Legend: <span class="only_a">Only in Old</span>
|
136
|
+
<span class="only_b">Only in New</span></p>
|
137
|
+
<div class="diff">
|
138
|
+
OUTPUT
|
139
|
+
|
140
|
+
callbacks = Callbacks.new(@options[:output])
|
141
|
+
Diff::LCS.traverse_sequences(@left, @right, callbacks)
|
142
|
+
|
143
|
+
@options[:output] << <<-OUTPUT
|
144
|
+
</div>
|
145
|
+
</body>
|
146
|
+
</html>
|
147
|
+
OUTPUT
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,276 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'diff/lcs/block'
|
4
|
+
|
5
|
+
# A Hunk is a group of Blocks which overlap because of the context
|
6
|
+
# surrounding each block. (So if we're not using context, every hunk will
|
7
|
+
# contain one block.) Used in the diff program (bin/diff).
|
8
|
+
class Diff::LCS::Hunk
|
9
|
+
# Create a hunk using references to both the old and new data, as well as
|
10
|
+
# the piece of data.
|
11
|
+
def initialize(data_old, data_new, piece, flag_context, file_length_difference)
|
12
|
+
# At first, a hunk will have just one Block in it
|
13
|
+
@blocks = [ Diff::LCS::Block.new(piece) ]
|
14
|
+
if String.method_defined?(:encoding)
|
15
|
+
@preferred_data_encoding = data_old.fetch(0, data_new.fetch(0,'') ).encoding
|
16
|
+
end
|
17
|
+
@data_old = data_old
|
18
|
+
@data_new = data_new
|
19
|
+
|
20
|
+
before = after = file_length_difference
|
21
|
+
after += @blocks[0].diff_size
|
22
|
+
@file_length_difference = after # The caller must get this manually
|
23
|
+
|
24
|
+
# Save the start & end of each array. If the array doesn't exist (e.g.,
|
25
|
+
# we're only adding items in this block), then figure out the line
|
26
|
+
# number based on the line number of the other file and the current
|
27
|
+
# difference in file lengths.
|
28
|
+
if @blocks[0].remove.empty?
|
29
|
+
a1 = a2 = nil
|
30
|
+
else
|
31
|
+
a1 = @blocks[0].remove[0].position
|
32
|
+
a2 = @blocks[0].remove[-1].position
|
33
|
+
end
|
34
|
+
|
35
|
+
if @blocks[0].insert.empty?
|
36
|
+
b1 = b2 = nil
|
37
|
+
else
|
38
|
+
b1 = @blocks[0].insert[0].position
|
39
|
+
b2 = @blocks[0].insert[-1].position
|
40
|
+
end
|
41
|
+
|
42
|
+
@start_old = a1 || (b1 - before)
|
43
|
+
@start_new = b1 || (a1 + before)
|
44
|
+
@end_old = a2 || (b2 - after)
|
45
|
+
@end_new = b2 || (a2 + after)
|
46
|
+
|
47
|
+
self.flag_context = flag_context
|
48
|
+
end
|
49
|
+
|
50
|
+
attr_reader :blocks
|
51
|
+
attr_reader :start_old, :start_new
|
52
|
+
attr_reader :end_old, :end_new
|
53
|
+
attr_reader :file_length_difference
|
54
|
+
|
55
|
+
# Change the "start" and "end" fields to note that context should be added
|
56
|
+
# to this hunk.
|
57
|
+
attr_accessor :flag_context
|
58
|
+
undef :flag_context=;
|
59
|
+
def flag_context=(context) #:nodoc:
|
60
|
+
return if context.nil? or context.zero?
|
61
|
+
|
62
|
+
add_start = (context > @start_old) ? @start_old : context
|
63
|
+
@start_old -= add_start
|
64
|
+
@start_new -= add_start
|
65
|
+
|
66
|
+
if (@end_old + context) > @data_old.size
|
67
|
+
add_end = @data_old.size - @end_old
|
68
|
+
else
|
69
|
+
add_end = context
|
70
|
+
end
|
71
|
+
@end_old += add_end
|
72
|
+
@end_new += add_end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Merges this hunk and the provided hunk together if they overlap. Returns
|
76
|
+
# a truthy value so that if there is no overlap, you can know the merge
|
77
|
+
# was skipped.
|
78
|
+
def merge(hunk)
|
79
|
+
if overlaps?(hunk)
|
80
|
+
@start_old = hunk.start_old
|
81
|
+
@start_new = hunk.start_new
|
82
|
+
blocks.unshift(*hunk.blocks)
|
83
|
+
else
|
84
|
+
nil
|
85
|
+
end
|
86
|
+
end
|
87
|
+
alias_method :unshift, :merge
|
88
|
+
|
89
|
+
# Determines whether there is an overlap between this hunk and the
|
90
|
+
# provided hunk. This will be true if the difference between the two hunks
|
91
|
+
# start or end positions is within one position of each other.
|
92
|
+
def overlaps?(hunk)
|
93
|
+
hunk and (((@start_old - hunk.end_old) <= 1) or
|
94
|
+
((@start_new - hunk.end_new) <= 1))
|
95
|
+
end
|
96
|
+
|
97
|
+
# Returns a diff string based on a format.
|
98
|
+
def diff(format)
|
99
|
+
case format
|
100
|
+
when :old
|
101
|
+
old_diff
|
102
|
+
when :unified
|
103
|
+
unified_diff
|
104
|
+
when :context
|
105
|
+
context_diff
|
106
|
+
when :ed
|
107
|
+
self
|
108
|
+
when :reverse_ed, :ed_finish
|
109
|
+
ed_diff(format)
|
110
|
+
else
|
111
|
+
raise "Unknown diff format #{format}."
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Note that an old diff can't have any context. Therefore, we know that
|
116
|
+
# there's only one block in the hunk.
|
117
|
+
def old_diff
|
118
|
+
warn "Expecting only one block in an old diff hunk!" if @blocks.size > 1
|
119
|
+
op_act = { "+" => 'a', "-" => 'd', "!" => "c" }
|
120
|
+
|
121
|
+
block = @blocks[0]
|
122
|
+
|
123
|
+
# Calculate item number range. Old diff range is just like a context
|
124
|
+
# diff range, except the ranges are on one line with the action between
|
125
|
+
# them.
|
126
|
+
s = encode("#{context_range(:old)}#{op_act[block.op]}#{context_range(:new)}\n")
|
127
|
+
# If removing anything, just print out all the remove lines in the hunk
|
128
|
+
# which is just all the remove lines in the block.
|
129
|
+
@data_old[@start_old .. @end_old].each { |e| s << encode("< ") + e + encode("\n") } unless block.remove.empty?
|
130
|
+
s << encode("---\n") if block.op == "!"
|
131
|
+
@data_new[@start_new .. @end_new].each { |e| s << encode("> ") + e + encode("\n") } unless block.insert.empty?
|
132
|
+
s
|
133
|
+
end
|
134
|
+
private :old_diff
|
135
|
+
|
136
|
+
def unified_diff
|
137
|
+
# Calculate item number range.
|
138
|
+
s = encode("@@ -#{unified_range(:old)} +#{unified_range(:new)} @@\n")
|
139
|
+
|
140
|
+
# Outlist starts containing the hunk of the old file. Removing an item
|
141
|
+
# just means putting a '-' in front of it. Inserting an item requires
|
142
|
+
# getting it from the new file and splicing it in. We splice in
|
143
|
+
# +num_added+ items. Remove blocks use +num_added+ because splicing
|
144
|
+
# changed the length of outlist.
|
145
|
+
#
|
146
|
+
# We remove +num_removed+ items. Insert blocks use +num_removed+
|
147
|
+
# because their item numbers -- corresponding to positions in the NEW
|
148
|
+
# file -- don't take removed items into account.
|
149
|
+
lo, hi, num_added, num_removed = @start_old, @end_old, 0, 0
|
150
|
+
|
151
|
+
outlist = @data_old[lo .. hi].map { |e| e.insert(0, encode(' ')) }
|
152
|
+
|
153
|
+
@blocks.each do |block|
|
154
|
+
block.remove.each do |item|
|
155
|
+
op = item.action.to_s # -
|
156
|
+
offset = item.position - lo + num_added
|
157
|
+
outlist[offset][0, 1] = encode(op)
|
158
|
+
num_removed += 1
|
159
|
+
end
|
160
|
+
block.insert.each do |item|
|
161
|
+
op = item.action.to_s # +
|
162
|
+
offset = item.position - @start_new + num_removed
|
163
|
+
outlist[offset, 0] = encode(op) + @data_new[item.position]
|
164
|
+
num_added += 1
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
s << outlist.join(encode("\n"))
|
169
|
+
end
|
170
|
+
private :unified_diff
|
171
|
+
|
172
|
+
def context_diff
|
173
|
+
s = encode("***************\n")
|
174
|
+
s << encode("*** #{context_range(:old)} ****\n")
|
175
|
+
r = context_range(:new)
|
176
|
+
|
177
|
+
# Print out file 1 part for each block in context diff format if there
|
178
|
+
# are any blocks that remove items
|
179
|
+
lo, hi = @start_old, @end_old
|
180
|
+
removes = @blocks.select { |e| not e.remove.empty? }
|
181
|
+
if removes
|
182
|
+
outlist = @data_old[lo .. hi].map { |e| e.insert(0, encode(' ')) }
|
183
|
+
|
184
|
+
removes.each do |block|
|
185
|
+
block.remove.each do |item|
|
186
|
+
outlist[item.position - lo][0, 1] = encode(block.op) # - or !
|
187
|
+
end
|
188
|
+
end
|
189
|
+
s << outlist.join("\n")
|
190
|
+
end
|
191
|
+
|
192
|
+
s << encode("\n--- #{r} ----\n")
|
193
|
+
lo, hi = @start_new, @end_new
|
194
|
+
inserts = @blocks.select { |e| not e.insert.empty? }
|
195
|
+
if inserts
|
196
|
+
outlist = @data_new[lo .. hi].collect { |e| e.insert(0, encode(' ')) }
|
197
|
+
inserts.each do |block|
|
198
|
+
block.insert.each do |item|
|
199
|
+
outlist[item.position - lo][0, 1] = encode(block.op) # + or !
|
200
|
+
end
|
201
|
+
end
|
202
|
+
s << outlist.join("\n")
|
203
|
+
end
|
204
|
+
s
|
205
|
+
end
|
206
|
+
private :context_diff
|
207
|
+
|
208
|
+
def ed_diff(format)
|
209
|
+
op_act = { "+" => 'a', "-" => 'd', "!" => "c" }
|
210
|
+
warn "Expecting only one block in an old diff hunk!" if @blocks.size > 1
|
211
|
+
|
212
|
+
if format == :reverse_ed
|
213
|
+
s = encode("#{op_act[@blocks[0].op]}#{context_range(:old)}\n")
|
214
|
+
else
|
215
|
+
s = encode("#{context_range(:old, ' ')}#{op_act[@blocks[0].op]}\n")
|
216
|
+
end
|
217
|
+
|
218
|
+
unless @blocks[0].insert.empty?
|
219
|
+
@data_new[@start_new .. @end_new].each { |e| s << e + encode("\n") }
|
220
|
+
s << encode(".\n")
|
221
|
+
end
|
222
|
+
s
|
223
|
+
end
|
224
|
+
private :ed_diff
|
225
|
+
|
226
|
+
# Generate a range of item numbers to print. Only print 1 number if the
|
227
|
+
# range has only one item in it. Otherwise, it's 'start,end'
|
228
|
+
def context_range(mode, op = ',')
|
229
|
+
case mode
|
230
|
+
when :old
|
231
|
+
s, e = (@start_old + 1), (@end_old + 1)
|
232
|
+
when :new
|
233
|
+
s, e = (@start_new + 1), (@end_new + 1)
|
234
|
+
end
|
235
|
+
|
236
|
+
(s < e) ? "#{s}#{op}#{e}" : "#{e}"
|
237
|
+
end
|
238
|
+
private :context_range
|
239
|
+
|
240
|
+
# Generate a range of item numbers to print for unified diff. Print number
|
241
|
+
# where block starts, followed by number of lines in the block
|
242
|
+
# (don't print number of lines if it's 1)
|
243
|
+
def unified_range(mode)
|
244
|
+
case mode
|
245
|
+
when :old
|
246
|
+
s, e = (@start_old + 1), (@end_old + 1)
|
247
|
+
when :new
|
248
|
+
s, e = (@start_new + 1), (@end_new + 1)
|
249
|
+
end
|
250
|
+
|
251
|
+
length = e - s + 1
|
252
|
+
first = (length < 2) ? e : s # "strange, but correct"
|
253
|
+
(length == 1) ? "#{first}" : "#{first},#{length}"
|
254
|
+
end
|
255
|
+
private :unified_range
|
256
|
+
|
257
|
+
if String.method_defined?(:encoding)
|
258
|
+
def encode(literal, target_encoding = @preferred_data_encoding)
|
259
|
+
literal.encode target_encoding
|
260
|
+
end
|
261
|
+
|
262
|
+
def encode_as(string, *args)
|
263
|
+
args.map { |arg| arg.encode(string.encoding) }
|
264
|
+
end
|
265
|
+
else
|
266
|
+
def encode(literal, target_encoding = nil)
|
267
|
+
literal
|
268
|
+
end
|
269
|
+
def encode_as(string, *args)
|
270
|
+
args
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
private :encode
|
275
|
+
private :encode_as
|
276
|
+
end
|
@@ -0,0 +1,301 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
|
3
|
+
class << Diff::LCS
|
4
|
+
def diff_traversal(method, seq1, seq2, callbacks, &block)
|
5
|
+
callbacks = callbacks_for(callbacks)
|
6
|
+
case method
|
7
|
+
when :diff
|
8
|
+
traverse_sequences(seq1, seq2, callbacks)
|
9
|
+
when :sdiff
|
10
|
+
traverse_balanced(seq1, seq2, callbacks)
|
11
|
+
end
|
12
|
+
callbacks.finish if callbacks.respond_to? :finish
|
13
|
+
|
14
|
+
if block
|
15
|
+
callbacks.diffs.map do |hunk|
|
16
|
+
if hunk.kind_of? Array
|
17
|
+
hunk.map { |hunk_block| block[hunk_block] }
|
18
|
+
else
|
19
|
+
block[hunk]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
else
|
23
|
+
callbacks.diffs
|
24
|
+
end
|
25
|
+
end
|
26
|
+
private :diff_traversal
|
27
|
+
end
|
28
|
+
|
29
|
+
module Diff::LCS::Internals # :nodoc:
|
30
|
+
end
|
31
|
+
|
32
|
+
class << Diff::LCS::Internals
|
33
|
+
# Compute the longest common subsequence between the sequenced
|
34
|
+
# Enumerables +a+ and +b+. The result is an array whose contents is such
|
35
|
+
# that
|
36
|
+
#
|
37
|
+
# result = Diff::LCS::Internals.lcs(a, b)
|
38
|
+
# result.each_with_index do |e, i|
|
39
|
+
# assert_equal(a[i], b[e]) unless e.nil?
|
40
|
+
# end
|
41
|
+
def lcs(a, b)
|
42
|
+
a_start = b_start = 0
|
43
|
+
a_finish = a.size - 1
|
44
|
+
b_finish = b.size - 1
|
45
|
+
vector = []
|
46
|
+
|
47
|
+
# Prune off any common elements at the beginning...
|
48
|
+
while ((a_start <= a_finish) and (b_start <= b_finish) and
|
49
|
+
(a[a_start] == b[b_start]))
|
50
|
+
vector[a_start] = b_start
|
51
|
+
a_start += 1
|
52
|
+
b_start += 1
|
53
|
+
end
|
54
|
+
b_start = a_start
|
55
|
+
|
56
|
+
# Now the end...
|
57
|
+
while ((a_start <= a_finish) and (b_start <= b_finish) and
|
58
|
+
(a[a_finish] == b[b_finish]))
|
59
|
+
vector[a_finish] = b_finish
|
60
|
+
a_finish -= 1
|
61
|
+
b_finish -= 1
|
62
|
+
end
|
63
|
+
|
64
|
+
# Now, compute the equivalence classes of positions of elements.
|
65
|
+
b_matches = position_hash(b, b_start..b_finish)
|
66
|
+
|
67
|
+
thresh = []
|
68
|
+
links = []
|
69
|
+
string = a.kind_of?(String)
|
70
|
+
|
71
|
+
(a_start .. a_finish).each do |i|
|
72
|
+
ai = string ? a[i, 1] : a[i]
|
73
|
+
bm = b_matches[ai]
|
74
|
+
k = nil
|
75
|
+
bm.reverse_each do |j|
|
76
|
+
if k and (thresh[k] > j) and (thresh[k - 1] < j)
|
77
|
+
thresh[k] = j
|
78
|
+
else
|
79
|
+
k = replace_next_larger(thresh, j, k)
|
80
|
+
end
|
81
|
+
links[k] = [ (k > 0) ? links[k - 1] : nil, i, j ] unless k.nil?
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
unless thresh.empty?
|
86
|
+
link = links[thresh.size - 1]
|
87
|
+
while not link.nil?
|
88
|
+
vector[link[1]] = link[2]
|
89
|
+
link = link[0]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
vector
|
94
|
+
end
|
95
|
+
|
96
|
+
# This method will analyze the provided patchset to provide a
|
97
|
+
# single-pass normalization (conversion of the array form of
|
98
|
+
# Diff::LCS::Change objects to the object form of same) and detection of
|
99
|
+
# whether the patchset represents changes to be made.
|
100
|
+
def analyze_patchset(patchset, depth = 0)
|
101
|
+
raise "Patchset too complex" if depth > 1
|
102
|
+
|
103
|
+
has_changes = false
|
104
|
+
|
105
|
+
# Format:
|
106
|
+
# [ # patchset
|
107
|
+
# # hunk (change)
|
108
|
+
# [ # hunk
|
109
|
+
# # change
|
110
|
+
# ]
|
111
|
+
# ]
|
112
|
+
|
113
|
+
patchset = patchset.map do |hunk|
|
114
|
+
case hunk
|
115
|
+
when Diff::LCS::Change
|
116
|
+
has_changes ||= !hunk.unchanged?
|
117
|
+
hunk
|
118
|
+
when Array
|
119
|
+
# Detect if the 'hunk' is actually an array-format
|
120
|
+
# Change object.
|
121
|
+
if Diff::LCS::Change.valid_action? hunk[0]
|
122
|
+
hunk = Diff::LCS::Change.from_a(hunk)
|
123
|
+
has_changes ||= !hunk.unchanged?
|
124
|
+
hunk
|
125
|
+
else
|
126
|
+
with_changes, hunk = analyze_patchset(hunk, depth + 1)
|
127
|
+
has_changes ||= with_changes
|
128
|
+
hunk.flatten
|
129
|
+
end
|
130
|
+
else
|
131
|
+
raise ArgumentError, "Cannot normalise a hunk of class #{hunk.class}."
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
[ has_changes, patchset.flatten(1) ]
|
136
|
+
end
|
137
|
+
|
138
|
+
# Examine the patchset and the source to see in which direction the
|
139
|
+
# patch should be applied.
|
140
|
+
#
|
141
|
+
# WARNING: By default, this examines the whole patch, so this could take
|
142
|
+
# some time. This also works better with Diff::LCS::ContextChange or
|
143
|
+
# Diff::LCS::Change as its source, as an array will cause the creation
|
144
|
+
# of one of the above.
|
145
|
+
#
|
146
|
+
# Note: This will be deprecated as a public function in a future release.
|
147
|
+
def intuit_diff_direction(src, patchset, limit = nil)
|
148
|
+
string = src.kind_of?(String)
|
149
|
+
count = left_match = left_miss = right_match = right_miss = 0
|
150
|
+
|
151
|
+
patchset.each do |change|
|
152
|
+
count += 1
|
153
|
+
|
154
|
+
case change
|
155
|
+
when Diff::LCS::ContextChange
|
156
|
+
le = string ? src[change.old_position, 1] : src[change.old_position]
|
157
|
+
re = string ? src[change.new_position, 1] : src[change.new_position]
|
158
|
+
|
159
|
+
case change.action
|
160
|
+
when '-' # Remove details from the old string
|
161
|
+
if le == change.old_element
|
162
|
+
left_match += 1
|
163
|
+
else
|
164
|
+
left_miss += 1
|
165
|
+
end
|
166
|
+
when '+'
|
167
|
+
if re == change.new_element
|
168
|
+
right_match += 1
|
169
|
+
else
|
170
|
+
right_miss += 1
|
171
|
+
end
|
172
|
+
when '='
|
173
|
+
left_miss += 1 if le != change.old_element
|
174
|
+
right_miss += 1 if re != change.new_element
|
175
|
+
when '!'
|
176
|
+
if le == change.old_element
|
177
|
+
left_match += 1
|
178
|
+
else
|
179
|
+
if re == change.new_element
|
180
|
+
right_match += 1
|
181
|
+
else
|
182
|
+
left_miss += 1
|
183
|
+
right_miss += 1
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
when Diff::LCS::Change
|
188
|
+
# With a simplistic change, we can't tell the difference between
|
189
|
+
# the left and right on '!' actions, so we ignore those. On '='
|
190
|
+
# actions, if there's a miss, we miss both left and right.
|
191
|
+
element = string ? src[change.position, 1] : src[change.position]
|
192
|
+
|
193
|
+
case change.action
|
194
|
+
when '-'
|
195
|
+
if element == change.element
|
196
|
+
left_match += 1
|
197
|
+
else
|
198
|
+
left_miss += 1
|
199
|
+
end
|
200
|
+
when '+'
|
201
|
+
if element == change.element
|
202
|
+
right_match += 1
|
203
|
+
else
|
204
|
+
right_miss += 1
|
205
|
+
end
|
206
|
+
when '='
|
207
|
+
if element != change.element
|
208
|
+
left_miss += 1
|
209
|
+
right_miss += 1
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
break if (not limit.nil?) && (count > limit)
|
215
|
+
end
|
216
|
+
|
217
|
+
no_left = (left_match == 0) && (left_miss > 0)
|
218
|
+
no_right = (right_match == 0) && (right_miss > 0)
|
219
|
+
|
220
|
+
case [no_left, no_right]
|
221
|
+
when [false, true]
|
222
|
+
:patch
|
223
|
+
when [true, false]
|
224
|
+
:unpatch
|
225
|
+
else
|
226
|
+
case left_match <=> right_match
|
227
|
+
when 1
|
228
|
+
:patch
|
229
|
+
when -1
|
230
|
+
:unpatch
|
231
|
+
else
|
232
|
+
raise "The provided patchset does not appear to apply to the provided value as either source or destination value."
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
# Find the place at which +value+ would normally be inserted into the
|
238
|
+
# Enumerable. If that place is already occupied by +value+, do nothing
|
239
|
+
# and return +nil+. If the place does not exist (i.e., it is off the end
|
240
|
+
# of the Enumerable), add it to the end. Otherwise, replace the element
|
241
|
+
# at that point with +value+. It is assumed that the Enumerable's values
|
242
|
+
# are numeric.
|
243
|
+
#
|
244
|
+
# This operation preserves the sort order.
|
245
|
+
def replace_next_larger(enum, value, last_index = nil)
|
246
|
+
# Off the end?
|
247
|
+
if enum.empty? or (value > enum[-1])
|
248
|
+
enum << value
|
249
|
+
return enum.size - 1
|
250
|
+
end
|
251
|
+
|
252
|
+
# Binary search for the insertion point
|
253
|
+
last_index ||= enum.size
|
254
|
+
first_index = 0
|
255
|
+
while (first_index <= last_index)
|
256
|
+
i = (first_index + last_index) >> 1
|
257
|
+
|
258
|
+
found = enum[i]
|
259
|
+
|
260
|
+
if value == found
|
261
|
+
return nil
|
262
|
+
elsif value > found
|
263
|
+
first_index = i + 1
|
264
|
+
else
|
265
|
+
last_index = i - 1
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
# The insertion point is in first_index; overwrite the next larger
|
270
|
+
# value.
|
271
|
+
enum[first_index] = value
|
272
|
+
return first_index
|
273
|
+
end
|
274
|
+
private :replace_next_larger
|
275
|
+
|
276
|
+
# If +vector+ maps the matching elements of another collection onto this
|
277
|
+
# Enumerable, compute the inverse of +vector+ that maps this Enumerable
|
278
|
+
# onto the collection. (Currently unused.)
|
279
|
+
def inverse_vector(a, vector)
|
280
|
+
inverse = a.dup
|
281
|
+
(0...vector.size).each do |i|
|
282
|
+
inverse[vector[i]] = i unless vector[i].nil?
|
283
|
+
end
|
284
|
+
inverse
|
285
|
+
end
|
286
|
+
private :inverse_vector
|
287
|
+
|
288
|
+
# Returns a hash mapping each element of an Enumerable to the set of
|
289
|
+
# positions it occupies in the Enumerable, optionally restricted to the
|
290
|
+
# elements specified in the range of indexes specified by +interval+.
|
291
|
+
def position_hash(enum, interval)
|
292
|
+
string = enum.kind_of?(String)
|
293
|
+
hash = Hash.new { |h, k| h[k] = [] }
|
294
|
+
interval.each do |i|
|
295
|
+
k = string ? enum[i, 1] : enum[i]
|
296
|
+
hash[k] << i
|
297
|
+
end
|
298
|
+
hash
|
299
|
+
end
|
300
|
+
private :position_hash
|
301
|
+
end
|