Class: Traquitana::Cleaner

Inherits:
Object
  • Object
show all
Defined in:
lib/cleaner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCleaner

Returns a new instance of Cleaner.



5
6
7
8
9
10
11
# File 'lib/cleaner.rb', line 5

def initialize
  @config  = Traquitana::Config.instance
  @config.load

  @options = @config.password.size > 1 ? { password: @config.password } : {}
  @network = Traquitana::SSH.new(@config.host, @config.user, @options)
end

Instance Attribute Details

#networkObject

Returns the value of attribute network.



3
4
5
# File 'lib/cleaner.rb', line 3

def network
  @network
end

Instance Method Details

#runObject



13
14
15
16
17
# File 'lib/cleaner.rb', line 13

def run
  STDOUT.print 'Cleaning old files ... '
  @network.execute(["find #{@config.directory}/traq -type f -iname '*.zip' -o -iname '*.list' | sort | head -n-2 | xargs rm $1"])
  STDOUT.puts 'done.'
end