module DiffJson
Public Class Methods
diff(old_json, new_json, return_type, diff_opts = {}, output_opts = {})
click to toggle source
# File lib/diff_json/diff.rb, line 4 def self.diff(old_json, new_json, return_type, diff_opts = {}, output_opts = {}) completed_diff = Diff.new(old_json, new_json, **diff_opts) return case return_type when :raw completed_diff when :patch patch_operations = [] completed_diff.diff.each do |path, operations| operations.each do |op| patch_operations << op if [:add, :replace, :remove].include?(op[:op]) or (op[:op] == :move and path == op[:from]) end end return patch_operations when :html HtmlOutput.new(completed_diff, **output_opts) end end