44require 'json'
55require 'fileutils'
66
7+ require_relative 'export_options'
8+
79module XCResult
810 class Parser
911 attr_accessor :path , :result_bundle_json , :actions_invocation_record
@@ -69,7 +71,7 @@ def export_xccovarchives(destination: nil)
6971 end
7072 end
7173
72- def export_screenshots ( destination : Dir . pwd , by_device : false , by_locale : false )
74+ def export_screenshots ( options = XCResult :: ExportOptions . new ( destination : Dir . pwd ) )
7375 # Filter non test results; i.e build action
7476 actions = actions_invocation_record . actions . select { |x | x . action_result . tests_ref }
7577
@@ -89,11 +91,10 @@ def export_screenshots(destination: Dir.pwd, by_device: false, by_locale: false)
8991 . flat_map ( &:attachments )
9092
9193 # Prepare output directory for each tests
92- locale = [ action_testable_summary . test_language , action_testable_summary . test_region ] . compact . join ( '_' )
93- locale = 'UNKOWN' if locale . empty?
94- output_directory = destination
95- output_directory = File . join ( output_directory , action . run_destination . target_device_record . model_name ) if by_device
96- output_directory = File . join ( output_directory , locale ) if by_locale
94+ output_directory = options . output_directory (
95+ target_device_record : action . run_destination . target_device_record ,
96+ action_testable_summary : action_testable_summary
97+ )
9798 FileUtils . mkdir_p ( output_directory ) unless Dir . exist? ( output_directory )
9899
99100 # Finally exports attachments
0 commit comments