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,9 +7,7 @@ module SuperDiff
|
|
7
7
|
@disallowed_node_names = disallowed_node_names
|
8
8
|
@nodes = []
|
9
9
|
|
10
|
-
if block
|
11
|
-
instance_eval(&block)
|
12
|
-
end
|
10
|
+
evaluate_block(&block) if block
|
13
11
|
end
|
14
12
|
|
15
13
|
Nodes.registry.each do |node_class|
|
@@ -28,18 +26,16 @@ module SuperDiff
|
|
28
26
|
|
29
27
|
def render_to_string(object)
|
30
28
|
nodes.reduce("") do |string, node|
|
31
|
-
|
32
|
-
string + result
|
29
|
+
string + node.render_to_string(object)
|
33
30
|
end
|
34
31
|
end
|
35
32
|
|
36
33
|
def render_to_lines(object, type:, indentation_level:)
|
37
|
-
nodes
|
38
|
-
each_with_index
|
39
|
-
reduce(
|
40
|
-
|
41
|
-
|
42
|
-
|
|
34
|
+
nodes
|
35
|
+
.each_with_index
|
36
|
+
.reduce(
|
37
|
+
[TieredLines.new, "", ""]
|
38
|
+
) do |(tiered_lines, prelude, prefix), (node, index)|
|
43
39
|
UpdateTieredLines.call(
|
44
40
|
object: object,
|
45
41
|
type: type,
|
@@ -49,53 +45,51 @@ module SuperDiff
|
|
49
45
|
prelude: prelude,
|
50
46
|
prefix: prefix,
|
51
47
|
node: node,
|
52
|
-
index: index
|
48
|
+
index: index
|
53
49
|
)
|
54
|
-
end
|
55
|
-
first
|
50
|
+
end
|
51
|
+
.first
|
56
52
|
end
|
57
53
|
|
58
|
-
def evaluate_block(
|
59
|
-
|
54
|
+
def evaluate_block(*args, &block)
|
55
|
+
block.call(self, *args)
|
60
56
|
end
|
61
57
|
|
62
58
|
def insert_array_inspection_of(array)
|
63
|
-
insert_separated_list(array) do |value|
|
59
|
+
insert_separated_list(array) do |t, value|
|
64
60
|
# Have to do these shenanigans so that if value is a hash, Ruby
|
65
61
|
# doesn't try to interpret it as keyword args
|
66
62
|
if SuperDiff::Helpers.ruby_version_matches?(">= 2.7.1")
|
67
|
-
add_inspection_of(value, **{})
|
63
|
+
t.add_inspection_of(value, **{})
|
68
64
|
else
|
69
|
-
add_inspection_of(*[value, {}])
|
65
|
+
t.add_inspection_of(*[value, {}])
|
70
66
|
end
|
71
67
|
end
|
72
68
|
end
|
73
69
|
|
74
70
|
def insert_hash_inspection_of(hash)
|
75
71
|
keys = hash.keys
|
72
|
+
format_keys_as_kwargs = keys.all? { |key| key.is_a?(Symbol) }
|
76
73
|
|
77
|
-
|
78
|
-
key.is_a?(Symbol)
|
79
|
-
end
|
80
|
-
|
81
|
-
insert_separated_list(keys) do |key|
|
74
|
+
insert_separated_list(keys) do |t1, key|
|
82
75
|
if format_keys_as_kwargs
|
83
|
-
|
84
|
-
|
76
|
+
# stree-ignore
|
77
|
+
t1.as_prefix_when_rendering_to_lines do |t2|
|
78
|
+
t2.add_text "#{key}: "
|
85
79
|
end
|
86
80
|
else
|
87
|
-
as_prefix_when_rendering_to_lines do
|
88
|
-
add_inspection_of key, as_lines: false
|
89
|
-
add_text " => "
|
81
|
+
t1.as_prefix_when_rendering_to_lines do |t2|
|
82
|
+
t2.add_inspection_of key, as_lines: false
|
83
|
+
t2.add_text " => "
|
90
84
|
end
|
91
85
|
end
|
92
86
|
|
93
87
|
# Have to do these shenanigans so that if hash[key] is a hash, Ruby
|
94
88
|
# doesn't try to interpret it as keyword args
|
95
89
|
if SuperDiff::Helpers.ruby_version_matches?(">= 2.7.1")
|
96
|
-
add_inspection_of(hash[key], **{})
|
90
|
+
t1.add_inspection_of(hash[key], **{})
|
97
91
|
else
|
98
|
-
add_inspection_of(*[hash[key], {}])
|
92
|
+
t1.add_inspection_of(*[hash[key], {}])
|
99
93
|
end
|
100
94
|
end
|
101
95
|
end
|
@@ -103,15 +97,15 @@ module SuperDiff
|
|
103
97
|
def insert_separated_list(enumerable, &block)
|
104
98
|
enumerable.each_with_index do |value, index|
|
105
99
|
as_lines_when_rendering_to_lines(
|
106
|
-
add_comma: index < enumerable.size - 1
|
107
|
-
) do
|
100
|
+
add_comma: index < enumerable.size - 1
|
101
|
+
) do |t1|
|
108
102
|
if index > 0
|
109
|
-
|
110
|
-
|
103
|
+
# stree-ignore
|
104
|
+
t1.when_rendering_to_string do |t2|
|
105
|
+
t2.add_text " "
|
111
106
|
end
|
112
107
|
end
|
113
|
-
|
114
|
-
evaluate_block(value, &block)
|
108
|
+
t1.evaluate_block(value, &block)
|
115
109
|
end
|
116
110
|
end
|
117
111
|
end
|
@@ -139,17 +133,17 @@ module SuperDiff
|
|
139
133
|
class UpdateTieredLines
|
140
134
|
extend AttrExtras.mixin
|
141
135
|
|
142
|
-
method_object [
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
136
|
+
method_object %i[
|
137
|
+
object!
|
138
|
+
type!
|
139
|
+
indentation_level!
|
140
|
+
nodes!
|
141
|
+
tiered_lines!
|
142
|
+
prelude!
|
143
|
+
prefix!
|
144
|
+
node!
|
145
|
+
index!
|
146
|
+
]
|
153
147
|
|
154
148
|
def call
|
155
149
|
if rendering.is_a?(Array)
|
@@ -168,19 +162,13 @@ module SuperDiff
|
|
168
162
|
private
|
169
163
|
|
170
164
|
def concat_with_lines
|
171
|
-
additional_lines =
|
172
|
-
prefix,
|
173
|
-
prepend_with(prelude, rendering),
|
174
|
-
)
|
165
|
+
additional_lines =
|
166
|
+
prefix_with(prefix, prepend_with(prelude, rendering))
|
175
167
|
[tiered_lines + additional_lines, "", ""]
|
176
168
|
end
|
177
169
|
|
178
170
|
def prefix_with(prefix, text)
|
179
|
-
|
180
|
-
text
|
181
|
-
else
|
182
|
-
[text[0].prefixed_with(prefix)] + text[1..-1]
|
183
|
-
end
|
171
|
+
prefix.empty? ? text : [text[0].prefixed_with(prefix)] + text[1..-1]
|
184
172
|
end
|
185
173
|
|
186
174
|
def prepend_with(prelude, text)
|
@@ -196,9 +184,9 @@ module SuperDiff
|
|
196
184
|
end
|
197
185
|
|
198
186
|
def add_to_last_line
|
199
|
-
new_lines =
|
200
|
-
tiered_lines[
|
201
|
-
|
187
|
+
new_lines =
|
188
|
+
tiered_lines[0..-2] +
|
189
|
+
[tiered_lines[-1].with_value_appended(rendering)]
|
202
190
|
[new_lines, prelude, prefix]
|
203
191
|
end
|
204
192
|
|
@@ -207,13 +195,15 @@ module SuperDiff
|
|
207
195
|
end
|
208
196
|
|
209
197
|
def add_to_lines
|
210
|
-
new_lines =
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
198
|
+
new_lines =
|
199
|
+
tiered_lines +
|
200
|
+
[
|
201
|
+
Line.new(
|
202
|
+
type: type,
|
203
|
+
indentation_level: indentation_level,
|
204
|
+
value: rendering
|
205
|
+
)
|
206
|
+
]
|
217
207
|
[new_lines, prelude, prefix]
|
218
208
|
end
|
219
209
|
|
@@ -221,12 +211,13 @@ module SuperDiff
|
|
221
211
|
if defined?(@_rendering)
|
222
212
|
@_rendering
|
223
213
|
else
|
224
|
-
@_rendering =
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
214
|
+
@_rendering =
|
215
|
+
node.render(
|
216
|
+
object,
|
217
|
+
preferably_as_lines: true,
|
218
|
+
type: type,
|
219
|
+
indentation_level: indentation_level
|
220
|
+
)
|
230
221
|
end
|
231
222
|
end
|
232
223
|
end
|
@@ -7,31 +7,46 @@ module SuperDiff
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
as_lines_when_rendering_to_lines do
|
16
|
-
add_text "[]"
|
10
|
+
InspectionTree.new do |t1|
|
11
|
+
t1.only_when empty do |t2|
|
12
|
+
# stree-ignore
|
13
|
+
t2.as_lines_when_rendering_to_lines do |t3|
|
14
|
+
t3.add_text "[]"
|
17
15
|
end
|
18
16
|
end
|
19
17
|
|
20
|
-
only_when nonempty do
|
21
|
-
|
22
|
-
|
18
|
+
t1.only_when nonempty do |t2|
|
19
|
+
# stree-ignore
|
20
|
+
t2.as_lines_when_rendering_to_lines(
|
21
|
+
collection_bookend: :open
|
22
|
+
) do |t3|
|
23
|
+
t3.add_text "["
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
# stree-ignore
|
27
|
+
t2.nested do |t3|
|
28
|
+
t3.insert_array_inspection_of(object)
|
27
29
|
end
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
+
# stree-ignore
|
32
|
+
t2.as_lines_when_rendering_to_lines(
|
33
|
+
collection_bookend: :close
|
34
|
+
) do |t3|
|
35
|
+
t3.add_text "]"
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
34
39
|
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def empty
|
44
|
+
-> { object.empty? }
|
45
|
+
end
|
46
|
+
|
47
|
+
def nonempty
|
48
|
+
-> { !object.empty? }
|
49
|
+
end
|
35
50
|
end
|
36
51
|
end
|
37
52
|
end
|
@@ -7,27 +7,31 @@ 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
|
-
nested do |
|
22
|
-
insert_hash_inspection_of(object.attributes_for_super_diff)
|
22
|
+
t1.nested do |t2|
|
23
|
+
t2.insert_hash_inspection_of(object.attributes_for_super_diff)
|
23
24
|
end
|
24
25
|
|
25
|
-
as_lines_when_rendering_to_lines(
|
26
|
-
|
27
|
-
|
26
|
+
t1.as_lines_when_rendering_to_lines(
|
27
|
+
collection_bookend: :close
|
28
|
+
) do |t2|
|
29
|
+
# stree-ignore
|
30
|
+
t2.when_rendering_to_lines do |t3|
|
31
|
+
t3.add_text "}"
|
28
32
|
end
|
29
33
|
|
30
|
-
add_text ">"
|
34
|
+
t2.add_text ">"
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module SuperDiff
|
2
|
+
module ObjectInspection
|
3
|
+
module InspectionTreeBuilders
|
4
|
+
class DateLike < Base
|
5
|
+
def self.applies_to?(value)
|
6
|
+
SuperDiff.date_like?(value)
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
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
|
+
|
16
|
+
# stree-ignore
|
17
|
+
t2.when_rendering_to_lines do |t3|
|
18
|
+
t3.add_text "{"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
t1.when_rendering_to_string do |t2|
|
23
|
+
t2.add_text object.strftime("%Y-%m-%d")
|
24
|
+
end
|
25
|
+
|
26
|
+
t1.when_rendering_to_lines do |t2|
|
27
|
+
t2.nested do |t3|
|
28
|
+
t3.insert_separated_list(%i[year month day]) do |t4, name|
|
29
|
+
t4.add_text name.to_s
|
30
|
+
t4.add_text ": "
|
31
|
+
t4.add_inspection_of object.public_send(name)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
t1.as_lines_when_rendering_to_lines(
|
37
|
+
collection_bookend: :close
|
38
|
+
) do |t2|
|
39
|
+
# stree-ignore
|
40
|
+
t2.when_rendering_to_lines do |t3|
|
41
|
+
t3.add_text "}"
|
42
|
+
end
|
43
|
+
|
44
|
+
t2.add_text ">"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -7,56 +7,72 @@ module SuperDiff
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
only_when empty do
|
15
|
-
as_lines_when_rendering_to_lines do
|
16
|
-
add_text do |object|
|
10
|
+
InspectionTree.new do |t1|
|
11
|
+
t1.only_when empty do |t2|
|
12
|
+
t2.as_lines_when_rendering_to_lines do |t3|
|
13
|
+
t3.add_text(
|
17
14
|
"#<#{object.class.name}:" +
|
18
|
-
SuperDiff::Helpers.object_address_for(object) +
|
19
|
-
|
20
|
-
end
|
15
|
+
SuperDiff::Helpers.object_address_for(object) + ">"
|
16
|
+
)
|
21
17
|
end
|
22
18
|
end
|
23
19
|
|
24
|
-
only_when nonempty do
|
25
|
-
as_lines_when_rendering_to_lines(
|
26
|
-
|
20
|
+
t1.only_when nonempty do |t2|
|
21
|
+
t2.as_lines_when_rendering_to_lines(
|
22
|
+
collection_bookend: :open
|
23
|
+
) do |t3|
|
24
|
+
t3.add_text(
|
27
25
|
"#<#{object.class.name}:" +
|
28
26
|
SuperDiff::Helpers.object_address_for(object)
|
29
|
-
|
27
|
+
)
|
30
28
|
|
31
|
-
|
32
|
-
|
29
|
+
# stree-ignore
|
30
|
+
t3.when_rendering_to_lines do |t4|
|
31
|
+
t4.add_text " {"
|
33
32
|
end
|
34
33
|
end
|
35
34
|
|
36
|
-
|
37
|
-
|
35
|
+
# stree-ignore
|
36
|
+
t2.when_rendering_to_string do |t3|
|
37
|
+
t3.add_text " "
|
38
38
|
end
|
39
39
|
|
40
|
-
nested do |
|
41
|
-
insert_separated_list(
|
42
|
-
|
43
|
-
|
40
|
+
t2.nested do |t3|
|
41
|
+
t3.insert_separated_list(
|
42
|
+
object.instance_variables.sort
|
43
|
+
) do |t4, name|
|
44
|
+
# stree-ignore
|
45
|
+
t4.as_prefix_when_rendering_to_lines do |t5|
|
46
|
+
t5.add_text "#{name}="
|
44
47
|
end
|
45
48
|
|
46
|
-
add_inspection_of object.instance_variable_get(name)
|
49
|
+
t4.add_inspection_of object.instance_variable_get(name)
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
50
|
-
as_lines_when_rendering_to_lines(
|
51
|
-
|
52
|
-
|
53
|
+
t2.as_lines_when_rendering_to_lines(
|
54
|
+
collection_bookend: :close
|
55
|
+
) do |t3|
|
56
|
+
# stree-ignore
|
57
|
+
t3.when_rendering_to_lines do |t4|
|
58
|
+
t4.add_text "}"
|
53
59
|
end
|
54
60
|
|
55
|
-
add_text ">"
|
61
|
+
t3.add_text ">"
|
56
62
|
end
|
57
63
|
end
|
58
64
|
end
|
59
65
|
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def empty
|
70
|
+
-> { object.instance_variables.empty? }
|
71
|
+
end
|
72
|
+
|
73
|
+
def nonempty
|
74
|
+
-> { !object.instance_variables.empty? }
|
75
|
+
end
|
60
76
|
end
|
61
77
|
end
|
62
78
|
end
|
@@ -7,39 +7,56 @@ module SuperDiff
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
as_lines_when_rendering_to_lines do
|
16
|
-
add_text "{}"
|
10
|
+
InspectionTree.new do |t1|
|
11
|
+
t1.only_when empty do |t2|
|
12
|
+
# stree-ignore
|
13
|
+
t2.as_lines_when_rendering_to_lines do |t3|
|
14
|
+
t3.add_text "{}"
|
17
15
|
end
|
18
16
|
end
|
19
17
|
|
20
|
-
only_when nonempty do
|
21
|
-
|
22
|
-
|
18
|
+
t1.only_when nonempty do |t2|
|
19
|
+
# stree-ignore
|
20
|
+
t2.as_lines_when_rendering_to_lines(
|
21
|
+
collection_bookend: :open
|
22
|
+
) do |t3|
|
23
|
+
t3.add_text "{"
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
# stree-ignore
|
27
|
+
t2.when_rendering_to_string do |t3|
|
28
|
+
t3.add_text " "
|
27
29
|
end
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
+
# stree-ignore
|
32
|
+
t2.nested do |t3|
|
33
|
+
t3.insert_hash_inspection_of(object)
|
31
34
|
end
|
32
35
|
|
33
|
-
|
34
|
-
|
36
|
+
# stree-ignore
|
37
|
+
t2.when_rendering_to_string do |t3|
|
38
|
+
t3.add_text " "
|
35
39
|
end
|
36
40
|
|
37
|
-
|
38
|
-
|
41
|
+
# stree-ignore
|
42
|
+
t2.as_lines_when_rendering_to_lines(
|
43
|
+
collection_bookend: :close
|
44
|
+
) do |t3|
|
45
|
+
t3.add_text "}"
|
39
46
|
end
|
40
47
|
end
|
41
48
|
end
|
42
49
|
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def empty
|
54
|
+
-> { object.empty? }
|
55
|
+
end
|
56
|
+
|
57
|
+
def nonempty
|
58
|
+
-> { !object.empty? }
|
59
|
+
end
|
43
60
|
end
|
44
61
|
end
|
45
62
|
end
|
@@ -7,11 +7,9 @@ module SuperDiff
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call
|
10
|
-
InspectionTree.new do
|
11
|
-
as_lines_when_rendering_to_lines do
|
12
|
-
|
13
|
-
add_text { |object| object.inspect }
|
14
|
-
# rubocop:enable Style/SymbolProc
|
10
|
+
InspectionTree.new do |t1|
|
11
|
+
t1.as_lines_when_rendering_to_lines do |t2|
|
12
|
+
t2.add_text object.inspect
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|