Skip to content

Instantly share code, notes, and snippets.

@nwjsmith
Last active August 29, 2015 14:01
Show Gist options
  • Save nwjsmith/266e26c4814da8c257fa to your computer and use it in GitHub Desktop.
Save nwjsmith/266e26c4814da8c257fa to your computer and use it in GitHub Desktop.
psych.patch
diff --git a/lib/psych/handlers/document_stream.rb b/lib/psych/handlers/document_stream.rb
index e429993..25d10fb 100644
--- a/lib/psych/handlers/document_stream.rb
+++ b/lib/psych/handlers/document_stream.rb
@@ -18,5 +18,19 @@ module Psych
@block.call pop
end
end
+
+ class StrictDocumentStream < DocumentStream
+ def end_mapping
+ mapping = pop
+ keys = []
+ mapping.children.each_slice(2) do |(key_scalar, _)|
+ key = key_scalar.value
+ fail "whale" if keys.include? key
+ keys << key
+ end
+ mapping
+ end
+ end
+
end
end
@peeken78
Copy link

diff --git a/lib/psych/handlers/document_stream.rb b/lib/psych/handlers/document_stream.rb
index e429993..25d10fb 100644
--- a/lib/psych/handlers/document_stream.rb
+++ b/lib/psych/handlers/document_stream.rb
@@ -18,5 +18,19 @@ module Psych
@block.call pop
end
end
+

  • class StrictDocumentStream < DocumentStream
  • def end_mapping
    
  •   mapping = pop
    
  •   keys = []
    
  •   mapping.children.each_slice(2) do |(key_scalar, _)|
    
  •     key = key_scalar.value
    
  •     fail "whale" if keys.include? key
    
  •     keys << key
    
  •   end
    
  •   mapping
    
  • end
    
  • end

end
end

@peeken78
Copy link

diff --git a/lib/psych/handlers/document_stream.rb b/lib/psych/handlers/document_stream.rb
index e429993..25d10fb 100644
--- a/lib/psych/handlers/document_stream.rb
+++ b/lib/psych/handlers/document_stream.rb
@@ -18,5 +18,19 @@ module Psych
@block.call pop
end
end
+

  • class StrictDocumentStream < DocumentStream
  • def end_mapping
    
  •   mapping = pop
    
  •   keys = []
    
  •   mapping.children.each_slice(2) do |(key_scalar, _)|
    
  •     key = key_scalar.value
    
  •     fail "whale" if keys.include? key
    
  •     keys << key
    
  •   end
    
  •   mapping
    
  • end
    
  • end

end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment