Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please remove protected from raw_array #13

Open
SamiSieranoja opened this issue Mar 2, 2019 · 3 comments
Open

Please remove protected from raw_array #13

SamiSieranoja opened this issue Mar 2, 2019 · 3 comments

Comments

@SamiSieranoja
Copy link

SamiSieranoja commented Mar 2, 2019

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
@mvz
Copy link

mvz commented Jan 22, 2020

You can create a subclass and expose #raw_array there, or just do diff.send :raw_array.

@sixtyfive
Copy link

That's unnecessarily cumbersome. Please do do something here, perhaps provide #to_a ?

@lenlo
Copy link

lenlo commented Nov 19, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants