differ
differ copied to clipboard
Please remove protected from raw_array
Hi.
Could you remove "protected" from raw_array? I need the diff output in machine readable format (rather than display to user), and raw_array seems the most usable format. My use case is that I'm developing a text editor (https://github.com/SamiSieranoja/vimamsa) and I want to process the buffer contents with external program and then include the diffs of before/after in undo history.
diff --git a/lib/differ/diff.rb b/lib/differ/diff.rb
index 76d3012..5f46cb6 100644
--- a/lib/differ/diff.rb
+++ b/lib/differ/diff.rb
@@ -82,7 +82,7 @@ module Differ
end
end
- protected
+# protected
def raw_array
@raw
end
You can create a subclass and expose #raw_array
there, or just do diff.send :raw_array
.
That's unnecessarily cumbersome. Please do do something here, perhaps provide #to_a
?
I agree, I'm in the same situation. I want to process only the changes, not the part of the text that stays the same, and the only way to do so seems to be for me to go through the raw_array
myself. While it is true that I can work around this by doing diff.send(:raw_array)
, having a properly exposed API would be a lot cleaner, perhaps called #to_a
as suggested earlier or simply #parts
. Thanks for a great little gem otherwise!