class Jeny::StateManager

State Manager abstraction used by Snippets to work atomically.

An implementation is supposed to be stateless (no instance variables). The methods receive a `state` argument, which is an OpenStruct that can be used to track state accros calls.

See StateManager::Git for a typical implementation using git.

Attributes

config[R]

Public Class Methods

new(config) click to toggle source
# File lib/jeny/state_manager.rb, line 11
def initialize(config)
  @config = config
end

Public Instance Methods

commit(changed, state) click to toggle source

Commit all changes to the files in `changed`.

The method MAY raise an Error, but it will force jeny to reset everything.

# File lib/jeny/state_manager.rb, line 46
def commit(changed, state)
end
reset(changed, state) click to toggle source

Reset all changes to files in `changed`, typically because an error occured.

The method SHOULD NOT raise an Error in any case.

# File lib/jeny/state_manager.rb, line 39
def reset(changed, state)
end
stash(state) click to toggle source

Make sure the working directory is clean, for instance by stashing any pending change.

The method MAY raise an Error if the current state is not clean and nothing can be done about it.

The method SHOULD NOT raise an Error is nothing needs to be done.

# File lib/jeny/state_manager.rb, line 23
def stash(state)
end
unstash(state) click to toggle source

Unstash changes stashed the last time `stash` has been called.

This method MAY NOT raise errors since a previous `stash` has been successfuly done earlier.

The method SHOULD NOT raise an Error is nothing needs to be done.

# File lib/jeny/state_manager.rb, line 32
def unstash(state)
end