Class: TestResultLogging

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTestResultLogging

Returns a new instance of TestResultLogging.



10
11
12
# File 'lib/test_result_logging.rb', line 10

def initialize
  self.current_run_name   = Time.now.strftime("%Y-%m-%dT%H:%M:%S")
end

Instance Attribute Details

#current_run_nameObject

Used for generating filenames for where we should store the results of the current test run (new_file)



8
9
10
# File 'lib/test_result_logging.rb', line 8

def current_run_name
  @current_run_name
end

Class Method Details

.latest_default_file_for_format(format) ⇒ Object



24
25
26
27
# File 'lib/test_result_logging.rb', line 24

def self.latest_default_file_for_format(format)
  ext = formats_to_extensions[format]
  results_dir + ("default.#{ext}")
end


29
30
31
32
# File 'lib/test_result_logging.rb', line 29

def self.latest_symlink_for_format(format)
  ext = formats_to_extensions[format]
  results_dir + ("latest.#{user}.#{ext}")
end

.results_dirObject



19
20
21
# File 'lib/test_result_logging.rb', line 19

def self.results_dir
  Pathname(_results_dir).tap {|_| _.mkpath unless _.exist? }
end

.userObject



14
15
16
# File 'lib/test_result_logging.rb', line 14

def self.user
  ENV['USER']
end

Instance Method Details

#each_format_to_current_filesObject



39
40
41
42
43
44
45
46
47
# File 'lib/test_result_logging.rb', line 39

def each_format_to_current_files
  formats_to_extensions.each do |format, ext|
    yield [
      format,
      self.class.latest_symlink_for_format(format),
      new_file_for_format(format)
    ]
  end
end

#new_file_for_format(format) ⇒ Object



34
35
36
37
# File 'lib/test_result_logging.rb', line 34

def new_file_for_format(format)
  ext = formats_to_extensions[format]
  results_dir + ("#{current_run_name}.#{user}.#{ext}")
end

#results_dirObject



22
# File 'lib/test_result_logging.rb', line 22

def results_dir; self.class.results_dir; end


49
50
51
52
53
54
# File 'lib/test_result_logging.rb', line 49

def update_latest_symlinks
  each_format_to_current_files do |format, latest_symlink, new_file|
    puts "Updating #{latest_symlink} to point to #{new_file.basename}..."
    latest_symlink.tap {|_| _.unlink rescue nil }.make_symlink new_file.basename
  end
end

#userObject



17
# File 'lib/test_result_logging.rb', line 17

def user; self.class.user; end