Class: TestResultLogging
- Inherits:
-
Object
show all
- Defined in:
- lib/test_result_logging.rb
Instance Attribute Summary collapse
-
#current_run_name ⇒ Object
Used for generating filenames for where we should store the results of the current test run (new_file).
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
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_name ⇒ Object
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
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_dir ⇒ Object
19
20
21
|
# File 'lib/test_result_logging.rb', line 19
def self.results_dir
Pathname(_results_dir).tap {|_| _.mkpath unless _.exist? }
end
|
.user ⇒ Object
14
15
16
|
# File 'lib/test_result_logging.rb', line 14
def self.user
ENV['USER']
end
|
Instance Method Details
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
|
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_dir ⇒ Object
22
|
# File 'lib/test_result_logging.rb', line 22
def results_dir; self.class.results_dir; end
|
#update_latest_symlinks ⇒ Object
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
|
#user ⇒ Object
17
|
# File 'lib/test_result_logging.rb', line 17
def user; self.class.user; end
|