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.
Files changed (276) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/super_diff/active_record/differs/active_record_relation.rb +2 -0
  4. data/lib/super_diff/active_record/differs.rb +3 -1
  5. data/lib/super_diff/active_record/inspection_tree_builders/active_record_model.rb +7 -5
  6. data/lib/super_diff/active_record/inspection_tree_builders/active_record_relation.rb +12 -10
  7. data/lib/super_diff/active_record/inspection_tree_builders.rb +4 -2
  8. data/lib/super_diff/active_record/monkey_patches.rb +4 -2
  9. data/lib/super_diff/active_record/object_inspection.rb +6 -4
  10. data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +3 -1
  11. data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +3 -1
  12. data/lib/super_diff/active_record/operation_tree_builders.rb +4 -2
  13. data/lib/super_diff/active_record/operation_tree_flatteners/active_record_relation.rb +4 -2
  14. data/lib/super_diff/active_record/operation_tree_flatteners.rb +3 -1
  15. data/lib/super_diff/active_record/operation_trees/active_record_relation.rb +2 -0
  16. data/lib/super_diff/active_record/operation_trees.rb +3 -1
  17. data/lib/super_diff/active_record.rb +10 -8
  18. data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +2 -0
  19. data/lib/super_diff/active_support/differs.rb +3 -1
  20. data/lib/super_diff/active_support/inspection_tree_builders/hash_with_indifferent_access.rb +16 -14
  21. data/lib/super_diff/active_support/inspection_tree_builders/ordered_options.rb +16 -14
  22. data/lib/super_diff/active_support/inspection_tree_builders.rb +4 -2
  23. data/lib/super_diff/active_support/object_inspection.rb +6 -4
  24. data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +6 -4
  25. data/lib/super_diff/active_support/operation_tree_builders.rb +3 -1
  26. data/lib/super_diff/active_support/operation_tree_flatteners/hash_with_indifferent_access.rb +4 -2
  27. data/lib/super_diff/active_support/operation_tree_flatteners.rb +3 -1
  28. data/lib/super_diff/active_support/operation_trees/hash_with_indifferent_access.rb +2 -0
  29. data/lib/super_diff/active_support/operation_trees.rb +3 -1
  30. data/lib/super_diff/active_support.rb +8 -6
  31. data/lib/super_diff/basic/diff_formatters/collection.rb +18 -18
  32. data/lib/super_diff/basic/diff_formatters/multiline_string.rb +2 -0
  33. data/lib/super_diff/basic/diff_formatters.rb +4 -2
  34. data/lib/super_diff/basic/differs/array.rb +2 -0
  35. data/lib/super_diff/basic/differs/custom_object.rb +3 -1
  36. data/lib/super_diff/basic/differs/date_like.rb +2 -0
  37. data/lib/super_diff/basic/differs/default_object.rb +3 -1
  38. data/lib/super_diff/basic/differs/hash.rb +2 -0
  39. data/lib/super_diff/basic/differs/multiline_string.rb +2 -0
  40. data/lib/super_diff/basic/differs/time_like.rb +2 -0
  41. data/lib/super_diff/basic/differs.rb +11 -9
  42. data/lib/super_diff/basic/inspection_tree_builders/array.rb +5 -3
  43. data/lib/super_diff/basic/inspection_tree_builders/custom_object.rb +5 -3
  44. data/lib/super_diff/basic/inspection_tree_builders/data_object.rb +6 -4
  45. data/lib/super_diff/basic/inspection_tree_builders/date_like.rb +7 -5
  46. data/lib/super_diff/basic/inspection_tree_builders/default_object.rb +7 -5
  47. data/lib/super_diff/basic/inspection_tree_builders/hash.rb +7 -5
  48. data/lib/super_diff/basic/inspection_tree_builders/primitive.rb +2 -0
  49. data/lib/super_diff/basic/inspection_tree_builders/range_object.rb +19 -0
  50. data/lib/super_diff/basic/inspection_tree_builders/time_like.rb +8 -8
  51. data/lib/super_diff/basic/inspection_tree_builders.rb +15 -9
  52. data/lib/super_diff/basic/operation_tree_builders/array.rb +6 -4
  53. data/lib/super_diff/basic/operation_tree_builders/custom_object.rb +3 -1
  54. data/lib/super_diff/basic/operation_tree_builders/data_object.rb +4 -2
  55. data/lib/super_diff/basic/operation_tree_builders/date_like.rb +2 -0
  56. data/lib/super_diff/basic/operation_tree_builders/default_object.rb +32 -31
  57. data/lib/super_diff/basic/operation_tree_builders/hash.rb +49 -46
  58. data/lib/super_diff/basic/operation_tree_builders/multiline_string.rb +5 -3
  59. data/lib/super_diff/basic/operation_tree_builders/time_like.rb +5 -3
  60. data/lib/super_diff/basic/operation_tree_builders.rb +12 -10
  61. data/lib/super_diff/basic/operation_tree_flatteners/array.rb +4 -2
  62. data/lib/super_diff/basic/operation_tree_flatteners/collection.rb +11 -11
  63. data/lib/super_diff/basic/operation_tree_flatteners/custom_object.rb +5 -3
  64. data/lib/super_diff/basic/operation_tree_flatteners/default_object.rb +6 -5
  65. data/lib/super_diff/basic/operation_tree_flatteners/hash.rb +5 -3
  66. data/lib/super_diff/basic/operation_tree_flatteners/multiline_string.rb +3 -1
  67. data/lib/super_diff/basic/operation_tree_flatteners.rb +8 -6
  68. data/lib/super_diff/basic/operation_trees/array.rb +2 -0
  69. data/lib/super_diff/basic/operation_trees/custom_object.rb +2 -0
  70. data/lib/super_diff/basic/operation_trees/default_object.rb +6 -4
  71. data/lib/super_diff/basic/operation_trees/hash.rb +2 -0
  72. data/lib/super_diff/basic/operation_trees/multiline_string.rb +3 -1
  73. data/lib/super_diff/basic/operation_trees.rb +9 -7
  74. data/lib/super_diff/basic.rb +9 -6
  75. data/lib/super_diff/core/abstract_differ.rb +2 -0
  76. data/lib/super_diff/core/abstract_inspection_tree_builder.rb +2 -0
  77. data/lib/super_diff/core/abstract_operation_tree.rb +4 -2
  78. data/lib/super_diff/core/abstract_operation_tree_builder.rb +15 -18
  79. data/lib/super_diff/core/abstract_operation_tree_flattener.rb +5 -3
  80. data/lib/super_diff/core/binary_operation.rb +3 -1
  81. data/lib/super_diff/core/colorized_document_extensions.rb +2 -0
  82. data/lib/super_diff/core/configuration.rb +14 -38
  83. data/lib/super_diff/core/differ_dispatcher.rb +4 -2
  84. data/lib/super_diff/core/gem_version.rb +2 -0
  85. data/lib/super_diff/core/helpers.rb +13 -11
  86. data/lib/super_diff/core/implementation_checks.rb +6 -2
  87. data/lib/super_diff/core/inspection_tree.rb +38 -38
  88. data/lib/super_diff/core/inspection_tree_builder_dispatcher.rb +5 -5
  89. data/lib/super_diff/core/inspection_tree_nodes/as_lines_when_rendering_to_lines.rb +3 -1
  90. data/lib/super_diff/core/inspection_tree_nodes/as_prefix_when_rendering_to_lines.rb +2 -0
  91. data/lib/super_diff/core/inspection_tree_nodes/as_prelude_when_rendering_to_lines.rb +2 -0
  92. data/lib/super_diff/core/inspection_tree_nodes/as_single_line.rb +2 -0
  93. data/lib/super_diff/core/inspection_tree_nodes/base.rb +9 -9
  94. data/lib/super_diff/core/inspection_tree_nodes/inspection.rb +2 -0
  95. data/lib/super_diff/core/inspection_tree_nodes/nesting.rb +2 -0
  96. data/lib/super_diff/core/inspection_tree_nodes/only_when.rb +5 -1
  97. data/lib/super_diff/core/inspection_tree_nodes/text.rb +2 -0
  98. data/lib/super_diff/core/inspection_tree_nodes/when_empty.rb +3 -1
  99. data/lib/super_diff/core/inspection_tree_nodes/when_non_empty.rb +3 -1
  100. data/lib/super_diff/core/inspection_tree_nodes/when_rendering_to_lines.rb +3 -1
  101. data/lib/super_diff/core/inspection_tree_nodes/when_rendering_to_string.rb +2 -0
  102. data/lib/super_diff/core/inspection_tree_nodes.rb +16 -14
  103. data/lib/super_diff/core/line.rb +9 -7
  104. data/lib/super_diff/core/no_differ_available_error.rb +7 -5
  105. data/lib/super_diff/core/no_inspection_tree_builder_available_error.rb +5 -3
  106. data/lib/super_diff/core/no_operation_tree_available_error.rb +4 -2
  107. data/lib/super_diff/core/no_operation_tree_builder_available_error.rb +7 -5
  108. data/lib/super_diff/core/operation_tree_builder_dispatcher.rb +3 -3
  109. data/lib/super_diff/core/operation_tree_finder.rb +8 -8
  110. data/lib/super_diff/core/prefix_for_next_inspection_tree_node.rb +2 -0
  111. data/lib/super_diff/core/prelude_for_next_inspection_tree_node.rb +2 -0
  112. data/lib/super_diff/core/recursion_guard.rb +6 -4
  113. data/lib/super_diff/core/tiered_lines.rb +2 -0
  114. data/lib/super_diff/core/tiered_lines_elider.rb +53 -54
  115. data/lib/super_diff/core/tiered_lines_formatter.rb +6 -4
  116. data/lib/super_diff/core/unary_operation.rb +2 -0
  117. data/lib/super_diff/core.rb +31 -29
  118. data/lib/super_diff/csi/bold_sequence.rb +2 -0
  119. data/lib/super_diff/csi/color.rb +4 -4
  120. data/lib/super_diff/csi/color_sequence_block.rb +3 -1
  121. data/lib/super_diff/csi/colorized_document.rb +7 -9
  122. data/lib/super_diff/csi/document.rb +15 -18
  123. data/lib/super_diff/csi/eight_bit_color.rb +32 -37
  124. data/lib/super_diff/csi/four_bit_color.rb +12 -9
  125. data/lib/super_diff/csi/reset_sequence.rb +2 -0
  126. data/lib/super_diff/csi/twenty_four_bit_color.rb +22 -21
  127. data/lib/super_diff/csi/uncolorized_document.rb +2 -0
  128. data/lib/super_diff/csi.rb +12 -10
  129. data/lib/super_diff/differs.rb +6 -4
  130. data/lib/super_diff/equality_matchers/array.rb +18 -16
  131. data/lib/super_diff/equality_matchers/base.rb +6 -4
  132. data/lib/super_diff/equality_matchers/default.rb +5 -3
  133. data/lib/super_diff/equality_matchers/defaults.rb +2 -0
  134. data/lib/super_diff/equality_matchers/hash.rb +18 -16
  135. data/lib/super_diff/equality_matchers/main.rb +3 -1
  136. data/lib/super_diff/equality_matchers/multiline_string.rb +18 -16
  137. data/lib/super_diff/equality_matchers/primitive.rb +15 -13
  138. data/lib/super_diff/equality_matchers/singleline_string.rb +16 -14
  139. data/lib/super_diff/equality_matchers.rb +11 -9
  140. data/lib/super_diff/errors.rb +4 -2
  141. data/lib/super_diff/object_inspection.rb +17 -15
  142. data/lib/super_diff/operation_tree_builders.rb +6 -4
  143. data/lib/super_diff/operation_tree_flatteners.rb +6 -4
  144. data/lib/super_diff/operation_trees.rb +6 -4
  145. data/lib/super_diff/operations.rb +4 -2
  146. data/lib/super_diff/rails.rb +4 -2
  147. data/lib/super_diff/rspec/augmented_matcher.rb +3 -1
  148. data/lib/super_diff/rspec/differ.rb +16 -7
  149. data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +2 -0
  150. data/lib/super_diff/rspec/differs/collection_including.rb +2 -0
  151. data/lib/super_diff/rspec/differs/hash_including.rb +2 -0
  152. data/lib/super_diff/rspec/differs/object_having_attributes.rb +2 -0
  153. data/lib/super_diff/rspec/differs.rb +6 -4
  154. data/lib/super_diff/rspec/inspection_tree_builders/collection_containing_exactly.rb +12 -10
  155. data/lib/super_diff/rspec/inspection_tree_builders/collection_including.rb +10 -8
  156. data/lib/super_diff/rspec/inspection_tree_builders/double.rb +20 -18
  157. data/lib/super_diff/rspec/inspection_tree_builders/generic_describable_matcher.rb +2 -0
  158. data/lib/super_diff/rspec/inspection_tree_builders/hash_including.rb +10 -8
  159. data/lib/super_diff/rspec/inspection_tree_builders/instance_of.rb +2 -0
  160. data/lib/super_diff/rspec/inspection_tree_builders/kind_of.rb +2 -0
  161. data/lib/super_diff/rspec/inspection_tree_builders/object_having_attributes.rb +12 -10
  162. data/lib/super_diff/rspec/inspection_tree_builders/primitive.rb +2 -0
  163. data/lib/super_diff/rspec/inspection_tree_builders/value_within.rb +6 -4
  164. data/lib/super_diff/rspec/inspection_tree_builders.rb +12 -10
  165. data/lib/super_diff/rspec/matcher_text_builders/base.rb +12 -12
  166. data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +19 -17
  167. data/lib/super_diff/rspec/matcher_text_builders/contain_exactly.rb +3 -1
  168. data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +7 -5
  169. data/lib/super_diff/rspec/matcher_text_builders/match.rb +6 -4
  170. data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +5 -3
  171. data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +20 -18
  172. data/lib/super_diff/rspec/matcher_text_builders.rb +9 -7
  173. data/lib/super_diff/rspec/matcher_text_template.rb +34 -39
  174. data/lib/super_diff/rspec/monkey_patches.rb +129 -56
  175. data/lib/super_diff/rspec/object_inspection.rb +7 -5
  176. data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +4 -4
  177. data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +2 -0
  178. data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +2 -0
  179. data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +2 -0
  180. data/lib/super_diff/rspec/operation_tree_builders.rb +6 -4
  181. data/lib/super_diff/rspec-rails.rb +4 -2
  182. data/lib/super_diff/rspec.rb +27 -14
  183. data/lib/super_diff/version.rb +3 -1
  184. data/lib/super_diff.rb +24 -26
  185. data/super_diff.gemspec +20 -19
  186. metadata +6 -185
  187. data/spec/examples.txt +0 -450
  188. data/spec/integration/rails/active_record_spec.rb +0 -21
  189. data/spec/integration/rails/active_support_spec.rb +0 -19
  190. data/spec/integration/rails/engines_spec.rb +0 -25
  191. data/spec/integration/rails/hash_with_indifferent_access_spec.rb +0 -21
  192. data/spec/integration/rspec/be_falsey_matcher_spec.rb +0 -58
  193. data/spec/integration/rspec/be_matcher_spec.rb +0 -605
  194. data/spec/integration/rspec/be_nil_matcher_spec.rb +0 -57
  195. data/spec/integration/rspec/be_predicate_matcher_spec.rb +0 -615
  196. data/spec/integration/rspec/be_truthy_matcher_spec.rb +0 -62
  197. data/spec/integration/rspec/contain_exactly_matcher_spec.rb +0 -377
  198. data/spec/integration/rspec/eq_matcher_spec.rb +0 -1066
  199. data/spec/integration/rspec/generic_describable_matchers_spec.rb +0 -177
  200. data/spec/integration/rspec/have_attributes_matcher_spec.rb +0 -443
  201. data/spec/integration/rspec/have_predicate_matcher_spec.rb +0 -478
  202. data/spec/integration/rspec/include_matcher_spec.rb +0 -452
  203. data/spec/integration/rspec/magic_metadata_spec.rb +0 -51
  204. data/spec/integration/rspec/match_array_matcher_spec.rb +0 -424
  205. data/spec/integration/rspec/match_matcher_spec.rb +0 -1359
  206. data/spec/integration/rspec/raise_error_matcher_spec.rb +0 -1488
  207. data/spec/integration/rspec/respond_to_matcher_spec.rb +0 -999
  208. data/spec/integration/rspec/third_party_matcher_spec.rb +0 -245
  209. data/spec/integration/rspec/unhandled_errors_spec.rb +0 -150
  210. data/spec/spec_helper.rb +0 -91
  211. data/spec/support/colorizer.rb +0 -9
  212. data/spec/support/command_runner.rb +0 -253
  213. data/spec/support/helpers.rb +0 -21
  214. data/spec/support/integration/helpers.rb +0 -124
  215. data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +0 -104
  216. data/spec/support/integration/matchers.rb +0 -177
  217. data/spec/support/integration/test_programs/base.rb +0 -143
  218. data/spec/support/integration/test_programs/plain.rb +0 -19
  219. data/spec/support/integration/test_programs/rspec_active_record.rb +0 -20
  220. data/spec/support/integration/test_programs/rspec_active_support.rb +0 -20
  221. data/spec/support/integration/test_programs/rspec_rails.rb +0 -20
  222. data/spec/support/integration/test_programs/rspec_rails_engine.rb +0 -20
  223. data/spec/support/models/a.rb +0 -11
  224. data/spec/support/models/active_record/person.rb +0 -28
  225. data/spec/support/models/active_record/query.rb +0 -15
  226. data/spec/support/models/active_record/shipping_address.rb +0 -24
  227. data/spec/support/models/customer.rb +0 -22
  228. data/spec/support/models/empty_class.rb +0 -6
  229. data/spec/support/models/item.rb +0 -10
  230. data/spec/support/models/order.rb +0 -9
  231. data/spec/support/models/person.rb +0 -20
  232. data/spec/support/models/player.rb +0 -30
  233. data/spec/support/models/point.rb +0 -7
  234. data/spec/support/models/shipping_address.rb +0 -25
  235. data/spec/support/shared_examples/active_record.rb +0 -428
  236. data/spec/support/shared_examples/active_support.rb +0 -188
  237. data/spec/support/shared_examples/elided_diffs.rb +0 -938
  238. data/spec/support/shared_examples/hash_with_indifferent_access.rb +0 -749
  239. data/spec/support/shared_examples/key.rb +0 -123
  240. data/spec/support/unit/helpers.rb +0 -24
  241. data/spec/support/unit/matchers/be_deprecated_in_favor_of.rb +0 -39
  242. data/spec/support/unit/matchers/match_output.rb +0 -40
  243. data/spec/unit/active_record/object_inspection_spec.rb +0 -289
  244. data/spec/unit/active_support/object_inspection_spec.rb +0 -170
  245. data/spec/unit/basic/inspection_tree_builders/data_object_spec.rb +0 -146
  246. data/spec/unit/basic/operation_tree_builders/data_object_spec.rb +0 -82
  247. data/spec/unit/basic/operation_tree_flatteners/array_spec.rb +0 -637
  248. data/spec/unit/basic/operation_tree_flatteners/custom_object_spec.rb +0 -685
  249. data/spec/unit/basic/operation_tree_flatteners/default_object_spec.rb +0 -685
  250. data/spec/unit/basic/operation_tree_flatteners/hash_spec.rb +0 -671
  251. data/spec/unit/basic/operation_tree_flatteners/multiline_string_spec.rb +0 -131
  252. data/spec/unit/core/configuration_no_rspec_spec.rb +0 -58
  253. data/spec/unit/core/configuration_spec.rb +0 -176
  254. data/spec/unit/core/helpers_spec.rb +0 -68
  255. data/spec/unit/core/tiered_lines_elider_spec.rb +0 -6328
  256. data/spec/unit/core/tiered_lines_formatter_spec.rb +0 -131
  257. data/spec/unit/deprecations_spec.rb +0 -176
  258. data/spec/unit/equality_matchers/main_spec.rb +0 -1842
  259. data/spec/unit/rspec/matchers/be_compared_to_spec.rb +0 -23
  260. data/spec/unit/rspec/matchers/be_falsey_spec.rb +0 -9
  261. data/spec/unit/rspec/matchers/be_nil_spec.rb +0 -9
  262. data/spec/unit/rspec/matchers/be_predicate_spec.rb +0 -31
  263. data/spec/unit/rspec/matchers/be_spec.rb +0 -17
  264. data/spec/unit/rspec/matchers/be_truthy_spec.rb +0 -9
  265. data/spec/unit/rspec/matchers/contain_exactly_spec.rb +0 -11
  266. data/spec/unit/rspec/matchers/eq_spec.rb +0 -9
  267. data/spec/unit/rspec/matchers/have_attributes_spec.rb +0 -11
  268. data/spec/unit/rspec/matchers/have_predicate_spec.rb +0 -21
  269. data/spec/unit/rspec/matchers/include_spec.rb +0 -21
  270. data/spec/unit/rspec/matchers/match_array_spec.rb +0 -11
  271. data/spec/unit/rspec/matchers/match_spec.rb +0 -9
  272. data/spec/unit/rspec/matchers/raise_error_spec.rb +0 -77
  273. data/spec/unit/rspec/matchers/respond_to_spec.rb +0 -85
  274. data/spec/unit/rspec/object_inspection/rspec_matcher_spec.rb +0 -91
  275. data/spec/unit/rspec/object_inspection_spec.rb +0 -471
  276. 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, "super_diff/basic/operation_trees/array"
