Class: Strobe::CLI::DeployProgress

Inherits:
Object
  • Object
show all
Defined in:
lib/strobe/cli/deploy_progress.rb

Instance Method Summary collapse

Constructor Details

#initializeDeployProgress

Returns a new instance of DeployProgress.



3
4
5
6
7
8
# File 'lib/strobe/cli/deploy_progress.rb', line 3

def initialize
  @thread  = nil
  @width   = 50
  @current = 0
  @ticker  = CLI::Ticker.new
end

Instance Method Details

#deploy_completeObject



38
39
40
# File 'lib/strobe/cli/deploy_progress.rb', line 38

def deploy_complete
  @ticker.stop
end

#upload_completeObject



31
32
33
34
35
36
# File 'lib/strobe/cli/deploy_progress.rb', line 31

def upload_complete
  upload_progress(1.0)
  print "\n"

  @ticker.tick "Reticulating splines"
end

#upload_progress(percentage) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/strobe/cli/deploy_progress.rb', line 10

def upload_progress(percentage)
  width = 50
  left  = ( percentage * width ).round

  return if @current == left

  (@current..left).each do |i|
    arrow = nil
    right = width - i

    if i < width
      right -= 1
      arrow = ">"
    end

    print "Uploading [#{ '=' * i }#{ arrow }#{' ' * right}]\r"
  end

  @current = left
end