class DeltaTest::CLI::StatsSaveCommand

Public Instance Methods

cleanup_tmp_table_files() click to toggle source
# File lib/delta_test/cli/stats_save_command.rb, line 31
def cleanup_tmp_table_files
  tmp_dir = DeltaTest.config.tmp_table_file.parent
  FileUtils.rm_rf(tmp_dir) if File.directory?(tmp_dir)
end
invoke!() click to toggle source
# File lib/delta_test/cli/stats_save_command.rb, line 11
def invoke!
  return if error_recorded?

  load_tmp_table_files
  cleanup_tmp_table_files

  if table.any?
    save_table_file
    stage_table_file
    sync_table_file unless @options['no-sync']
  end
end
load_tmp_table_files() click to toggle source
# File lib/delta_test/cli/stats_save_command.rb, line 24
def load_tmp_table_files
  tmp_table_files.each do |tmp_table_file|
    tmp_table = DependenciesTable.load(tmp_table_file)
    table.reverse_merge!(tmp_table)
  end
end
save_table_file() click to toggle source
# File lib/delta_test/cli/stats_save_command.rb, line 36
def save_table_file
  table.dump(stats.table_file_path)
end
stage_table_file() click to toggle source
# File lib/delta_test/cli/stats_save_command.rb, line 40
def stage_table_file
  status = true
  status &&= stats.stats_git.add(stats.table_file_path)
  status &&= stats.stats_git.commit(stats.base_commit)
  raise TableFileStageError unless status
end
stats() click to toggle source
# File lib/delta_test/cli/stats_save_command.rb, line 65
def stats
  @stats ||= Stats.new(head: true)
end
sync_table_file() click to toggle source
# File lib/delta_test/cli/stats_save_command.rb, line 47
def sync_table_file
  return unless stats.stats_git.has_remote?
  status = true
  status &&= stats.stats_git.pull
  status &&= stats.stats_git.push
  raise StatsRepositorySyncError unless status
end
table() click to toggle source
# File lib/delta_test/cli/stats_save_command.rb, line 61
def table
  @table ||= DependenciesTable.new
end
tmp_table_files() click to toggle source
# File lib/delta_test/cli/stats_save_command.rb, line 55
def tmp_table_files
  return @tmp_table_files if defined?(@tmp_table_files)
  tmp_table_files_pattern ||= DeltaTest.config.tmp_table_file.parent.join('*')
  @tmp_table_files = Dir.glob(tmp_table_files_pattern)
end