Class: Karo::Cache

Inherits:
Thor
  • Object
show all
Defined in:
lib/karo/cache.rb

Instance Method Summary collapse

Instance Method Details

#remove(name = "") ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/karo/cache.rb', line 22

def remove(name="")
   invoke :search

   configuration = Config.load_configuration(options)
   path = File.join(configuration["path"], "shared/cache")
   ssh  = "ssh #{configuration["user"]}@#{configuration["host"]}"
   cmd  = "find #{path} -type f -name \"*#{name}*\" -delete"

   to_run = "#{ssh} '#{cmd}'"

   if yes?("Are you sure?", :yellow)
     say to_run, :green if options[:verbose]
     system to_run
     say "Cache removed", :green
   else
     say "Cache not removed", :yellow
   end
end

#search(name = "") ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/karo/cache.rb', line 9

def search(name="")
  configuration = Config.load_configuration(options)
  path = File.join(configuration["path"], "shared/cache")
   ssh  = "ssh #{configuration["user"]}@#{configuration["host"]}"
   cmd  = "find #{path} -type f -name \"*#{name}*\""

   to_run = "#{ssh} '#{cmd}'"

   say to_run, :green if options[:verbose]
   system to_run
end