Skip to content

Commit 8e203a8

Browse files
committed
Extract a SuperDiff::ActiveSupport module
This now contains integration with HashWithIndifferentAccess, which SuperDiff::Rails had before.
1 parent c34733e commit 8e203a8

17 files changed

+66
-53
lines changed

lib/super_diff/active_record.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require "super_diff/active_support"
2+
13
module SuperDiff
24
module ActiveRecord
35
autoload :DiffFormatters, "super_diff/active_record/diff_formatters"

lib/super_diff/active_support.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module SuperDiff
2+
module ActiveSupport
3+
autoload :DiffFormatters, "super_diff/active_support/diff_formatters"
4+
autoload :Differs, "super_diff/active_support/differs"
5+
autoload :ObjectInspection, "super_diff/active_support/object_inspection"
6+
autoload(
7+
:OperationalSequencers,
8+
"super_diff/active_support/operational_sequencers",
9+
)
10+
autoload(
11+
:OperationalSequences,
12+
"super_diff/active_support/operational_sequences",
13+
)
14+
end
15+
end
16+
17+
if defined?(SuperDiff::RSpec)
18+
SuperDiff::RSpec.configure do |config|
19+
config.add_extra_differ_class(
20+
SuperDiff::ActiveSupport::Differs::HashWithIndifferentAccess,
21+
)
22+
config.add_extra_operational_sequencer_class(
23+
SuperDiff::ActiveSupport::OperationalSequencers::HashWithIndifferentAccess,
24+
)
25+
config.add_extra_diff_formatter_class(
26+
SuperDiff::ActiveSupport::DiffFormatters::HashWithIndifferentAccess,
27+
)
28+
end
29+
end
30+
31+
SuperDiff::ObjectInspection.map.prepend(
32+
SuperDiff::ActiveSupport::ObjectInspection::MapExtension,
33+
)

lib/super_diff/rails/diff_formatters.rb renamed to lib/super_diff/active_support/diff_formatters.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module SuperDiff
2-
module Rails
2+
module ActiveSupport
33
module DiffFormatters
44
autoload(
55
:HashWithIndifferentAccess,
6-
"super_diff/rails/diff_formatters/hash_with_indifferent_access",
6+
"super_diff/active_support/diff_formatters/hash_with_indifferent_access",
77
)
88
end
99
end

lib/super_diff/rails/diff_formatters/hash_with_indifferent_access.rb renamed to lib/super_diff/active_support/diff_formatters/hash_with_indifferent_access.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module SuperDiff
2-
module Rails
2+
module ActiveSupport
33
module DiffFormatters
44
class HashWithIndifferentAccess < SuperDiff::DiffFormatters::Base
55
def self.applies_to?(operations)

lib/super_diff/rails/differs.rb renamed to lib/super_diff/active_support/differs.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module SuperDiff
2-
module Rails
2+
module ActiveSupport
33
module Differs
44
autoload(
55
:HashWithIndifferentAccess,
6-
"super_diff/rails/differs/hash_with_indifferent_access",
6+
"super_diff/active_support/differs/hash_with_indifferent_access",
77
)
88
end
99
end

lib/super_diff/rails/differs/hash_with_indifferent_access.rb renamed to lib/super_diff/active_support/differs/hash_with_indifferent_access.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module SuperDiff
2-
module Rails
2+
module ActiveSupport
33
module Differs
44
class HashWithIndifferentAccess < SuperDiff::Differs::Hash
55
def self.applies_to?(expected, actual)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module SuperDiff
2+
module ActiveSupport
3+
module ObjectInspection
4+
autoload(
5+
:Inspectors,
6+
"super_diff/active_support/object_inspection/inspectors",
7+
)
8+
autoload(
9+
:MapExtension,
10+
"super_diff/active_support/object_inspection/map_extension",
11+
)
12+
end
13+
end
14+
end

lib/super_diff/rails/object_inspection/inspectors.rb renamed to lib/super_diff/active_support/object_inspection/inspectors.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module SuperDiff
2-
module Rails
2+
module ActiveSupport
33
module ObjectInspection
44
module Inspectors
55
autoload(
66
:HashWithIndifferentAccess,
7-
"super_diff/rails/object_inspection/inspectors/hash_with_indifferent_access",
7+
"super_diff/active_support/object_inspection/inspectors/hash_with_indifferent_access",
88
)
99
end
1010
end

lib/super_diff/rails/object_inspection/inspectors/hash_with_indifferent_access.rb renamed to lib/super_diff/active_support/object_inspection/inspectors/hash_with_indifferent_access.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module SuperDiff
2-
module Rails
2+
module ActiveSupport
33
module ObjectInspection
44
module Inspectors
55
HashWithIndifferentAccess = SuperDiff::ObjectInspection::InspectionTree.new do

lib/super_diff/rails/object_inspection/map_extension.rb renamed to lib/super_diff/active_support/object_inspection/map_extension.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module SuperDiff
2-
module Rails
2+
module ActiveSupport
33
module ObjectInspection
44
module MapExtension
55
def call(object)

0 commit comments

Comments
 (0)