5
- autoload :CustomObject, "super_diff/basic/operation_trees/custom_object"
6
- autoload :DefaultObject, "super_diff/basic/operation_trees/default_object"
7
- autoload :Hash, "super_diff/basic/operation_trees/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
- "super_diff/basic/operation_trees/multiline_string"
12
+ 'super_diff/basic/operation_trees/multiline_string'
11
13
  )
12
14
 
13
15
  class Main
14
16
  def self.call(*args)
15
- warn <<~EOT
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
- EOT
21
+ WARNING
20
22
  SuperDiff.find_operation_tree_for(*args)
21
23
  end
22
24
  end
@@ -1,12 +1,14 @@
1
- require "super_diff/basic/differs"
2
- require "super_diff/basic/inspection_tree_builders"
3
- require "super_diff/basic/operation_tree_builders"
4
- require "super_diff/basic/operation_tree_flatteners"
5
- require "super_diff/basic/operation_trees"
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, "super_diff/basic/diff_formatters"
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,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SuperDiff
2
4
  module Core
3
5
  class AbstractDiffer
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SuperDiff
2
4
  module Core
3
5
  class AbstractInspectionTreeBuilder
@@ -1,4 +1,6 @@
1
- require "forwardable"
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} [", "]>") do
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, index|
35
- if (
36
- operation.name == :insert &&
37
- (
38
- delete_operation =
39
- unmatched_delete_operations.find do |op|
40
- op.key == operation.key
41
- end
42
- ) && (insert_operation = operation)
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
- if should_compare?(operation, next_operation)
80
- compare(operation.value, next_operation.value)
81
- else
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 > 0
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 > 0
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
- @_tiered_lines ||= build_tiered_lines
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 BinaryOperation
@@ -14,7 +16,7 @@ module SuperDiff
14
16
  :right_value!,
15
17
  :left_index!,
16
18
  :right_index!,
17
- children: []
19
+ { children: [] }
18
20
  ]
