super_diff 0.13.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/super_diff/active_record/differs/active_record_relation.rb +2 -0
- data/lib/super_diff/active_record/differs.rb +3 -1
- data/lib/super_diff/active_record/inspection_tree_builders/active_record_model.rb +7 -5
- data/lib/super_diff/active_record/inspection_tree_builders/active_record_relation.rb +12 -10
- data/lib/super_diff/active_record/inspection_tree_builders.rb +4 -2
- data/lib/super_diff/active_record/monkey_patches.rb +4 -2
- data/lib/super_diff/active_record/object_inspection.rb +6 -4
- data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +3 -1
- data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +3 -1
- data/lib/super_diff/active_record/operation_tree_builders.rb +4 -2
- data/lib/super_diff/active_record/operation_tree_flatteners/active_record_relation.rb +4 -2
- data/lib/super_diff/active_record/operation_tree_flatteners.rb +3 -1
- data/lib/super_diff/active_record/operation_trees/active_record_relation.rb +2 -0
- data/lib/super_diff/active_record/operation_trees.rb +3 -1
- data/lib/super_diff/active_record.rb +10 -8
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +2 -0
- data/lib/super_diff/active_support/differs.rb +3 -1
- data/lib/super_diff/active_support/inspection_tree_builders/hash_with_indifferent_access.rb +16 -14
- data/lib/super_diff/active_support/inspection_tree_builders/ordered_options.rb +16 -14
- data/lib/super_diff/active_support/inspection_tree_builders.rb +4 -2
- data/lib/super_diff/active_support/object_inspection.rb +6 -4
- data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +6 -4
- data/lib/super_diff/active_support/operation_tree_builders.rb +3 -1
- data/lib/super_diff/active_support/operation_tree_flatteners/hash_with_indifferent_access.rb +4 -2
- data/lib/super_diff/active_support/operation_tree_flatteners.rb +3 -1
- data/lib/super_diff/active_support/operation_trees/hash_with_indifferent_access.rb +2 -0
- data/lib/super_diff/active_support/operation_trees.rb +3 -1
- data/lib/super_diff/active_support.rb +8 -6
- data/lib/super_diff/basic/diff_formatters/collection.rb +18 -18
- data/lib/super_diff/basic/diff_formatters/multiline_string.rb +2 -0
- data/lib/super_diff/basic/diff_formatters.rb +4 -2
- data/lib/super_diff/basic/differs/array.rb +2 -0
- data/lib/super_diff/basic/differs/custom_object.rb +3 -1
- data/lib/super_diff/basic/differs/date_like.rb +2 -0
- data/lib/super_diff/basic/differs/default_object.rb +3 -1
- data/lib/super_diff/basic/differs/hash.rb +2 -0
- data/lib/super_diff/basic/differs/multiline_string.rb +2 -0
- data/lib/super_diff/basic/differs/time_like.rb +2 -0
- data/lib/super_diff/basic/differs.rb +11 -9
- data/lib/super_diff/basic/inspection_tree_builders/array.rb +5 -3
- data/lib/super_diff/basic/inspection_tree_builders/custom_object.rb +5 -3
- data/lib/super_diff/basic/inspection_tree_builders/data_object.rb +6 -4
- data/lib/super_diff/basic/inspection_tree_builders/date_like.rb +7 -5
- data/lib/super_diff/basic/inspection_tree_builders/default_object.rb +7 -5
- data/lib/super_diff/basic/inspection_tree_builders/hash.rb +7 -5
- data/lib/super_diff/basic/inspection_tree_builders/primitive.rb +2 -0
- data/lib/super_diff/basic/inspection_tree_builders/range_object.rb +19 -0
- data/lib/super_diff/basic/inspection_tree_builders/time_like.rb +8 -8
- data/lib/super_diff/basic/inspection_tree_builders.rb +15 -9
- data/lib/super_diff/basic/operation_tree_builders/array.rb +6 -4
- data/lib/super_diff/basic/operation_tree_builders/custom_object.rb +3 -1
- data/lib/super_diff/basic/operation_tree_builders/data_object.rb +4 -2
- data/lib/super_diff/basic/operation_tree_builders/date_like.rb +2 -0
- data/lib/super_diff/basic/operation_tree_builders/default_object.rb +32 -31
- data/lib/super_diff/basic/operation_tree_builders/hash.rb +49 -46
- data/lib/super_diff/basic/operation_tree_builders/multiline_string.rb +5 -3
- data/lib/super_diff/basic/operation_tree_builders/time_like.rb +5 -3
- data/lib/super_diff/basic/operation_tree_builders.rb +12 -10
- data/lib/super_diff/basic/operation_tree_flatteners/array.rb +4 -2
- data/lib/super_diff/basic/operation_tree_flatteners/collection.rb +11 -11
- data/lib/super_diff/basic/operation_tree_flatteners/custom_object.rb +5 -3
- data/lib/super_diff/basic/operation_tree_flatteners/default_object.rb +6 -5
- data/lib/super_diff/basic/operation_tree_flatteners/hash.rb +5 -3
- data/lib/super_diff/basic/operation_tree_flatteners/multiline_string.rb +3 -1
- data/lib/super_diff/basic/operation_tree_flatteners.rb +8 -6
- data/lib/super_diff/basic/operation_trees/array.rb +2 -0
- data/lib/super_diff/basic/operation_trees/custom_object.rb +2 -0
- data/lib/super_diff/basic/operation_trees/default_object.rb +6 -4
- data/lib/super_diff/basic/operation_trees/hash.rb +2 -0
- data/lib/super_diff/basic/operation_trees/multiline_string.rb +3 -1
- data/lib/super_diff/basic/operation_trees.rb +9 -7
- data/lib/super_diff/basic.rb +9 -6
- data/lib/super_diff/core/abstract_differ.rb +2 -0
- data/lib/super_diff/core/abstract_inspection_tree_builder.rb +2 -0
- data/lib/super_diff/core/abstract_operation_tree.rb +4 -2
- data/lib/super_diff/core/abstract_operation_tree_builder.rb +15 -18
- data/lib/super_diff/core/abstract_operation_tree_flattener.rb +5 -3
- data/lib/super_diff/core/binary_operation.rb +3 -1
- data/lib/super_diff/core/colorized_document_extensions.rb +2 -0
- data/lib/super_diff/core/configuration.rb +14 -38
- data/lib/super_diff/core/differ_dispatcher.rb +4 -2
- data/lib/super_diff/core/gem_version.rb +2 -0
- data/lib/super_diff/core/helpers.rb +13 -11
- data/lib/super_diff/core/implementation_checks.rb +6 -2
- data/lib/super_diff/core/inspection_tree.rb +38 -38
- data/lib/super_diff/core/inspection_tree_builder_dispatcher.rb +5 -5
- data/lib/super_diff/core/inspection_tree_nodes/as_lines_when_rendering_to_lines.rb +3 -1
- data/lib/super_diff/core/inspection_tree_nodes/as_prefix_when_rendering_to_lines.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/as_prelude_when_rendering_to_lines.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/as_single_line.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/base.rb +9 -9
- data/lib/super_diff/core/inspection_tree_nodes/inspection.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/nesting.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/only_when.rb +5 -1
- data/lib/super_diff/core/inspection_tree_nodes/text.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/when_empty.rb +3 -1
- data/lib/super_diff/core/inspection_tree_nodes/when_non_empty.rb +3 -1
- data/lib/super_diff/core/inspection_tree_nodes/when_rendering_to_lines.rb +3 -1
- data/lib/super_diff/core/inspection_tree_nodes/when_rendering_to_string.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes.rb +16 -14
- data/lib/super_diff/core/line.rb +9 -7
- data/lib/super_diff/core/no_differ_available_error.rb +7 -5
- data/lib/super_diff/core/no_inspection_tree_builder_available_error.rb +5 -3
- data/lib/super_diff/core/no_operation_tree_available_error.rb +4 -2
- data/lib/super_diff/core/no_operation_tree_builder_available_error.rb +7 -5
- data/lib/super_diff/core/operation_tree_builder_dispatcher.rb +3 -3
- data/lib/super_diff/core/operation_tree_finder.rb +8 -8
- data/lib/super_diff/core/prefix_for_next_inspection_tree_node.rb +2 -0
- data/lib/super_diff/core/prelude_for_next_inspection_tree_node.rb +2 -0
- data/lib/super_diff/core/recursion_guard.rb +6 -4
- data/lib/super_diff/core/tiered_lines.rb +2 -0
- data/lib/super_diff/core/tiered_lines_elider.rb +53 -54
- data/lib/super_diff/core/tiered_lines_formatter.rb +6 -4
- data/lib/super_diff/core/unary_operation.rb +2 -0
- data/lib/super_diff/core.rb +31 -29
- data/lib/super_diff/csi/bold_sequence.rb +2 -0
- data/lib/super_diff/csi/color.rb +4 -4
- data/lib/super_diff/csi/color_sequence_block.rb +3 -1
- data/lib/super_diff/csi/colorized_document.rb +7 -9
- data/lib/super_diff/csi/document.rb +15 -18
- data/lib/super_diff/csi/eight_bit_color.rb +32 -37
- data/lib/super_diff/csi/four_bit_color.rb +12 -9
- data/lib/super_diff/csi/reset_sequence.rb +2 -0
- data/lib/super_diff/csi/twenty_four_bit_color.rb +22 -21
- data/lib/super_diff/csi/uncolorized_document.rb +2 -0
- data/lib/super_diff/csi.rb +12 -10
- data/lib/super_diff/differs.rb +6 -4
- data/lib/super_diff/equality_matchers/array.rb +18 -16
- data/lib/super_diff/equality_matchers/base.rb +6 -4
- data/lib/super_diff/equality_matchers/default.rb +5 -3
- data/lib/super_diff/equality_matchers/defaults.rb +2 -0
- data/lib/super_diff/equality_matchers/hash.rb +18 -16
- data/lib/super_diff/equality_matchers/main.rb +3 -1
- data/lib/super_diff/equality_matchers/multiline_string.rb +18 -16
- data/lib/super_diff/equality_matchers/primitive.rb +15 -13
- data/lib/super_diff/equality_matchers/singleline_string.rb +16 -14
- data/lib/super_diff/equality_matchers.rb +11 -9
- data/lib/super_diff/errors.rb +4 -2
- data/lib/super_diff/object_inspection.rb +17 -15
- data/lib/super_diff/operation_tree_builders.rb +6 -4
- data/lib/super_diff/operation_tree_flatteners.rb +6 -4
- data/lib/super_diff/operation_trees.rb +6 -4
- data/lib/super_diff/operations.rb +4 -2
- data/lib/super_diff/rails.rb +4 -2
- data/lib/super_diff/rspec/augmented_matcher.rb +3 -1
- data/lib/super_diff/rspec/differ.rb +16 -7
- data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +2 -0
- data/lib/super_diff/rspec/differs/collection_including.rb +2 -0
- data/lib/super_diff/rspec/differs/hash_including.rb +2 -0
- data/lib/super_diff/rspec/differs/object_having_attributes.rb +2 -0
- data/lib/super_diff/rspec/differs.rb +6 -4
- data/lib/super_diff/rspec/inspection_tree_builders/collection_containing_exactly.rb +12 -10
- data/lib/super_diff/rspec/inspection_tree_builders/collection_including.rb +10 -8
- data/lib/super_diff/rspec/inspection_tree_builders/double.rb +20 -18
- data/lib/super_diff/rspec/inspection_tree_builders/generic_describable_matcher.rb +2 -0
- data/lib/super_diff/rspec/inspection_tree_builders/hash_including.rb +10 -8
- data/lib/super_diff/rspec/inspection_tree_builders/instance_of.rb +2 -0
- data/lib/super_diff/rspec/inspection_tree_builders/kind_of.rb +2 -0
- data/lib/super_diff/rspec/inspection_tree_builders/object_having_attributes.rb +12 -10
- data/lib/super_diff/rspec/inspection_tree_builders/primitive.rb +2 -0
- data/lib/super_diff/rspec/inspection_tree_builders/value_within.rb +6 -4
- data/lib/super_diff/rspec/inspection_tree_builders.rb +12 -10
- data/lib/super_diff/rspec/matcher_text_builders/base.rb +12 -12
- data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +19 -17
- data/lib/super_diff/rspec/matcher_text_builders/contain_exactly.rb +3 -1
- data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +7 -5
- data/lib/super_diff/rspec/matcher_text_builders/match.rb +6 -4
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +5 -3
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +20 -18
- data/lib/super_diff/rspec/matcher_text_builders.rb +9 -7
- data/lib/super_diff/rspec/matcher_text_template.rb +34 -39
- data/lib/super_diff/rspec/monkey_patches.rb +129 -56
- data/lib/super_diff/rspec/object_inspection.rb +7 -5
- data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +4 -4
- data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +2 -0
- data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +2 -0
- data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +2 -0
- data/lib/super_diff/rspec/operation_tree_builders.rb +6 -4
- data/lib/super_diff/rspec-rails.rb +4 -2
- data/lib/super_diff/rspec.rb +27 -14
- data/lib/super_diff/version.rb +3 -1
- data/lib/super_diff.rb +24 -26
- data/super_diff.gemspec +20 -19
- metadata +6 -185
- data/spec/examples.txt +0 -450
- data/spec/integration/rails/active_record_spec.rb +0 -21
- data/spec/integration/rails/active_support_spec.rb +0 -19
- data/spec/integration/rails/engines_spec.rb +0 -25
- data/spec/integration/rails/hash_with_indifferent_access_spec.rb +0 -21
- data/spec/integration/rspec/be_falsey_matcher_spec.rb +0 -58
- data/spec/integration/rspec/be_matcher_spec.rb +0 -605
- data/spec/integration/rspec/be_nil_matcher_spec.rb +0 -57
- data/spec/integration/rspec/be_predicate_matcher_spec.rb +0 -615
- data/spec/integration/rspec/be_truthy_matcher_spec.rb +0 -62
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +0 -377
- data/spec/integration/rspec/eq_matcher_spec.rb +0 -1066
- data/spec/integration/rspec/generic_describable_matchers_spec.rb +0 -177
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +0 -443
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +0 -478
- data/spec/integration/rspec/include_matcher_spec.rb +0 -452
- data/spec/integration/rspec/magic_metadata_spec.rb +0 -51
- data/spec/integration/rspec/match_array_matcher_spec.rb +0 -424
- data/spec/integration/rspec/match_matcher_spec.rb +0 -1359
- data/spec/integration/rspec/raise_error_matcher_spec.rb +0 -1488
- data/spec/integration/rspec/respond_to_matcher_spec.rb +0 -999
- data/spec/integration/rspec/third_party_matcher_spec.rb +0 -245
- data/spec/integration/rspec/unhandled_errors_spec.rb +0 -150
- data/spec/spec_helper.rb +0 -91
- data/spec/support/colorizer.rb +0 -9
- data/spec/support/command_runner.rb +0 -253
- data/spec/support/helpers.rb +0 -21
- data/spec/support/integration/helpers.rb +0 -124
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +0 -104
- data/spec/support/integration/matchers.rb +0 -177
- data/spec/support/integration/test_programs/base.rb +0 -143
- data/spec/support/integration/test_programs/plain.rb +0 -19
- data/spec/support/integration/test_programs/rspec_active_record.rb +0 -20
- data/spec/support/integration/test_programs/rspec_active_support.rb +0 -20
- data/spec/support/integration/test_programs/rspec_rails.rb +0 -20
- data/spec/support/integration/test_programs/rspec_rails_engine.rb +0 -20
- data/spec/support/models/a.rb +0 -11
- data/spec/support/models/active_record/person.rb +0 -28
- data/spec/support/models/active_record/query.rb +0 -15
- data/spec/support/models/active_record/shipping_address.rb +0 -24
- data/spec/support/models/customer.rb +0 -22
- data/spec/support/models/empty_class.rb +0 -6
- data/spec/support/models/item.rb +0 -10
- data/spec/support/models/order.rb +0 -9
- data/spec/support/models/person.rb +0 -20
- data/spec/support/models/player.rb +0 -30
- data/spec/support/models/point.rb +0 -7
- data/spec/support/models/shipping_address.rb +0 -25
- data/spec/support/shared_examples/active_record.rb +0 -428
- data/spec/support/shared_examples/active_support.rb +0 -188
- data/spec/support/shared_examples/elided_diffs.rb +0 -938
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +0 -749
- data/spec/support/shared_examples/key.rb +0 -123
- data/spec/support/unit/helpers.rb +0 -24
- data/spec/support/unit/matchers/be_deprecated_in_favor_of.rb +0 -39
- data/spec/support/unit/matchers/match_output.rb +0 -40
- data/spec/unit/active_record/object_inspection_spec.rb +0 -289
- data/spec/unit/active_support/object_inspection_spec.rb +0 -170
- data/spec/unit/basic/inspection_tree_builders/data_object_spec.rb +0 -146
- data/spec/unit/basic/operation_tree_builders/data_object_spec.rb +0 -82
- data/spec/unit/basic/operation_tree_flatteners/array_spec.rb +0 -637
- data/spec/unit/basic/operation_tree_flatteners/custom_object_spec.rb +0 -685
- data/spec/unit/basic/operation_tree_flatteners/default_object_spec.rb +0 -685
- data/spec/unit/basic/operation_tree_flatteners/hash_spec.rb +0 -671
- data/spec/unit/basic/operation_tree_flatteners/multiline_string_spec.rb +0 -131
- data/spec/unit/core/configuration_no_rspec_spec.rb +0 -58
- data/spec/unit/core/configuration_spec.rb +0 -176
- data/spec/unit/core/helpers_spec.rb +0 -68
- data/spec/unit/core/tiered_lines_elider_spec.rb +0 -6328
- data/spec/unit/core/tiered_lines_formatter_spec.rb +0 -131
- data/spec/unit/deprecations_spec.rb +0 -176
- data/spec/unit/equality_matchers/main_spec.rb +0 -1842
- data/spec/unit/rspec/matchers/be_compared_to_spec.rb +0 -23
- data/spec/unit/rspec/matchers/be_falsey_spec.rb +0 -9
- data/spec/unit/rspec/matchers/be_nil_spec.rb +0 -9
- data/spec/unit/rspec/matchers/be_predicate_spec.rb +0 -31
- data/spec/unit/rspec/matchers/be_spec.rb +0 -17
- data/spec/unit/rspec/matchers/be_truthy_spec.rb +0 -9
- data/spec/unit/rspec/matchers/contain_exactly_spec.rb +0 -11
- data/spec/unit/rspec/matchers/eq_spec.rb +0 -9
- data/spec/unit/rspec/matchers/have_attributes_spec.rb +0 -11
- data/spec/unit/rspec/matchers/have_predicate_spec.rb +0 -21
- data/spec/unit/rspec/matchers/include_spec.rb +0 -21
- data/spec/unit/rspec/matchers/match_array_spec.rb +0 -11
- data/spec/unit/rspec/matchers/match_spec.rb +0 -9
- data/spec/unit/rspec/matchers/raise_error_spec.rb +0 -77
- data/spec/unit/rspec/matchers/respond_to_spec.rb +0 -85
- data/spec/unit/rspec/object_inspection/rspec_matcher_spec.rb +0 -91
- data/spec/unit/rspec/object_inspection_spec.rb +0 -471
- data/spec/unit/super_diff_spec.rb +0 -2115
@@ -1,22 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SuperDiff
|
2
4
|
module Basic
|
3
5
|
module OperationTrees
|
4
|
-
autoload :Array,
|
5
|
-
autoload :CustomObject,
|
6
|
-
autoload :DefaultObject,
|
7
|
-
autoload :Hash,
|
6
|
+
autoload :Array, 'super_diff/basic/operation_trees/array'
|
7
|
+
autoload :CustomObject, 'super_diff/basic/operation_trees/custom_object'
|
8
|
+
autoload :DefaultObject, 'super_diff/basic/operation_trees/default_object'
|
9
|
+
autoload :Hash, 'super_diff/basic/operation_trees/hash'
|
8
10
|
autoload(
|
9
11
|
:MultilineString,
|
10
|
-
|
12
|
+
'super_diff/basic/operation_trees/multiline_string'
|
11
13
|
)
|
12
14
|
|
13
15
|
class Main
|
14
16
|
def self.call(*args)
|
15
|
-
warn <<~
|
17
|
+
warn <<~WARNING
|
16
18
|
WARNING: SuperDiff::OperationTrees::Main.call(...) is deprecated and will be removed in the next major release.
|
17
19
|
Please use SuperDiff.find_operation_tree_for(...) instead.
|
18
20
|
#{caller_locations.join("\n")}
|
19
|
-
|
21
|
+
WARNING
|
20
22
|
SuperDiff.find_operation_tree_for(*args)
|
21
23
|
end
|
22
24
|
end
|
data/lib/super_diff/basic.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'super_diff/basic/differs'
|
4
|
+
require 'super_diff/basic/inspection_tree_builders'
|
5
|
+
require 'super_diff/basic/operation_tree_builders'
|
6
|
+
require 'super_diff/basic/operation_tree_flatteners'
|
7
|
+
require 'super_diff/basic/operation_trees'
|
6
8
|
|
7
9
|
module SuperDiff
|
8
10
|
module Basic
|
9
|
-
autoload :DiffFormatters,
|
11
|
+
autoload :DiffFormatters, 'super_diff/basic/diff_formatters'
|
10
12
|
|
11
13
|
SuperDiff.configuration.tap do |config|
|
12
14
|
config.add_extra_differ_classes(
|
@@ -27,6 +29,7 @@ module SuperDiff
|
|
27
29
|
InspectionTreeBuilders::TimeLike,
|
28
30
|
InspectionTreeBuilders::DateLike,
|
29
31
|
InspectionTreeBuilders::DataObject,
|
32
|
+
InspectionTreeBuilders::RangeObject,
|
30
33
|
InspectionTreeBuilders::DefaultObject
|
31
34
|
)
|
32
35
|
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'forwardable'
|
2
4
|
|
3
5
|
module SuperDiff
|
4
6
|
module Core
|
@@ -32,7 +34,7 @@ module SuperDiff
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def pretty_print(pp)
|
35
|
-
pp.group(1, "#<#{self.class.name} [",
|
37
|
+
pp.group(1, "#<#{self.class.name} [", ']>') do
|
36
38
|
pp.breakable
|
37
39
|
pp.seplist(self) { |value| pp.pp value }
|
38
40
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SuperDiff
|
2
4
|
module Core
|
3
5
|
class AbstractOperationTreeBuilder
|
@@ -31,16 +33,15 @@ module SuperDiff
|
|
31
33
|
operation_tree = build_operation_tree
|
32
34
|
unmatched_delete_operations = []
|
33
35
|
|
34
|
-
unary_operations.each_with_index do |operation,
|
35
|
-
if
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
)
|
36
|
+
unary_operations.each_with_index do |operation, _index|
|
37
|
+
if operation.name == :insert &&
|
38
|
+
(
|
39
|
+
delete_operation =
|
40
|
+
unmatched_delete_operations.find do |op|
|
41
|
+
op.key == operation.key
|
42
|
+
end
|
43
|
+
) && (insert_operation = operation)
|
44
|
+
|
44
45
|
unmatched_delete_operations.delete(delete_operation)
|
45
46
|
|
46
47
|
if (
|
@@ -64,9 +65,7 @@ module SuperDiff
|
|
64
65
|
operation_tree << insert_operation
|
65
66
|
end
|
66
67
|
else
|
67
|
-
if operation.name == :delete
|
68
|
-
unmatched_delete_operations << operation
|
69
|
-
end
|
68
|
+
unmatched_delete_operations << operation if operation.name == :delete
|
70
69
|
|
71
70
|
operation_tree << operation
|
72
71
|
end
|
@@ -76,11 +75,9 @@ module SuperDiff
|
|
76
75
|
end
|
77
76
|
|
78
77
|
def possible_comparison_of(operation, next_operation)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
nil
|
83
|
-
end
|
78
|
+
return unless should_compare?(operation, next_operation)
|
79
|
+
|
80
|
+
compare(operation.value, next_operation.value)
|
84
81
|
end
|
85
82
|
|
86
83
|
def should_compare?(operation, next_operation)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SuperDiff
|
2
4
|
module Core
|
3
5
|
class AbstractOperationTreeFlattener
|
@@ -21,7 +23,7 @@ module SuperDiff
|
|
21
23
|
def beginning_lines
|
22
24
|
if tiered_lines.empty?
|
23
25
|
[]
|
24
|
-
elsif indentation_level
|
26
|
+
elsif indentation_level.positive?
|
25
27
|
[tiered_lines[0]]
|
26
28
|
else
|
27
29
|
[tiered_lines[0].with_complete_bookend(:open)]
|
@@ -35,7 +37,7 @@ module SuperDiff
|
|
35
37
|
def ending_lines
|
36
38
|
if tiered_lines.empty?
|
37
39
|
[]
|
38
|
-
elsif indentation_level
|
40
|
+
elsif indentation_level.positive?
|
39
41
|
[tiered_lines[-1]]
|
40
42
|
else
|
41
43
|
[tiered_lines[-1].with_complete_bookend(:close)]
|
@@ -43,7 +45,7 @@ module SuperDiff
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def tiered_lines
|
46
|
-
@
|
48
|
+
@tiered_lines ||= build_tiered_lines
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SuperDiff
|
2
4
|
module Core
|
3
5
|
class Configuration
|
@@ -81,83 +83,59 @@ module SuperDiff
|
|
81
83
|
@extra_diff_formatter_classes =
|
82
84
|
(@extra_diff_formatter_classes + classes).freeze
|
83
85
|
end
|
84
|
-
|
85
|
-
:add_extra_diff_formatter_class,
|
86
|
-
:add_extra_diff_formatter_classes
|
87
|
-
)
|
86
|
+
alias add_extra_diff_formatter_class add_extra_diff_formatter_classes
|
88
87
|
|
89
88
|
def prepend_extra_diff_formatter_classes(*classes)
|
90
89
|
@extra_diff_formatter_classes =
|
91
90
|
(classes + @extra_diff_formatter_classes).freeze
|
92
91
|
end
|
93
|
-
|
94
|
-
:prepend_extra_diff_formatter_class,
|
95
|
-
:prepend_extra_diff_formatter_classes
|
96
|
-
)
|
92
|
+
alias prepend_extra_diff_formatter_class prepend_extra_diff_formatter_classes
|
97
93
|
|
98
94
|
def add_extra_differ_classes(*classes)
|
99
95
|
@extra_differ_classes = (@extra_differ_classes + classes).freeze
|
100
96
|
end
|
101
|
-
|
97
|
+
alias add_extra_differ_class add_extra_differ_classes
|
102
98
|
|
103
99
|
def prepend_extra_differ_classes(*classes)
|
104
100
|
@extra_differ_classes = (classes + @extra_differ_classes).freeze
|
105
101
|
end
|
106
|
-
|
102
|
+
alias prepend_extra_differ_class prepend_extra_differ_classes
|
107
103
|
|
108
104
|
def add_extra_inspection_tree_builder_classes(*classes)
|
109
105
|
@extra_inspection_tree_builder_classes =
|
110
106
|
(@extra_inspection_tree_builder_classes + classes).freeze
|
111
107
|
end
|
112
|
-
|
113
|
-
:add_extra_inspection_tree_builder_class,
|
114
|
-
:add_extra_inspection_tree_builder_classes
|
115
|
-
)
|
108
|
+
alias add_extra_inspection_tree_builder_class add_extra_inspection_tree_builder_classes
|
116
109
|
|
117
110
|
def prepend_extra_inspection_tree_builder_classes(*classes)
|
118
111
|
@extra_inspection_tree_builder_classes =
|
119
112
|
(classes + @extra_inspection_tree_builder_classes).freeze
|
120
113
|
end
|
121
|
-
|
122
|
-
:prepend_extra_inspection_tree_builder_class,
|
123
|
-
:prepend_extra_inspection_tree_builder_classes
|
124
|
-
)
|
114
|
+
alias prepend_extra_inspection_tree_builder_class prepend_extra_inspection_tree_builder_classes
|
125
115
|
|
126
116
|
def add_extra_operation_tree_builder_classes(*classes)
|
127
117
|
@extra_operation_tree_builder_classes =
|
128
118
|
(@extra_operation_tree_builder_classes + classes).freeze
|
129
119
|
end
|
130
|
-
|
131
|
-
:add_extra_operation_tree_builder_class,
|
132
|
-
:add_extra_operation_tree_builder_classes
|
133
|
-
)
|
120
|
+
alias add_extra_operation_tree_builder_class add_extra_operation_tree_builder_classes
|
134
121
|
|
135
122
|
def prepend_extra_operation_tree_builder_classes(*classes)
|
136
123
|
@extra_operation_tree_builder_classes =
|
137
124
|
(classes + @extra_operation_tree_builder_classes).freeze
|
138
125
|
end
|
139
|
-
|
140
|
-
:prepend_extra_operation_tree_builder_class,
|
141
|
-
:prepend_extra_operation_tree_builder_classes
|
142
|
-
)
|
126
|
+
alias prepend_extra_operation_tree_builder_class prepend_extra_operation_tree_builder_classes
|
143
127
|
|
144
128
|
def add_extra_operation_tree_classes(*classes)
|
145
129
|
@extra_operation_tree_classes =
|
146
130
|
(@extra_operation_tree_classes + classes).freeze
|
147
131
|
end
|
148
|
-
|
149
|
-
:add_extra_operation_tree_class,
|
150
|
-
:add_extra_operation_tree_classes
|
151
|
-
)
|
132
|
+
alias add_extra_operation_tree_class add_extra_operation_tree_classes
|
152
133
|
|
153
134
|
def prepend_extra_operation_tree_classes(*classes)
|
154
135
|
@extra_operation_tree_classes =
|
155
136
|
(classes + @extra_operation_tree_classes).freeze
|
156
137
|
end
|
157
|
-
|
158
|
-
:prepend_extra_operation_tree_class,
|
159
|
-
:prepend_extra_operation_tree_classes
|
160
|
-
)
|
138
|
+
alias prepend_extra_operation_tree_class prepend_extra_operation_tree_classes
|
161
139
|
|
162
140
|
def to_h
|
163
141
|
{
|
@@ -183,11 +161,9 @@ module SuperDiff
|
|
183
161
|
private
|
184
162
|
|
185
163
|
def color_enabled_by_default?
|
186
|
-
return true if ENV[
|
164
|
+
return true if ENV['CI'] == 'true'
|
187
165
|
|
188
|
-
if defined?(::SuperDiff::RSpec)
|
189
|
-
return ::RSpec.configuration.color_enabled?
|
190
|
-
end
|
166
|
+
return ::RSpec.configuration.color_enabled? if defined?(::SuperDiff::RSpec)
|
191
167
|
|
192
168
|
$stdout.respond_to?(:tty?) && $stdout.tty?
|
193
169
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SuperDiff
|
2
4
|
module Core
|
3
5
|
class DifferDispatcher
|
@@ -6,7 +8,7 @@ module SuperDiff
|
|
6
8
|
method_object(
|
7
9
|
:expected,
|
8
10
|
:actual,
|
9
|
-
[:available_classes, indent_level: 0, raise_if_nothing_applies: true]
|
11
|
+
[:available_classes, { indent_level: 0, raise_if_nothing_applies: true }]
|
10
12
|
)
|
11
13
|
|
12
14
|
def call
|
@@ -15,7 +17,7 @@ module SuperDiff
|
|
15
17
|
elsif raise_if_nothing_applies?
|
16
18
|
raise NoDifferAvailableError.create(expected, actual)
|
17
19
|
else
|
18
|
-
|
20
|
+
''
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SuperDiff
|
2
4
|
module Core
|
3
5
|
module Helpers
|
@@ -26,13 +28,13 @@ module SuperDiff
|
|
26
28
|
def plural_type_for(value)
|
27
29
|
case value
|
28
30
|
when Numeric
|
29
|
-
|
31
|
+
'numbers'
|
30
32
|
when String
|
31
|
-
|
33
|
+
'strings'
|
32
34
|
when Symbol
|
33
|
-
|
35
|
+
'symbols'
|
34
36
|
else
|
35
|
-
|
37
|
+
'objects'
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
@@ -49,26 +51,26 @@ module SuperDiff
|
|
49
51
|
if jruby?
|
50
52
|
def object_address_for(object)
|
51
53
|
# Source: <https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/RubyBasicObject.java>
|
52
|
-
|
54
|
+
'0x%x' % object.hash
|
53
55
|
end
|
54
|
-
elsif ruby_version_matches?(
|
55
|
-
require
|
56
|
-
require
|
56
|
+
elsif ruby_version_matches?('>= 2.7.0')
|
57
|
+
require 'json'
|
58
|
+
require 'objspace'
|
57
59
|
|
58
60
|
def object_address_for(object)
|
59
61
|
# Sources: <https://bugs.ruby-lang.org/issues/15408> and <https://bugs.ruby-lang.org/issues/15626#Object-ID>
|
60
62
|
json = JSON.parse(ObjectSpace.dump(object))
|
61
|
-
json.is_a?(Hash) ?
|
63
|
+
json.is_a?(Hash) ? '0x%016x' % Integer(json['address'], 16) : ''
|
62
64
|
end
|
63
65
|
else
|
64
66
|
def object_address_for(object)
|
65
|
-
|
67
|
+
format('0x%016x', (object.object_id * 2))
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
69
71
|
def with_slice_of_array_replaced(array, range, replacement)
|
70
72
|
beginning =
|
71
|
-
if range.begin
|
73
|
+
if range.begin.positive?
|
72
74
|
array[Range.new(0, range.begin - 1)]
|
73
75
|
else
|
74
76
|
[]
|
@@ -1,7 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SuperDiff
|
2
4
|
module Core
|
3
5
|
module ImplementationChecks
|
4
|
-
protected
|
6
|
+
protected
|
7
|
+
|
8
|
+
def unimplemented_instance_method!
|
5
9
|
raise(
|
6
10
|
NotImplementedError,
|
7
11
|
"#{self.class} must implement ##{caller_locations(1, 1).first.label}",
|
@@ -9,7 +13,7 @@ module SuperDiff
|
|
9
13
|
)
|
10
14
|
end
|
11
15
|
|
12
|
-
|
16
|
+
def unimplemented_class_method!
|
13
17
|
raise(
|
14
18
|
NotImplementedError,
|
15
19
|
"#{self} must implement .#{caller_locations(1, 1).first.label}",
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SuperDiff
|
2
4
|
module Core
|
3
5
|
class InspectionTree
|
@@ -21,11 +23,11 @@ module SuperDiff
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def before_each_callbacks
|
24
|
-
@
|
26
|
+
@before_each_callbacks ||= Hash.new { |h, k| h[k] = [] }
|
25
27
|
end
|
26
28
|
|
27
29
|
def render_to_string(object)
|
28
|
-
nodes.reduce(
|
30
|
+
nodes.reduce('') do |string, node|
|
29
31
|
string + node.render_to_string(object)
|
30
32
|
end
|
31
33
|
end
|
@@ -34,7 +36,7 @@ module SuperDiff
|
|
34
36
|
nodes
|
35
37
|
.each_with_index
|
36
38
|
.reduce(
|
37
|
-
[TieredLines.new,
|
39
|
+
[TieredLines.new, '', '']
|
38
40
|
) do |(tiered_lines, prelude, prefix), (node, index)|
|
39
41
|
UpdateTieredLines.call(
|
40
42
|
object: object,
|
@@ -59,10 +61,10 @@ module SuperDiff
|
|
59
61
|
insert_separated_list(array) do |t, value|
|
60
62
|
# Have to do these shenanigans so that if value is a hash, Ruby
|
61
63
|
# doesn't try to interpret it as keyword args
|
62
|
-
if Helpers.ruby_version_matches?(
|
64
|
+
if Helpers.ruby_version_matches?('>= 2.7.1')
|
63
65
|
t.add_inspection_of(value, **{})
|
64
66
|
else
|
65
|
-
t.add_inspection_of(
|
67
|
+
t.add_inspection_of(value, {})
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
@@ -80,16 +82,16 @@ module SuperDiff
|
|
80
82
|
else
|
81
83
|
t1.as_prefix_when_rendering_to_lines do |t2|
|
82
84
|
t2.add_inspection_of key, as_lines: false
|
83
|
-
t2.add_text
|
85
|
+
t2.add_text ' => '
|
84
86
|
end
|
85
87
|
end
|
86
88
|
|
87
89
|
# Have to do these shenanigans so that if hash[key] is a hash, Ruby
|
88
90
|
# doesn't try to interpret it as keyword args
|
89
|
-
if Helpers.ruby_version_matches?(
|
91
|
+
if Helpers.ruby_version_matches?('>= 2.7.1')
|
90
92
|
t1.add_inspection_of(hash[key], **{})
|
91
93
|
else
|
92
|
-
t1.add_inspection_of(
|
94
|
+
t1.add_inspection_of(hash[key], {})
|
93
95
|
end
|
94
96
|
end
|
95
97
|
end
|
@@ -99,10 +101,10 @@ module SuperDiff
|
|
99
101
|
as_lines_when_rendering_to_lines(
|
100
102
|
add_comma: index < enumerable.size - 1
|
101
103
|
) do |t1|
|
102
|
-
if index
|
104
|
+
if index.positive?
|
103
105
|
# stree-ignore
|
104
106
|
t1.when_rendering_to_string do |t2|
|
105
|
-
t2.add_text
|
107
|
+
t2.add_text ' '
|
106
108
|
end
|
107
109
|
end
|
108
110
|
t1.evaluate_block(value, &block)
|
@@ -114,36 +116,34 @@ module SuperDiff
|
|
114
116
|
|
115
117
|
attr_reader :disallowed_node_names, :nodes
|
116
118
|
|
117
|
-
def add_node(node_class,
|
118
|
-
if disallowed_node_names.include?(node_class.name)
|
119
|
-
raise DisallowedNodeError.create(node_name: node_class.name)
|
120
|
-
end
|
119
|
+
def add_node(node_class, ...)
|
120
|
+
raise DisallowedNodeError.create(node_name: node_class.name) if disallowed_node_names.include?(node_class.name)
|
121
121
|
|
122
|
-
append_node(build_node(node_class,
|
122
|
+
append_node(build_node(node_class, ...))
|
123
123
|
end
|
124
124
|
|
125
125
|
def append_node(node)
|
126
126
|
nodes.push(node)
|
127
127
|
end
|
128
128
|
|
129
|
-
def build_node(node_class,
|
130
|
-
node_class.new(self,
|
129
|
+
def build_node(node_class, ...)
|
130
|
+
node_class.new(self, ...)
|
131
131
|
end
|
132
132
|
|
133
133
|
class UpdateTieredLines
|
134
134
|
extend AttrExtras.mixin
|
135
135
|
|
136
136
|
method_object %i[
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
137
|
+
object!
|
138
|
+
type!
|
139
|
+
indentation_level!
|
140
|
+
nodes!
|
141
|
+
tiered_lines!
|
142
|
+
prelude!
|
143
|
+
prefix!
|
144
|
+
node!
|
145
|
+
index!
|
146
|
+
]
|
147
147
|
|
148
148
|
def call
|
149
149
|
if rendering.is_a?(Array)
|
@@ -165,18 +165,18 @@ module SuperDiff
|
|
165
165
|
def concat_with_lines
|
166
166
|
additional_lines =
|
167
167
|
prefix_with(prefix, prepend_with(prelude, rendering))
|
168
|
-
[tiered_lines + additional_lines,
|
168
|
+
[tiered_lines + additional_lines, '', '']
|
169
169
|
end
|
170
170
|
|
171
171
|
def prefix_with(prefix, text)
|
172
|
-
prefix.empty? ? text : [text[0].prefixed_with(prefix)] + text[1
|
172
|
+
prefix.empty? ? text : [text[0].prefixed_with(prefix)] + text[1..]
|
173
173
|
end
|
174
174
|
|
175
175
|
def prepend_with(prelude, text)
|
176
176
|
if prelude.empty?
|
177
177
|
text
|
178
178
|
else
|
179
|
-
[text[0].with_value_prepended(prelude)] + text[1
|
179
|
+
[text[0].with_value_prepended(prelude)] + text[1..]
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
@@ -187,7 +187,7 @@ module SuperDiff
|
|
187
187
|
def add_to_last_line
|
188
188
|
new_lines =
|
189
189
|
tiered_lines[0..-2] +
|
190
|
-
|
190
|
+
[tiered_lines[-1].with_value_appended(rendering)]
|
191
191
|
[new_lines, prelude, prefix]
|
192
192
|
end
|
193
193
|
|
@@ -198,13 +198,13 @@ module SuperDiff
|
|
198
198
|
def add_to_lines
|
199
199
|
new_lines =
|
200
200
|
tiered_lines +
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
201
|
+
[
|
202
|
+
Line.new(
|
203
|
+
type: type,
|
204
|
+
indentation_level: indentation_level,
|
205
|
+
value: rendering
|
206
|
+
)
|
207
|
+
]
|
208
208
|
[new_lines, prelude, prefix]
|
209
209
|
end
|
210
210
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SuperDiff
|
2
4
|
module Core
|
3
5
|
class InspectionTreeBuilderDispatcher
|
@@ -6,11 +8,9 @@ module SuperDiff
|
|
6
8
|
method_object :object, [:available_classes]
|
7
9
|
|
8
10
|
def call
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
raise NoInspectionTreeBuilderAvailableError.create(object)
|
13
|
-
end
|
11
|
+
raise NoInspectionTreeBuilderAvailableError.create(object) unless resolved_class
|
12
|
+
|
13
|
+
resolved_class.call(object)
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SuperDiff
|
2
4
|
module Core
|
3
5
|
module InspectionTreeNodes
|
@@ -35,7 +37,7 @@ module SuperDiff
|
|
35
37
|
end
|
36
38
|
)
|
37
39
|
|
38
|
-
add_comma? ? string
|
40
|
+
add_comma? ? "#{string}," : string
|
39
41
|
end
|
40
42
|
|
41
43
|
def render_to_lines(object, type:, indentation_level:)
|