Sha256: e6ccbd17855777ffbcc71a461905c4ecd4fdb98e22eb9313b14e0636aff7706d

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

require 'karo/config'
require 'thor'

module Karo

	class Cache < Thor

	  class_option :config_file, type: :string, default: Config.default_file_name,
	  						  aliases: "-c", desc: "name of the file containing server configuration"
	  class_option :environment, aliases: "-e", desc: "server environment", default: "production"

	  desc "search", "searches for any matching cache files from the shared/cache directory"
	  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}*\""

      system "#{ssh} '#{cmd}'"
	  end

	  desc "remove", "removes any matching cache files from the shared/cache directory"
	  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"

      if yes?("Are you sure?", :yellow)
        system "#{ssh} '#{cmd}'"
        say "Cache removed", :green
      else
        say "Cache not removed", :yellow
      end
	  end

	end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
karo-1.5.0 lib/karo/cache.rb
karo-1.4.0 lib/karo/cache.rb
karo-1.3.0 lib/karo/cache.rb
karo-1.2.1 lib/karo/cache.rb
karo-1.2.0 lib/karo/cache.rb