class Cir::DiffManager
Abstraction above chosen diff library so that we can switch it at runtime if/when needed
Public Class Methods
create(source, destination)
click to toggle source
# File lib/cir/diff_manager.rb, line 20 def self.create(source, destination) # Compare stored version in our internal repo and then the current version diff = Diffy::Diff.new(source, destination, source: "files", diff: "-U 3") # And finally return diff object with standardized interface DiffManager.new(diff) end
new(diff)
click to toggle source
Persist generated diff inside the class
# File lib/cir/diff_manager.rb, line 32 def initialize(diff) @diff = diff end
Public Instance Methods
changed?()
click to toggle source
Return true if the files are different (e.g. diff is non-empty)
# File lib/cir/diff_manager.rb, line 40 def changed? return !@diff.to_s.empty? end
to_s()
click to toggle source
Serialize the diff into string that can be printed to the console
# File lib/cir/diff_manager.rb, line 46 def to_s # We want nice colors by default @diff.to_s(:color) end