super_diff 0.9.0 → 0.11.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 +65 -26
- data/lib/super_diff/active_record/differs/active_record_relation.rb +1 -2
- data/lib/super_diff/active_record/differs.rb +1 -1
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +22 -18
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +14 -7
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +2 -2
- data/lib/super_diff/active_record/object_inspection.rb +1 -1
- data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +1 -2
- data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +1 -2
- data/lib/super_diff/active_record/operation_tree_builders.rb +2 -2
- data/lib/super_diff/active_record/operation_tree_flatteners.rb +1 -1
- data/lib/super_diff/active_record/operation_trees.rb +1 -1
- data/lib/super_diff/active_record.rb +7 -15
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +5 -6
- data/lib/super_diff/active_support/differs.rb +1 -1
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +20 -11
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/ordered_options.rb +46 -0
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +5 -1
- data/lib/super_diff/active_support/object_inspection.rb +1 -1
- data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +5 -6
- data/lib/super_diff/active_support/operation_tree_builders.rb +1 -1
- data/lib/super_diff/active_support/operation_tree_flatteners.rb +1 -1
- data/lib/super_diff/active_support/operation_trees.rb +1 -1
- data/lib/super_diff/active_support.rb +6 -10
- data/lib/super_diff/colorized_document_extensions.rb +2 -4
- data/lib/super_diff/configuration.rb +14 -8
- data/lib/super_diff/csi/color.rb +4 -4
- data/lib/super_diff/csi/colorized_document.rb +12 -16
- data/lib/super_diff/csi/document.rb +8 -19
- data/lib/super_diff/csi/eight_bit_color.rb +19 -19
- data/lib/super_diff/csi/four_bit_color.rb +82 -31
- data/lib/super_diff/csi/twenty_four_bit_color.rb +12 -11
- data/lib/super_diff/csi/uncolorized_document.rb +2 -6
- data/lib/super_diff/csi.rb +10 -14
- data/lib/super_diff/diff_formatters/collection.rb +35 -41
- data/lib/super_diff/differs/date_like.rb +15 -0
- data/lib/super_diff/differs/default_object.rb +1 -1
- data/lib/super_diff/differs/defaults.rb +2 -1
- data/lib/super_diff/differs/main.rb +2 -13
- data/lib/super_diff/differs.rb +1 -0
- data/lib/super_diff/equality_matchers/array.rb +10 -12
- data/lib/super_diff/equality_matchers/base.rb +1 -1
- data/lib/super_diff/equality_matchers/default.rb +2 -4
- data/lib/super_diff/equality_matchers/defaults.rb +1 -1
- data/lib/super_diff/equality_matchers/hash.rb +10 -12
- data/lib/super_diff/equality_matchers/multiline_string.rb +11 -13
- data/lib/super_diff/equality_matchers/primitive.rb +10 -12
- data/lib/super_diff/equality_matchers/singleline_string.rb +10 -12
- data/lib/super_diff/equality_matchers.rb +1 -1
- data/lib/super_diff/errors.rb +2 -6
- data/lib/super_diff/gem_version.rb +3 -3
- data/lib/super_diff/helpers.rb +10 -10
- data/lib/super_diff/implementation_checks.rb +2 -2
- data/lib/super_diff/line.rb +3 -3
- data/lib/super_diff/object_inspection/inspection_tree.rb +64 -73
- data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +29 -14
- data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +17 -13
- data/lib/super_diff/object_inspection/inspection_tree_builders/date_like.rb +51 -0
- data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +43 -27
- data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +2 -1
- data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +35 -18
- data/lib/super_diff/object_inspection/inspection_tree_builders/primitive.rb +3 -5
- data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +30 -36
- data/lib/super_diff/object_inspection/inspection_tree_builders.rb +13 -9
- data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +11 -22
- data/lib/super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/as_single_line.rb +3 -7
- data/lib/super_diff/object_inspection/nodes/base.rb +9 -14
- data/lib/super_diff/object_inspection/nodes/inspection.rb +26 -34
- data/lib/super_diff/object_inspection/nodes/nesting.rb +1 -1
- data/lib/super_diff/object_inspection/nodes/only_when.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/text.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/when_empty.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/when_non_empty.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_lines.rb +1 -1
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_string.rb +1 -5
- data/lib/super_diff/object_inspection/nodes.rb +7 -7
- data/lib/super_diff/object_inspection.rb +3 -3
- data/lib/super_diff/operation_tree_builders/array.rb +12 -11
- data/lib/super_diff/operation_tree_builders/base.rb +17 -15
- data/lib/super_diff/operation_tree_builders/custom_object.rb +8 -6
- data/lib/super_diff/operation_tree_builders/date_like.rb +15 -0
- data/lib/super_diff/operation_tree_builders/default_object.rb +29 -21
- data/lib/super_diff/operation_tree_builders/defaults.rb +1 -1
- data/lib/super_diff/operation_tree_builders/hash.rb +23 -24
- data/lib/super_diff/operation_tree_builders/main.rb +4 -11
- data/lib/super_diff/operation_tree_builders/multiline_string.rb +3 -3
- data/lib/super_diff/operation_tree_builders/time_like.rb +1 -11
- data/lib/super_diff/operation_tree_builders.rb +2 -1
- data/lib/super_diff/operation_tree_flatteners/base.rb +1 -5
- data/lib/super_diff/operation_tree_flatteners/collection.rb +13 -16
- data/lib/super_diff/operation_tree_flatteners/default_object.rb +1 -2
- data/lib/super_diff/operation_tree_flatteners/hash.rb +2 -10
- data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +2 -1
- data/lib/super_diff/operation_tree_flatteners.rb +3 -3
- data/lib/super_diff/operation_trees/base.rb +3 -5
- data/lib/super_diff/operation_trees/default_object.rb +1 -3
- data/lib/super_diff/operations/binary_operation.rb +2 -2
- data/lib/super_diff/operations/unary_operation.rb +1 -1
- data/lib/super_diff/rails.rb +2 -1
- data/lib/super_diff/recursion_guard.rb +5 -4
- data/lib/super_diff/rspec/augmented_matcher.rb +4 -5
- data/lib/super_diff/rspec/differ.rb +6 -13
- data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +3 -2
- data/lib/super_diff/rspec/differs/collection_including.rb +1 -1
- data/lib/super_diff/rspec/differs/hash_including.rb +1 -1
- data/lib/super_diff/rspec/differs.rb +3 -3
- data/lib/super_diff/rspec/matcher_text_builders/base.rb +13 -15
- data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +5 -7
- data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +3 -5
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +2 -10
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +2 -6
- data/lib/super_diff/rspec/matcher_text_builders.rb +5 -8
- data/lib/super_diff/rspec/matcher_text_template.rb +13 -16
- data/lib/super_diff/rspec/monkey_patches.rb +180 -123
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_containing_exactly.rb +14 -7
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +21 -13
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +35 -36
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/generic_describable_matcher.rb +19 -0
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +21 -15
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +11 -10
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +11 -10
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/object_having_attributes.rb +14 -7
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/value_within.rb +10 -11
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +13 -9
- data/lib/super_diff/rspec/object_inspection.rb +1 -1
- data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +11 -10
- data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +7 -6
- data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +11 -10
- data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +22 -17
- data/lib/super_diff/rspec/operation_tree_builders.rb +4 -4
- data/lib/super_diff/rspec.rb +17 -18
- data/lib/super_diff/tiered_lines_elider.rb +87 -115
- data/lib/super_diff/tiered_lines_formatter.rb +5 -9
- data/lib/super_diff/version.rb +1 -1
- data/lib/super_diff.rb +13 -9
- data/spec/examples.txt +541 -483
- data/spec/integration/rails/active_record_spec.rb +3 -1
- data/spec/integration/rails/engines_spec.rb +25 -0
- data/spec/integration/rails/hash_with_indifferent_access_spec.rb +3 -1
- data/spec/integration/rspec/be_falsey_matcher_spec.rb +40 -35
- data/spec/integration/rspec/be_matcher_spec.rb +360 -320
- data/spec/integration/rspec/be_nil_matcher_spec.rb +38 -34
- data/spec/integration/rspec/be_predicate_matcher_spec.rb +376 -359
- data/spec/integration/rspec/be_truthy_matcher_spec.rb +38 -33
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +257 -254
- data/spec/integration/rspec/eq_matcher_spec.rb +695 -585
- data/spec/integration/rspec/generic_describable_matchers_spec.rb +177 -0
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +312 -304
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +291 -297
- data/spec/integration/rspec/include_matcher_spec.rb +327 -225
- data/spec/integration/rspec/magic_metadata_spec.rb +51 -0
- data/spec/integration/rspec/match_array_matcher_spec.rb +294 -291
- data/spec/integration/rspec/match_matcher_spec.rb +916 -903
- data/spec/integration/rspec/raise_error_matcher_spec.rb +1208 -449
- data/spec/integration/rspec/respond_to_matcher_spec.rb +702 -697
- data/spec/integration/rspec/third_party_matcher_spec.rb +142 -138
- data/spec/integration/rspec/unhandled_errors_spec.rb +88 -84
- data/spec/internal/log/test.log +0 -0
- data/spec/spec_helper.rb +20 -20
- data/spec/support/command_runner.rb +34 -57
- data/spec/support/integration/helpers.rb +44 -32
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +28 -23
- data/spec/support/integration/matchers.rb +34 -0
- data/spec/support/integration/test_programs/base.rb +17 -22
- data/spec/support/integration/test_programs/plain.rb +6 -0
- data/spec/support/integration/test_programs/rspec_active_record.rb +4 -1
- data/spec/support/integration/test_programs/rspec_active_support.rb +4 -1
- data/spec/support/integration/test_programs/rspec_rails.rb +4 -1
- data/spec/support/integration/test_programs/rspec_rails_engine.rb +20 -0
- data/spec/support/models/active_record/person.rb +6 -4
- data/spec/support/models/active_record/shipping_address.rb +9 -10
- data/spec/support/models/customer.rb +2 -4
- data/spec/support/models/player.rb +3 -6
- data/spec/support/models/shipping_address.rb +4 -13
- data/spec/support/shared_examples/active_record.rb +258 -240
- data/spec/support/shared_examples/active_support.rb +174 -51
- data/spec/support/shared_examples/elided_diffs.rb +447 -423
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +500 -464
- data/spec/support/shared_examples/key.rb +123 -0
- data/spec/support/unit/helpers.rb +1 -3
- data/spec/support/unit/matchers/match_output.rb +12 -13
- data/spec/unit/active_record/object_inspection_spec.rb +222 -206
- data/spec/unit/active_support/object_inspection_spec.rb +170 -0
- data/spec/unit/equality_matchers/main_spec.rb +1049 -984
- data/spec/unit/helpers_spec.rb +14 -21
- data/spec/unit/operation_tree_flatteners/array_spec.rb +557 -524
- data/spec/unit/operation_tree_flatteners/custom_object_spec.rb +619 -601
- data/spec/unit/operation_tree_flatteners/default_object_spec.rb +619 -621
- data/spec/unit/operation_tree_flatteners/hash_spec.rb +595 -556
- data/spec/unit/operation_tree_flatteners/multiline_string_spec.rb +102 -92
- data/spec/unit/rspec/matchers/be_compared_to_spec.rb +3 -3
- data/spec/unit/rspec/matchers/be_predicate_spec.rb +3 -3
- data/spec/unit/rspec/matchers/contain_exactly_spec.rb +1 -1
- data/spec/unit/rspec/matchers/have_attributes_spec.rb +1 -1
- data/spec/unit/rspec/matchers/have_predicate_spec.rb +2 -2
- data/spec/unit/rspec/matchers/include_spec.rb +2 -2
- data/spec/unit/rspec/matchers/match_array_spec.rb +2 -2
- data/spec/unit/rspec/matchers/raise_error_spec.rb +43 -11
- data/spec/unit/rspec/matchers/respond_to_spec.rb +23 -16
- data/spec/unit/rspec/object_inspection/rspec_matcher_spec.rb +91 -0
- data/spec/unit/rspec/object_inspection_spec.rb +351 -326
- data/spec/unit/super_diff_spec.rb +1594 -1437
- data/spec/unit/tiered_lines_elider_spec.rb +3508 -3536
- data/spec/unit/tiered_lines_formatter_spec.rb +54 -116
- data/super_diff.gemspec +13 -12
- metadata +88 -75
- data/lib/super_diff/errors/no_diff_formatter_available_error.rb +0 -21
- data/lib/super_diff/errors/no_operational_sequencer_available_error.rb +0 -22
- data/spec/tmp/warnings_logger/all_warnings.txt +0 -2
@@ -7,54 +7,48 @@ module SuperDiff
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call
|
10
|
-
InspectionTree.new do
|
11
|
-
as_lines_when_rendering_to_lines(
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
InspectionTree.new do |t1|
|
11
|
+
t1.as_lines_when_rendering_to_lines(
|
12
|
+
collection_bookend: :open
|
13
|
+
) do |t2|
|
14
|
+
t2.add_text "#<#{object.class} "
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
# stree-ignore
|
17
|
+
t2.when_rendering_to_lines do |t3|
|
18
|
+
t3.add_text "{"
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
|
-
when_rendering_to_string do
|
22
|
-
add_text
|
23
|
-
|
24
|
-
(
|
25
|
-
" " +
|
26
|
-
(
|
27
|
-
|
22
|
+
t1.when_rendering_to_string do |t2|
|
23
|
+
t2.add_text(
|
24
|
+
object.strftime("%Y-%m-%d %H:%M:%S") +
|
25
|
+
(object.subsec == 0 ? "" : "+#{object.subsec.inspect}") +
|
26
|
+
" " + object.strftime("%:z") +
|
27
|
+
(object.zone ? " (#{object.zone})" : "")
|
28
|
+
)
|
28
29
|
end
|
29
30
|
|
30
|
-
when_rendering_to_lines do
|
31
|
-
nested do |
|
32
|
-
insert_separated_list(
|
33
|
-
[
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
:min,
|
39
|
-
:sec,
|
40
|
-
:subsec,
|
41
|
-
:zone,
|
42
|
-
:utc_offset
|
43
|
-
]
|
44
|
-
) do |name|
|
45
|
-
add_text name.to_s
|
46
|
-
add_text ": "
|
47
|
-
add_inspection_of time.public_send(name)
|
31
|
+
t1.when_rendering_to_lines do |t2|
|
32
|
+
t2.nested do |t3|
|
33
|
+
t3.insert_separated_list(
|
34
|
+
%i[year month day hour min sec subsec zone utc_offset]
|
35
|
+
) do |t4, name|
|
36
|
+
t4.add_text name.to_s
|
37
|
+
t4.add_text ": "
|
38
|
+
t4.add_inspection_of object.public_send(name)
|
48
39
|
end
|
49
40
|
end
|
50
41
|
end
|
51
42
|
|
52
|
-
as_lines_when_rendering_to_lines(
|
53
|
-
|
54
|
-
|
43
|
+
t1.as_lines_when_rendering_to_lines(
|
44
|
+
collection_bookend: :close
|
45
|
+
) do |t2|
|
46
|
+
# stree-ignore
|
47
|
+
t2.when_rendering_to_lines do |t3|
|
48
|
+
t3.add_text "}"
|
55
49
|
end
|
56
50
|
|
57
|
-
add_text ">"
|
51
|
+
t2.add_text ">"
|
58
52
|
end
|
59
53
|
end
|
60
54
|
end
|
@@ -3,39 +3,43 @@ module SuperDiff
|
|
3
3
|
module InspectionTreeBuilders
|
4
4
|
autoload(
|
5
5
|
:Base,
|
6
|
-
"super_diff/object_inspection/inspection_tree_builders/base"
|
6
|
+
"super_diff/object_inspection/inspection_tree_builders/base"
|
7
7
|
)
|
8
8
|
autoload(
|
9
9
|
:Array,
|
10
|
-
"super_diff/object_inspection/inspection_tree_builders/array"
|
10
|
+
"super_diff/object_inspection/inspection_tree_builders/array"
|
11
11
|
)
|
12
12
|
autoload(
|
13
13
|
:CustomObject,
|
14
|
-
"super_diff/object_inspection/inspection_tree_builders/custom_object"
|
14
|
+
"super_diff/object_inspection/inspection_tree_builders/custom_object"
|
15
15
|
)
|
16
16
|
autoload(
|
17
17
|
:DefaultObject,
|
18
|
-
"super_diff/object_inspection/inspection_tree_builders/default_object"
|
18
|
+
"super_diff/object_inspection/inspection_tree_builders/default_object"
|
19
19
|
)
|
20
20
|
autoload(
|
21
21
|
:Hash,
|
22
|
-
"super_diff/object_inspection/inspection_tree_builders/hash"
|
22
|
+
"super_diff/object_inspection/inspection_tree_builders/hash"
|
23
23
|
)
|
24
24
|
autoload(
|
25
25
|
:Main,
|
26
|
-
"super_diff/object_inspection/inspection_tree_builders/main"
|
26
|
+
"super_diff/object_inspection/inspection_tree_builders/main"
|
27
27
|
)
|
28
28
|
autoload(
|
29
29
|
:Primitive,
|
30
|
-
"super_diff/object_inspection/inspection_tree_builders/primitive"
|
30
|
+
"super_diff/object_inspection/inspection_tree_builders/primitive"
|
31
31
|
)
|
32
32
|
autoload(
|
33
33
|
:String,
|
34
|
-
"super_diff/object_inspection/inspection_tree_builders/string"
|
34
|
+
"super_diff/object_inspection/inspection_tree_builders/string"
|
35
35
|
)
|
36
36
|
autoload(
|
37
37
|
:TimeLike,
|
38
|
-
"super_diff/object_inspection/inspection_tree_builders/time_like"
|
38
|
+
"super_diff/object_inspection/inspection_tree_builders/time_like"
|
39
|
+
)
|
40
|
+
autoload(
|
41
|
+
:DateLike,
|
42
|
+
"super_diff/object_inspection/inspection_tree_builders/date_like"
|
39
43
|
)
|
40
44
|
end
|
41
45
|
end
|
@@ -15,9 +15,10 @@ module SuperDiff
|
|
15
15
|
*args,
|
16
16
|
add_comma: false,
|
17
17
|
collection_bookend: nil,
|
18
|
-
**rest
|
18
|
+
**rest,
|
19
|
+
&block
|
19
20
|
)
|
20
|
-
super(tree, *args, **rest)
|
21
|
+
super(tree, *args, **rest, &block)
|
21
22
|
|
22
23
|
@add_comma = add_comma
|
23
24
|
@collection_bookend = collection_bookend
|
@@ -26,17 +27,9 @@ module SuperDiff
|
|
26
27
|
def render_to_string(object)
|
27
28
|
# TODO: This happens a lot, can we simplify this?
|
28
29
|
string =
|
29
|
-
|
30
|
-
render_to_string_in_subtree(object)
|
31
|
-
else
|
32
|
-
immediate_value.to_s
|
33
|
-
end
|
30
|
+
(block ? render_to_string_in_subtree(object) : immediate_value.to_s)
|
34
31
|
|
35
|
-
|
36
|
-
string + ","
|
37
|
-
else
|
38
|
-
string
|
39
|
-
end
|
32
|
+
add_comma? ? string + "," : string
|
40
33
|
end
|
41
34
|
|
42
35
|
def render_to_lines(object, type:, indentation_level:)
|
@@ -46,23 +39,20 @@ module SuperDiff
|
|
46
39
|
object,
|
47
40
|
type: type,
|
48
41
|
indentation_level: indentation_level,
|
49
|
-
disallowed_node_names: [
|
50
|
-
:line,
|
51
|
-
:as_lines_when_rendering_to_lines,
|
52
|
-
],
|
42
|
+
disallowed_node_names: %i[line as_lines_when_rendering_to_lines]
|
53
43
|
)
|
54
44
|
else
|
55
45
|
[
|
56
46
|
SuperDiff::Line.new(
|
57
47
|
type: type,
|
58
48
|
indentation_level: indentation_level,
|
59
|
-
value: immediate_value.to_s
|
60
|
-
)
|
49
|
+
value: immediate_value.to_s
|
50
|
+
)
|
61
51
|
]
|
62
52
|
end
|
63
53
|
|
64
54
|
with_collection_bookend_added_to_last_line_in(
|
65
|
-
with_add_comma_added_to_last_line_in(lines)
|
55
|
+
with_add_comma_added_to_last_line_in(lines)
|
66
56
|
)
|
67
57
|
end
|
68
58
|
|
@@ -76,9 +66,8 @@ module SuperDiff
|
|
76
66
|
|
77
67
|
def with_collection_bookend_added_to_last_line_in(lines)
|
78
68
|
if collection_bookend
|
79
|
-
lines[0..-2] +
|
80
|
-
lines[-1].clone_with(collection_bookend: collection_bookend)
|
81
|
-
]
|
69
|
+
lines[0..-2] +
|
70
|
+
[lines[-1].clone_with(collection_bookend: collection_bookend)]
|
82
71
|
else
|
83
72
|
lines
|
84
73
|
end
|
@@ -11,11 +11,7 @@ module SuperDiff
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def render_to_string(object)
|
14
|
-
|
15
|
-
render_to_string_in_subtree(object)
|
16
|
-
else
|
17
|
-
immediate_value.to_s
|
18
|
-
end
|
14
|
+
block ? render_to_string_in_subtree(object) : immediate_value.to_s
|
19
15
|
end
|
20
16
|
|
21
17
|
def render_to_lines(object, **)
|
@@ -11,11 +11,7 @@ module SuperDiff
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def render_to_string(object)
|
14
|
-
|
15
|
-
render_to_string_in_subtree(object)
|
16
|
-
else
|
17
|
-
immediate_value.to_s
|
18
|
-
end
|
14
|
+
block ? render_to_string_in_subtree(object) : immediate_value.to_s
|
19
15
|
end
|
20
16
|
|
21
17
|
def render_to_lines(object, **)
|
@@ -11,11 +11,7 @@ module SuperDiff
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def render_to_string(object)
|
14
|
-
|
15
|
-
render_to_string_in_subtree(object)
|
16
|
-
else
|
17
|
-
immediate_value.to_s
|
18
|
-
end
|
14
|
+
block ? render_to_string_in_subtree(object) : immediate_value.to_s
|
19
15
|
end
|
20
16
|
|
21
17
|
def render_to_lines(object, type:, indentation_level:)
|
@@ -23,8 +19,8 @@ module SuperDiff
|
|
23
19
|
SuperDiff::Line.new(
|
24
20
|
type: type,
|
25
21
|
indentation_level: indentation_level,
|
26
|
-
value: render_to_string(object)
|
27
|
-
)
|
22
|
+
value: render_to_string(object)
|
23
|
+
)
|
28
24
|
]
|
29
25
|
end
|
30
26
|
end
|
@@ -16,9 +16,9 @@ module SuperDiff
|
|
16
16
|
def initialize(tree, *args, **options, &block)
|
17
17
|
if !args.empty? && block
|
18
18
|
raise ArgumentError.new(
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
"You cannot provide both an immediate value and a lazy value. " +
|
20
|
+
"Either pass a block or a positional argument."
|
21
|
+
)
|
22
22
|
end
|
23
23
|
|
24
24
|
@tree = tree
|
@@ -50,13 +50,13 @@ module SuperDiff
|
|
50
50
|
|
51
51
|
# rubocop:disable Lint/UnusedMethodArgument
|
52
52
|
def render_to_string(object)
|
53
|
-
|
53
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
54
54
|
unimplemented_instance_method!
|
55
55
|
end
|
56
56
|
|
57
57
|
# rubocop:disable Lint/UnusedMethodArgument
|
58
58
|
def render_to_lines(object, type:, indentation_level:)
|
59
|
-
|
59
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
60
60
|
unimplemented_instance_method!
|
61
61
|
end
|
62
62
|
|
@@ -80,11 +80,7 @@ module SuperDiff
|
|
80
80
|
attr_reader :tree, :immediate_value, :block, :options
|
81
81
|
|
82
82
|
def pretty_print_variables
|
83
|
-
|
84
|
-
[:"@block"]
|
85
|
-
else
|
86
|
-
[:"@immediate_value"]
|
87
|
-
end
|
83
|
+
block ? [:"@block"] : [:"@immediate_value"]
|
88
84
|
end
|
89
85
|
|
90
86
|
def evaluate_block(object)
|
@@ -104,15 +100,14 @@ module SuperDiff
|
|
104
100
|
disallowed_node_names: [],
|
105
101
|
**rest
|
106
102
|
)
|
107
|
-
subtree =
|
108
|
-
disallowed_node_names: disallowed_node_names
|
109
|
-
)
|
103
|
+
subtree =
|
104
|
+
InspectionTree.new(disallowed_node_names: disallowed_node_names)
|
110
105
|
subtree.evaluate_block(object, &block)
|
111
106
|
subtree.render_to_lines(
|
112
107
|
object,
|
113
108
|
type: type,
|
114
109
|
indentation_level: indentation_level,
|
115
|
-
**rest
|
110
|
+
**rest
|
116
111
|
)
|
117
112
|
end
|
118
113
|
end
|
@@ -11,50 +11,42 @@ module SuperDiff
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def render_to_string(object)
|
14
|
-
value =
|
15
|
-
if block
|
16
|
-
evaluate_block(object)
|
17
|
-
else
|
18
|
-
immediate_value
|
19
|
-
end
|
14
|
+
value = (block ? evaluate_block(object) : immediate_value)
|
20
15
|
|
21
|
-
SuperDiff::RecursionGuard.
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
16
|
+
SuperDiff::RecursionGuard.guarding_recursion_of(
|
17
|
+
value
|
18
|
+
) do |already_seen|
|
19
|
+
if already_seen
|
20
|
+
SuperDiff::RecursionGuard::PLACEHOLDER
|
21
|
+
else
|
22
|
+
SuperDiff.inspect_object(value, as_lines: false)
|
28
23
|
end
|
24
|
+
end
|
29
25
|
end
|
30
26
|
|
31
27
|
def render_to_lines(object, type:, indentation_level:)
|
32
|
-
value =
|
33
|
-
if block
|
34
|
-
evaluate_block(object)
|
35
|
-
else
|
36
|
-
immediate_value
|
37
|
-
end
|
28
|
+
value = (block ? evaluate_block(object) : immediate_value)
|
38
29
|
|
39
|
-
SuperDiff::RecursionGuard.
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
indentation_level: indentation_level,
|
46
|
-
value: SuperDiff::RecursionGuard::PLACEHOLDER,
|
47
|
-
),
|
48
|
-
]
|
49
|
-
else
|
50
|
-
SuperDiff.inspect_object(
|
51
|
-
value,
|
52
|
-
as_lines: true,
|
30
|
+
SuperDiff::RecursionGuard.guarding_recursion_of(
|
31
|
+
value
|
32
|
+
) do |already_seen|
|
33
|
+
if already_seen
|
34
|
+
[
|
35
|
+
SuperDiff::Line.new(
|
53
36
|
type: type,
|
54
37
|
indentation_level: indentation_level,
|
38
|
+
value: SuperDiff::RecursionGuard::PLACEHOLDER
|
55
39
|
)
|
56
|
-
|
40
|
+
]
|
41
|
+
else
|
42
|
+
SuperDiff.inspect_object(
|
43
|
+
value,
|
44
|
+
as_lines: true,
|
45
|
+
type: type,
|
46
|
+
indentation_level: indentation_level
|
47
|
+
)
|
57
48
|
end
|
49
|
+
end
|
58
50
|
end
|
59
51
|
end
|
60
52
|
end
|
@@ -18,11 +18,7 @@ module SuperDiff
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def render_to_string(object)
|
21
|
-
|
22
|
-
render_to_string_in_subtree(object)
|
23
|
-
else
|
24
|
-
""
|
25
|
-
end
|
21
|
+
test_passes? ? render_to_string_in_subtree(object) : ""
|
26
22
|
end
|
27
23
|
|
28
24
|
def render_to_lines(object, type:, indentation_level:)
|
@@ -30,7 +26,7 @@ module SuperDiff
|
|
30
26
|
render_to_lines_in_subtree(
|
31
27
|
object,
|
32
28
|
type: type,
|
33
|
-
indentation_level: indentation_level
|
29
|
+
indentation_level: indentation_level
|
34
30
|
)
|
35
31
|
else
|
36
32
|
[]
|
@@ -11,11 +11,7 @@ module SuperDiff
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def render_to_string(object)
|
14
|
-
|
15
|
-
render_to_string_in_subtree(object)
|
16
|
-
else
|
17
|
-
""
|
18
|
-
end
|
14
|
+
empty?(object) ? render_to_string_in_subtree(object) : ""
|
19
15
|
end
|
20
16
|
|
21
17
|
def render_to_lines(object, type:, indentation_level:)
|
@@ -23,7 +19,7 @@ module SuperDiff
|
|
23
19
|
render_to_lines_in_subtree(
|
24
20
|
object,
|
25
21
|
type: type,
|
26
|
-
indentation_level: indentation_level
|
22
|
+
indentation_level: indentation_level
|
27
23
|
)
|
28
24
|
else
|
29
25
|
[]
|
@@ -11,11 +11,7 @@ module SuperDiff
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def render_to_string(object)
|
14
|
-
|
15
|
-
""
|
16
|
-
else
|
17
|
-
render_to_string_in_subtree(object)
|
18
|
-
end
|
14
|
+
empty?(object) ? "" : render_to_string_in_subtree(object)
|
19
15
|
end
|
20
16
|
|
21
17
|
def render_to_lines(object, type:, indentation_level:)
|
@@ -25,7 +21,7 @@ module SuperDiff
|
|
25
21
|
render_to_lines_in_subtree(
|
26
22
|
object,
|
27
23
|
type: type,
|
28
|
-
indentation_level: indentation_level
|
24
|
+
indentation_level: indentation_level
|
29
25
|
)
|
30
26
|
end
|
31
27
|
end
|
@@ -11,11 +11,7 @@ module SuperDiff
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def render_to_string(object)
|
14
|
-
|
15
|
-
render_to_string_in_subtree(object)
|
16
|
-
else
|
17
|
-
immediate_value.to_s
|
18
|
-
end
|
14
|
+
block ? render_to_string_in_subtree(object) : immediate_value.to_s
|
19
15
|
end
|
20
16
|
|
21
17
|
def render_to_lines(*, **)
|
@@ -3,19 +3,19 @@ module SuperDiff
|
|
3
3
|
module Nodes
|
4
4
|
autoload(
|
5
5
|
:AsLinesWhenRenderingToLines,
|
6
|
-
"super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines"
|
6
|
+
"super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines"
|
7
7
|
)
|
8
8
|
autoload(
|
9
9
|
:AsPrefixWhenRenderingToLines,
|
10
|
-
"super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines"
|
10
|
+
"super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines"
|
11
11
|
)
|
12
12
|
autoload(
|
13
13
|
:AsPreludeWhenRenderingToLines,
|
14
|
-
"super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines"
|
14
|
+
"super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines"
|
15
15
|
)
|
16
16
|
autoload(
|
17
17
|
:AsSingleLine,
|
18
|
-
"super_diff/object_inspection/nodes/as_single_line"
|
18
|
+
"super_diff/object_inspection/nodes/as_single_line"
|
19
19
|
)
|
20
20
|
autoload :Base, "super_diff/object_inspection/nodes/base"
|
21
21
|
autoload :Inspection, "super_diff/object_inspection/nodes/inspection"
|
@@ -24,11 +24,11 @@ module SuperDiff
|
|
24
24
|
autoload :Text, "super_diff/object_inspection/nodes/text"
|
25
25
|
autoload(
|
26
26
|
:WhenRenderingToLines,
|
27
|
-
"super_diff/object_inspection/nodes/when_rendering_to_lines"
|
27
|
+
"super_diff/object_inspection/nodes/when_rendering_to_lines"
|
28
28
|
)
|
29
29
|
autoload(
|
30
30
|
:WhenRenderingToString,
|
31
|
-
"super_diff/object_inspection/nodes/when_rendering_to_string"
|
31
|
+
"super_diff/object_inspection/nodes/when_rendering_to_string"
|
32
32
|
)
|
33
33
|
|
34
34
|
def self.registry
|
@@ -42,7 +42,7 @@ module SuperDiff
|
|
42
42
|
OnlyWhen,
|
43
43
|
Text,
|
44
44
|
WhenRenderingToLines,
|
45
|
-
WhenRenderingToString
|
45
|
+
WhenRenderingToString
|
46
46
|
]
|
47
47
|
end
|
48
48
|
end
|
@@ -3,16 +3,16 @@ module SuperDiff
|
|
3
3
|
autoload :InspectionTree, "super_diff/object_inspection/inspection_tree"
|
4
4
|
autoload(
|
5
5
|
:InspectionTreeBuilders,
|
6
|
-
"super_diff/object_inspection/inspection_tree_builders"
|
6
|
+
"super_diff/object_inspection/inspection_tree_builders"
|
7
7
|
)
|
8
8
|
autoload :Nodes, "super_diff/object_inspection/nodes"
|
9
9
|
autoload(
|
10
10
|
:PrefixForNextNode,
|
11
|
-
"super_diff/object_inspection/prefix_for_next_node"
|
11
|
+
"super_diff/object_inspection/prefix_for_next_node"
|
12
12
|
)
|
13
13
|
autoload(
|
14
14
|
:PreludeForNextNode,
|
15
|
-
"super_diff/object_inspection/prelude_for_next_node"
|
15
|
+
"super_diff/object_inspection/prelude_for_next_node"
|
16
16
|
)
|
17
17
|
end
|
18
18
|
end
|
@@ -13,12 +13,13 @@ module SuperDiff
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def lcs_callbacks
|
16
|
-
@_lcs_callbacks ||=
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
@_lcs_callbacks ||=
|
17
|
+
LcsCallbacks.new(
|
18
|
+
operation_tree: operation_tree,
|
19
|
+
expected: expected,
|
20
|
+
actual: actual,
|
21
|
+
compare: method(:compare)
|
22
|
+
)
|
22
23
|
end
|
23
24
|
|
24
25
|
def operation_tree
|
@@ -28,7 +29,7 @@ module SuperDiff
|
|
28
29
|
class LcsCallbacks
|
29
30
|
extend AttrExtras.mixin
|
30
31
|
|
31
|
-
pattr_initialize [
|
32
|
+
pattr_initialize %i[operation_tree! expected! actual! compare!]
|
32
33
|
public :operation_tree
|
33
34
|
|
34
35
|
def match(event)
|
@@ -62,7 +63,7 @@ module SuperDiff
|
|
62
63
|
collection: expected,
|
63
64
|
key: event.old_position,
|
64
65
|
value: event.old_element,
|
65
|
-
index: event.old_position
|
66
|
+
index: event.old_position
|
66
67
|
)
|
67
68
|
end
|
68
69
|
|
@@ -72,7 +73,7 @@ module SuperDiff
|
|
72
73
|
collection: actual,
|
73
74
|
key: event.new_position,
|
74
75
|
value: event.new_element,
|
75
|
-
index: event.new_position
|
76
|
+
index: event.new_position
|
76
77
|
)
|
77
78
|
end
|
78
79
|
|
@@ -82,7 +83,7 @@ module SuperDiff
|
|
82
83
|
collection: actual,
|
83
84
|
key: event.new_position,
|
84
85
|
value: event.new_element,
|
85
|
-
index: event.new_position
|
86
|
+
index: event.new_position
|
86
87
|
)
|
87
88
|
end
|
88
89
|
|
@@ -97,7 +98,7 @@ module SuperDiff
|
|
97
98
|
right_value: event.new_element,
|
98
99
|
left_index: event.old_position,
|
99
100
|
right_index: event.new_position,
|
100
|
-
children: children
|
101
|
+
children: children
|
101
102
|
)
|
102
103
|
end
|
103
104
|
end
|