Class: Cir::DiffManager
- Inherits:
-
Object
- Object
- Cir::DiffManager
- Defined in:
- lib/cir/diff_manager.rb
Overview
Abstraction above chosen diff library so that we can switch it at runtime if/when needed
Class Method Summary collapse
Instance Method Summary collapse
-
#changed? ⇒ Boolean
Return true if the files are different (e.g. diff is non-empty).
-
#to_s ⇒ Object
Serialize the diff into string that can be printed to the console.
Class Method Details
.create(source, destination) ⇒ Object
20 21 22 23 24 25 26 |
# 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 |
Instance Method Details
#changed? ⇒ Boolean
Return true if the files are different (e.g. diff is non-empty)
40 41 42 |
# File 'lib/cir/diff_manager.rb', line 40 def changed? return !@diff.to_s.empty? end |
#to_s ⇒ Object
Serialize the diff into string that can be printed to the console
46 47 48 49 |
# File 'lib/cir/diff_manager.rb', line 46 def to_s # We want nice colors by default @diff.to_s(:color) end |