Class: Kettle::Drift::Process
- Inherits:
-
Object
- Object
- Kettle::Drift::Process
- Defined in:
- lib/kettle/drift/process.rb,
lib/kettle/drift/process/printer.rb,
lib/kettle/drift/process/calculate_diff.rb
Defined Under Namespace
Modules: CalculateDiff Classes: Printer, Result
Instance Attribute Summary collapse
-
#lock_file ⇒ Object
readonly
Returns the value of attribute lock_file.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#new_results ⇒ Object
readonly
Returns the value of attribute new_results.
-
#old_results ⇒ Object
readonly
Returns the value of attribute old_results.
-
#printer_class ⇒ Object
readonly
Returns the value of attribute printer_class.
-
#project_root ⇒ Object
readonly
Returns the value of attribute project_root.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(project_root:, results:, lock_path:, mode: :update, printer_class: Kettle::Drift::Process::Printer) ⇒ Process
constructor
A new instance of Process.
- #run ⇒ Object
Constructor Details
#initialize(project_root:, results:, lock_path:, mode: :update, printer_class: Kettle::Drift::Process::Printer) ⇒ Process
Returns a new instance of Process.
13 14 15 16 17 18 19 20 |
# File 'lib/kettle/drift/process.rb', line 13 def initialize(project_root:, results:, lock_path:, mode: :update, printer_class: Kettle::Drift::Process::Printer) @project_root = File.(project_root) @lock_file = Kettle::Drift::LockFile.new(lock_path) @old_results = lock_file.read_results @new_results = Kettle::Drift::Serializer.normalize(results, project_root: @project_root) @mode = mode @printer_class = printer_class end |
Instance Attribute Details
#lock_file ⇒ Object (readonly)
Returns the value of attribute lock_file.
11 12 13 |
# File 'lib/kettle/drift/process.rb', line 11 def lock_file @lock_file end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
11 12 13 |
# File 'lib/kettle/drift/process.rb', line 11 def mode @mode end |
#new_results ⇒ Object (readonly)
Returns the value of attribute new_results.
11 12 13 |
# File 'lib/kettle/drift/process.rb', line 11 def new_results @new_results end |
#old_results ⇒ Object (readonly)
Returns the value of attribute old_results.
11 12 13 |
# File 'lib/kettle/drift/process.rb', line 11 def old_results @old_results end |
#printer_class ⇒ Object (readonly)
Returns the value of attribute printer_class.
11 12 13 |
# File 'lib/kettle/drift/process.rb', line 11 def printer_class @printer_class end |
#project_root ⇒ Object (readonly)
Returns the value of attribute project_root.
11 12 13 |
# File 'lib/kettle/drift/process.rb', line 11 def project_root @project_root end |
Instance Method Details
#call ⇒ Object
22 23 24 |
# File 'lib/kettle/drift/process.rb', line 22 def call run.exit_code end |
#run ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/kettle/drift/process.rb', line 26 def run diff = Kettle::Drift::Process::CalculateDiff.call(new_results, old_results) printer_class&.new(diff: diff, lock_path: lock_file.path, mode: mode)&.print_results exit_code = error_code(diff) sync_lock_file(diff) if exit_code.zero? Result.new(diff: diff, exit_code: exit_code) end |