Class: Cyrun::ResultDirectory

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(temp_directory, screenshots_pattern, spec_tasks) ⇒ ResultDirectory

Returns a new instance of ResultDirectory.



9
10
11
12
13
# File 'lib/cyrun/result_directory.rb', line 9

def initialize(temp_directory, screenshots_pattern, spec_tasks)
  @temp_directory = temp_directory
  @spec_tasks = spec_tasks
  @screenshots_pattern = screenshots_pattern
end

Instance Attribute Details

#screenshots_patternObject (readonly)

Returns the value of attribute screenshots_pattern.



7
8
9
# File 'lib/cyrun/result_directory.rb', line 7

def screenshots_pattern
  @screenshots_pattern
end

#spec_tasksObject (readonly)

Returns the value of attribute spec_tasks.



7
8
9
# File 'lib/cyrun/result_directory.rb', line 7

def spec_tasks
  @spec_tasks
end

#temp_directoryObject (readonly)

Returns the value of attribute temp_directory.



7
8
9
# File 'lib/cyrun/result_directory.rb', line 7

def temp_directory
  @temp_directory
end

Instance Method Details

#read_result_filesObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cyrun/result_directory.rb', line 15

def read_result_files
  absolute_filenames = Dir
                       .glob('results-*.xml', base: temp_directory)
                       .map { |filename| File.expand_path(filename, temp_directory) }

  results = absolute_filenames
            .map { |filename| read_result_file filename }
            .reject(&:nil?)

  spec_tasks.map do |task|
    find_result_for_task(results, task) || create_failed_spec_result(task)
  end
end

#screenshotsObject



29
30
31
32
33
# File 'lib/cyrun/result_directory.rb', line 29

def screenshots
  Dir
    .glob(screenshots_pattern, base: Dir.pwd)
    .map { |filename| File.expand_path(filename, Dir.pwd) }
end