Class: Jeny::StateManager

Inherits:
Object
  • Object
show all
Defined in:
lib/jeny/state_manager.rb,
lib/jeny/state_manager/git.rb

Overview

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.

Direct Known Subclasses

Git

Defined Under Namespace

Classes: Git

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ StateManager

Returns a new instance of StateManager.



11
12
13
# File 'lib/jeny/state_manager.rb', line 11

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



14
15
16
# File 'lib/jeny/state_manager.rb', line 14

def config
  @config
end

Instance Method Details

#commit(changed, state) ⇒ Object

Commit all changes to the files in ‘changed`.

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



46
47
# File 'lib/jeny/state_manager.rb', line 46

def commit(changed, state)
end

#reset(changed, state) ⇒ Object

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

The method SHOULD NOT raise an Error in any case.



39
40
# File 'lib/jeny/state_manager.rb', line 39

def reset(changed, state)
end

#stash(state) ⇒ Object

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.



23
24
# File 'lib/jeny/state_manager.rb', line 23

def stash(state)
end

#unstash(state) ⇒ Object

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.



32
33
# File 'lib/jeny/state_manager.rb', line 32

def unstash(state)
end