Class: XCResult::Parser
- Inherits:
-
Object
- Object
- XCResult::Parser
- Defined in:
- lib/xcresult/parser.rb
Instance Attribute Summary collapse
-
#actions_invocation_record ⇒ Object
Returns the value of attribute actions_invocation_record.
-
#path ⇒ Object
Returns the value of attribute path.
-
#result_bundle_json ⇒ Object
Returns the value of attribute result_bundle_json.
Instance Method Summary collapse
- #action_test_plan_summaries ⇒ Object
- #export_xccovarchives(destination: nil) ⇒ Object
- #export_xccovreports(destination: nil) ⇒ Object
-
#initialize(path: nil) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(path: nil) ⇒ Parser
Returns a new instance of Parser.
10 11 12 13 14 15 16 17 |
# File 'lib/xcresult/parser.rb', line 10 def initialize(path: nil) @path = Shellwords.escape(path) result_bundle_json_raw = get_result_bundle_json @result_bundle_json = JSON.parse(result_bundle_json_raw) @actions_invocation_record = XCResult::ActionsInvocationRecord.new(@result_bundle_json) end |
Instance Attribute Details
#actions_invocation_record ⇒ Object
Returns the value of attribute actions_invocation_record.
8 9 10 |
# File 'lib/xcresult/parser.rb', line 8 def actions_invocation_record @actions_invocation_record end |
#path ⇒ Object
Returns the value of attribute path.
8 9 10 |
# File 'lib/xcresult/parser.rb', line 8 def path @path end |
#result_bundle_json ⇒ Object
Returns the value of attribute result_bundle_json.
8 9 10 |
# File 'lib/xcresult/parser.rb', line 8 def result_bundle_json @result_bundle_json end |
Instance Method Details
#action_test_plan_summaries ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/xcresult/parser.rb', line 19 def action_test_plan_summaries return @action_test_plan_summaries if @action_test_plan_summaries # Parses JSON into ActionsInvocationRecord to find a list of all ids for ActionTestPlanRunSummaries test_refs = actions_invocation_record.actions.map do |action| action.action_result.tests_ref end.compact ids = test_refs.map(&:id) # Maps ids into ActionTestPlanRunSummaries by executing xcresulttool to get JSON # containing specific information for each test summary @action_test_plan_summaries = ids.map do |id| raw = execute_cmd(xcresulttool_command("get", "--format json --path #{path} --id #{id}")) json = JSON.parse(raw) XCResult::ActionTestPlanRunSummaries.new(json) end @action_test_plan_summaries end |
#export_xccovarchives(destination: nil) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/xcresult/parser.rb', line 58 def export_xccovarchives(destination: nil) destination ||= Dir.pwd # Collects archive references archive_refs = actions_invocation_record.actions.map do |action| action.action_result.coverage.archive_ref end.compact ids = archive_refs.map(&:id) # Exports all xcovarchive directories from the archive references ids.each_with_index.map do |id, i| output_path = File.join(destination, "action_#{i}.xccovarchive") cmd = xcresulttool_command("export", "--path #{path} --id '#{id}' --output-path #{output_path} --type directory") execute_cmd(cmd) output_path end end |
#export_xccovreports(destination: nil) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/xcresult/parser.rb', line 39 def export_xccovreports(destination: nil) destination ||= Dir.pwd # Collects report references report_refs = actions_invocation_record.actions.map do |action| action.action_result.coverage.report_ref end.compact ids = report_refs.map(&:id) # Exports all xccovreport files from the report references ids.each_with_index.map do |id, i| output_path = File.join(destination, "action_#{i}.xccovreport") cmd = xcresulttool_command("export", "--path #{path} --id '#{id}' --output-path #{output_path} --type file") execute_cmd(cmd) output_path end end |