19
21
  )
20
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SuperDiff
2
4
  module Core
3
5
  module ColorizedDocumentExtensions
@@ -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
- alias_method(
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
- alias_method(
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
- alias_method :add_extra_differ_class, :add_extra_differ_classes
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
- alias_method :prepend_extra_differ_class, :prepend_extra_differ_classes
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
- alias_method(
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
- alias_method(
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
- alias_method(
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
- alias_method(
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
- alias_method(
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
- alias_method(
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["CI"] == "true"
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
  class GemVersion
@@ -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
- "numbers"
31
+ 'numbers'
30
32
  when String
31
- "strings"
33
+ 'strings'
32
34
  when Symbol
33
- "symbols"
35
+ 'symbols'
34
36
  else
35
- "objects"
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
- "0x%x" % object.hash
54
+ '0x%x' % object.hash
53
55
  end
54
- elsif ruby_version_matches?(">= 2.7.0")
55
- require "json"
56
- require "objspace"
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) ? "0x%016x" % Integer(json["address"], 16) : ""
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
- "0x%016x" % (object.object_id * 2)
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 > 0
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 def unimplemented_instance_method!
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
- protected def unimplemented_class_method!
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
- @_before_each_callbacks ||= Hash.new { |h, k| h[k] = [] }
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("") do |string, node|
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?(">= 2.7.1")
64
+ if Helpers.ruby_version_matches?('>= 2.7.1')
63
65
  t.add_inspection_of(value, **{})
64
66
  else
65
- t.add_inspection_of(*[value, {}])
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?(">= 2.7.1")
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(*[hash[key], {}])
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 > 0
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, *args, **options, &block)
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, *args, **options, &block))
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, *args, **options, &block)
130
- node_class.new(self, *args, **options, &block)
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
- object!
138
- type!
139
- indentation_level!
140
- nodes!
141
- tiered_lines!
142
- prelude!
143
- prefix!
144
- node!
145
- index!
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..-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..-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
- [tiered_lines[-1].with_value_appended(rendering)]
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
- Line.new(
203
- type: type,
204
- indentation_level: indentation_level,
205
- value: rendering
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
- if resolved_class
10
- resolved_class.call(object)
11
- else
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 + "," : string
40
+ add_comma? ? "#{string}," : string
39
41
  end
40
42
 
41
43
  def render_to_lines(object, type:, indentation_level:)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SuperDiff
2
4
  module Core
3
5
  module InspectionTreeNodes
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SuperDiff
2
4
  module Core
3
5
  module InspectionTreeNodes
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SuperDiff
2
4
  module Core
3
5
  module InspectionTreeNodes