Class: DiffJson::Diff
- Inherits:
-
Object
- Object
- DiffJson::Diff
- Defined in:
- lib/diff_json/diff.rb
Instance Method Summary collapse
- #change_count(operation = :all) ⇒ Object
- #diff ⇒ Object
-
#initialize(old_json, new_json, **opts) ⇒ Diff
constructor
A new instance of Diff.
- #retrieve_output(output_type = :stdout, **output_opts) ⇒ Object
- #sub_diffs ⇒ Object
Constructor Details
#initialize(old_json, new_json, **opts) ⇒ Diff
Returns a new instance of Diff.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/diff_json/diff.rb', line 3 def initialize(old_json, new_json, **opts) @old_json = old_json @new_json = new_json @opts = { :debug => false, :diff_count_filter => { :only => ['$**'], :except => [] }, :ignore_object_keys => [], :generate_object_sub_diffs => {} }.merge(opts) @filtered = @opts[:diff_count_filter] != { :only => ['$**'], :except => [] } @diff = { :count => { :all => 0, :insert => 0, :update => 0, :delete => 0, :move => 0 }, :full_diff => { :old => [], :new => [] }, :sub_diffs => {} } calculate end |
Instance Method Details
#change_count(operation = :all) ⇒ Object
45 46 47 |
# File 'lib/diff_json/diff.rb', line 45 def change_count(operation = :all) return @diff[:count][operation] || 0 end |
#diff ⇒ Object
37 38 39 |
# File 'lib/diff_json/diff.rb', line 37 def diff return @diff[:full_diff] end |
#retrieve_output(output_type = :stdout, **output_opts) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/diff_json/diff.rb', line 49 def retrieve_output(output_type = :stdout, **output_opts) case output_type when :stdout when :file when :html html_output = HtmlOutput.new(self, **output_opts) return html_output end end |
#sub_diffs ⇒ Object
41 42 43 |
# File 'lib/diff_json/diff.rb', line 41 def sub_diffs return @diff[:sub_diffs] end |