-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module XCResult | ||
class ExportOptions | ||
AVAILABLE_OPTIONS = %i[destination by_device by_locale].freeze | ||
|
||
def initialize(**options) | ||
options = options.dup | ||
raise ':destination option is required' unless options[:destination] | ||
options.each do |key, value| | ||
raise "Found unknown option #{key} - #{value}." unless AVAILABLE_OPTIONS.include?(key) | ||
end | ||
|
||
@destination = options.delete(:destination) | ||
end | ||
|
||
def output_directory(target_device_record:, action_testable_summary:) | ||
output_directory = @destination | ||
|
||
# keep the order of given options so that you can customize output directory path based on your needs | ||
options.each do |key, value| | ||
if key == :by_device && value == true | ||
output_directory = File.join(output_directory, target_device_record.model_name) | ||
elsif key == :by_locale && value == true | ||
locale = [action_testable_summary.test_language, action_testable_summary.test_region].compact.join('_') | ||
locale = 'UNKOWN' if locale.empty? | ||
output_directory = File.join(output_directory, locale) | ||
end | ||
end | ||
|
||
output_directory | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters