Class: GitWaybackMachine::Engine
- Inherits:
-
Object
- Object
- GitWaybackMachine::Engine
- Defined in:
- lib/git_wayback_machine/engine.rb
Instance Method Summary collapse
-
#initialize ⇒ Engine
constructor
A new instance of Engine.
- #move_to(entry) ⇒ Object
- #rollback! ⇒ Object
- #start! ⇒ Object
- #stash! ⇒ Object
Constructor Details
#initialize ⇒ Engine
4 5 6 7 |
# File 'lib/git_wayback_machine/engine.rb', line 4 def initialize @history = GitWaybackMachine::History.new @navigator = GitWaybackMachine::Navigator.new(@history) end |
Instance Method Details
#move_to(entry) ⇒ Object
22 23 24 |
# File 'lib/git_wayback_machine/engine.rb', line 22 def move_to(entry) `git reset --hard #{entry.sha}` end |
#rollback! ⇒ Object
30 31 32 33 34 |
# File 'lib/git_wayback_machine/engine.rb', line 30 def rollback! puts "\rJumping back to the reality!" move_to @history[0] `git stash pop` unless @stash.include?("No local changes to save") end |
#start! ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/git_wayback_machine/engine.rb', line 9 def start! stash! @navigator.on_change do |commit| move_to commit end rescue Interrupt => e nil # that's cool ensure rollback! end |
#stash! ⇒ Object
26 27 28 |
# File 'lib/git_wayback_machine/engine.rb', line 26 def stash! @stash = `git stash -u` end |