Class: Prick::Diff
- Inherits:
-
Object
- Object
- Prick::Diff
- Defined in:
- lib/prick/diff.rb
Overview
Database diff
Instance Attribute Summary collapse
-
#after_table_changes ⇒ Object
readonly
Returns the value of attribute after_table_changes.
-
#before_table_changes ⇒ Object
readonly
Diff split into before/after table changes.
-
#diff ⇒ Object
readonly
Diff as a list of lines.
-
#table_changes ⇒ Object
readonly
Returns the value of attribute table_changes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(db1, db2) ⇒ Diff
constructor
A new instance of Diff.
-
#same? ⇒ Boolean
Return true if the two databases are equal.
-
#write(file1, file2 = nil, file3 = nil, mark: nil) ⇒ Object
:call-seq: write(file, mark: true) write(file1, file2, file3, mark: false).
Constructor Details
Instance Attribute Details
#after_table_changes ⇒ Object (readonly)
Returns the value of attribute after_table_changes.
10 11 12 |
# File 'lib/prick/diff.rb', line 10 def after_table_changes @after_table_changes end |
#before_table_changes ⇒ Object (readonly)
Diff split into before/after table changes
8 9 10 |
# File 'lib/prick/diff.rb', line 8 def before_table_changes @before_table_changes end |
#diff ⇒ Object (readonly)
Diff as a list of lines
5 6 7 |
# File 'lib/prick/diff.rb', line 5 def diff @diff end |
#table_changes ⇒ Object (readonly)
Returns the value of attribute table_changes.
9 10 11 |
# File 'lib/prick/diff.rb', line 9 def table_changes @table_changes end |
Class Method Details
Instance Method Details
#same? ⇒ Boolean
Return true if the two databases are equal. Named #same? to avoid name collision with the built-in #equal? method
24 |
# File 'lib/prick/diff.rb', line 24 def same?() diff.empty? end |
#write(file1, file2 = nil, file3 = nil, mark: nil) ⇒ Object
:call-seq:
write(file, mark: true)
write(file1, file2, file3, mark: false)
Write the diff between the databases to the given file(s). Return true if the databases are equal
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/prick/diff.rb', line 32 def write(file1, file2 = nil, file3 = nil, mark: nil) if file2.nil? && file3.nil? file2 = file3 = file1 mark = mark.nil? ? true : mark elsif file2.nil? != file3.nil? Prick.failure "Either none or both of `file2` and `file3` should be nil" else mark = mark.nil? ? false : mark end write_segment(file1, :before_table_changes, mark: mark) write_segment(file2, :table_changes, mark: mark) write_segment(file3, :after_table_changes, mark: mark) end |