Class: BitBalloon::Deploy
- Inherits:
-
Model
- Object
- Model
- BitBalloon::Deploy
show all
- Defined in:
- lib/bitballoon/deploy.rb
Instance Attribute Summary
Attributes inherited from Model
#attributes, #client, #prefix
Instance Method Summary
collapse
Methods inherited from Model
#collection, collection, #destroy, fields, #initialize, #path, #process, #refresh, #update
Instance Method Details
#error? ⇒ Boolean
47
48
49
|
# File 'lib/bitballoon/deploy.rb', line 47
def error?
state == "error"
end
|
#publish ⇒ Object
Also known as:
restore
51
52
53
54
55
|
# File 'lib/bitballoon/deploy.rb', line 51
def publish
response = client.request(:post, ::File.join(path, "restore"))
process(response.parsed)
self
end
|
#ready? ⇒ Boolean
43
44
45
|
# File 'lib/bitballoon/deploy.rb', line 43
def ready?
state == "ready"
end
|
#upload_dir(dir) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/bitballoon/deploy.rb', line 7
def upload_dir(dir)
return unless state == "uploading"
shas = Hash.new { [] }
glob = ::File.join(dir, "**", "*")
Dir.glob(glob) do |file|
next unless ::File.file?(file)
pathname = ::File.join("/", file[dir.length..-1])
next if pathname.match(/(^\/?__MACOSX\/|\/\.)/)
sha = Digest::SHA1.hexdigest(::File.read(file))
shas[sha] = shas[sha] + [pathname]
end
(required || []).each do |sha|
shas[sha].each do |pathname|
client.request(:put, ::File.join(path, "files", URI.encode(pathname)), :body => ::File.read(::File.join(dir, pathname)), :headers => {"Content-Type" => "application/octet-stream"})
end
end
refresh
end
|
#wait_for_ready(timeout = 900) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/bitballoon/deploy.rb', line 30
def wait_for_ready(timeout = 900)
start = Time.now
while !(ready?)
sleep 5
refresh
puts "Got state: #{state}"
raise "Error processing site: #{error_message}" if error?
yield(self) if block_given?
raise "Timeout while waiting for ready" if Time.now - start > timeout
end
self
end
|