Class: Patches::Runner
- Inherits:
-
Object
- Object
- Patches::Runner
- Defined in:
- lib/patches/runner.rb
Defined Under Namespace
Classes: UnknownPatch
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #complete!(patch_path) ⇒ Object
- #format_exception(e) ⇒ Object
-
#initialize(path = nil) ⇒ Runner
constructor
A new instance of Runner.
- #patch_path(patch_path) ⇒ Object
- #pending ⇒ Object
- #perform ⇒ Object
Constructor Details
#initialize(path = nil) ⇒ Runner
Returns a new instance of Runner.
6 7 8 |
# File 'lib/patches/runner.rb', line 6 def initialize(path = nil) @path = path || Patches.default_path end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
2 3 4 |
# File 'lib/patches/runner.rb', line 2 def path @path end |
Instance Method Details
#complete!(patch_path) ⇒ Object
27 28 29 |
# File 'lib/patches/runner.rb', line 27 def complete!(patch_path) Patches::Patch.create!(path: patch_path) end |
#format_exception(e) ⇒ Object
39 40 41 |
# File 'lib/patches/runner.rb', line 39 def format_exception(e) "#{e.class.name}: #{e.} (#{e.backtrace.first})" end |
#patch_path(patch_path) ⇒ Object
31 32 33 |
# File 'lib/patches/runner.rb', line 31 def patch_path(patch_path) File.basename(patch_path) end |
#pending ⇒ Object
35 36 37 |
# File 'lib/patches/runner.rb', line 35 def pending @pending ||= Patches::Pending.new(path) end |
#perform ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/patches/runner.rb', line 10 def perform completed_patches = pending.each do |file_path| klass = load_class(file_path) instance = klass.new Patches.logger.info("Running #{klass} from #{file_path}") begin instance.run rescue => e Patches::Notifier.notify_failure(file_path, format_exception(e)) raise e end complete!(patch_path(file_path)) end Patches::Notifier.notify_success(completed_patches) completed_patches end |