Class: Mutant::CLI::Command::Session::GC Private

Inherits:
Mutant::CLI::Command::Session show all
Defined in:
lib/mutant/cli/command/session.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Subject

Constant Summary collapse

NAME =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'gc'
SHORT_DESCRIPTION =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'Remove incompatible and old session results'
SUBCOMMANDS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

[].freeze
OPTIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%i[add_gc_options].freeze
DEFAULT_KEEP =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

100

Constants inherited from Mutant::CLI::Command::Session

RESULTS_DIR

Instance Method Summary collapse

Methods inherited from Mutant::CLI::Command

#call, command_name, #full_name, parse, short_description

Constructor Details

#initializeGC

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of GC.



235
236
237
238
# File 'lib/mutant/cli/command/session.rb', line 235

def initialize(*)
  super
  @keep = DEFAULT_KEEP
end

Instance Method Details

#actionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/mutant/cli/command/session.rb', line 240

def action
  incompatible, compatible = partition_sessions

  incompatible.each(&:delete)

  excess = compatible.length > @keep ? compatible.first(compatible.length - @keep) : []
  excess.each(&:delete)

  print("Removed #{incompatible.length + excess.length} session(s)")

  Either::Right.new(nil)
end