Class: CacheBuster::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/cache-buster/cli.rb

Instance Method Summary collapse

Instance Method Details

#clear(path = 'news') ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cache-buster/cli.rb', line 5

def clear(path = 'news')
  if options[:hard]
    say "********************************************************************************************************\n", :red
    say "*                                 SUPER MEGA IMPORTANT WARNING                                         *\n", :red
    say "********************************************************************************************************\n", :red
    say "* This will reboot all three backend nodes cleanly to completely clear the mysterious invisible caches *\n", :red
    say "* Before doing this, you should try and clear a page cache without the --hard option                   *\n", :red
    say "********************************************************************************************************\n\n", :red
    if yes?('Are you sure you want to proceed?', :yellow)
      say "\nPreparing to clear the cache with brute force. Press ctrl + c to cancel\n", :red
      (1..5).to_a.reverse_each { |i| say "#{i}.. ", :red ; sleep 1 }
      say "\n\nClearing cache.... ", :red
      Rackspace.new.clear
      say "Done!\n", :green
    else
      say "\nAborting. This was probably the right decision.\n", :green
    end
  else
    say "Clearing cache for #{path}..... ", :yellow
    Cloudflare.new.clear(path)
    say "Done!", :green
  end
end

#watchObject



30
31
32
33
# File 'lib/cache-buster/cli.rb', line 30

def watch
  say "Waiting for someone to press a button"
  Pi.new
end