Class: Admincredible::Resources::Upgrade

Inherits:
Admincredible::Resource show all
Defined in:
lib/admincredible/resources/Upgrade.rb

Instance Attribute Summary

Attributes inherited from Admincredible::Resource

#client

Instance Method Summary collapse

Methods inherited from Admincredible::Resource

#config, #connection, #initialize

Constructor Details

This class inherits a constructor from Admincredible::Resource

Instance Method Details

#cleanupObject



40
41
42
# File 'lib/admincredible/resources/Upgrade.rb', line 40

def cleanup
  client.jget('upgrade', 'cleanup')
end

#createObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/admincredible/resources/Upgrade.rb', line 44

def create
  response = download
  return response unless response['status'] == 200

  response = create_restoration_file
  return response unless response['status'] == 200

  response = start
  return response unless response['status'] == 302

  response = step
  return response unless response['status'] == 200

  response = finalize
  return response unless response['status'] == 200

  return cleanup
end

#create_restoration_fileObject



12
13
14
# File 'lib/admincredible/resources/Upgrade.rb', line 12

def create_restoration_file
  client.jget('upgrade', 'create_restoration_file')
end

#downloadObject



8
9
10
# File 'lib/admincredible/resources/Upgrade.rb', line 8

def download
  client.jget('upgrade', 'download')
end

#finalizeObject



36
37
38
# File 'lib/admincredible/resources/Upgrade.rb', line 36

def finalize
  client.jget('upgrade', 'finalize')
end

#infoObject



4
5
6
# File 'lib/admincredible/resources/Upgrade.rb', line 4

def info
  client.jget('upgrade', 'info')['data']
end

#startObject



16
17
18
# File 'lib/admincredible/resources/Upgrade.rb', line 16

def start
  client.jget('upgrade', 'start')
end

#step(repeat_until_done = true) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/admincredible/resources/Upgrade.rb', line 20

def step(repeat_until_done=true)
  response = client.jget('upgrade', 'step')

  if response['status'] == 'working' && repeat_until_done
    seconds_left = config.step_after_seconds

    seconds_left.times do |i|
      sleep 1
    end

    return step
  end

  response
end