Method: DeployInfo::State#update_state

Defined in:
lib/deploy-info/state.rb

#update_state(hash) ⇒ Object

rubocop: disable AbcSize



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/deploy-info/state.rb', line 34

def update_state(hash) # rubocop: disable AbcSize
  # => Check if App Already Exists
  existing = find_state(hash[:name])
  if existing # => Update the Existing App
    state.delete(existing)
    audit_string = [DateTime.now, hash[:creator]].join(' - ')
    existing[:last_modified] = existing[:last_modified].is_a?(Array) ? existing[:last_modified].take(5).unshift(audit_string) : [audit_string]
    hash = existing
  end

  # => Update the State
  state.push(hash)

  # => Write Out the Updated State
  write_state
end