class Fastlane::Actions::PeripheryAction::Runner
Attributes
config[R]
executable[R]
index_store_path[R]
results[R]
skip_build[R]
Public Class Methods
new(params)
click to toggle source
# File lib/fastlane/plugin/periphery/actions/periphery_action.rb, line 38 def initialize(params) @executable = params[:executable] || 'periphery' @config = expand_and_verify_path(params[:config]) @skip_build = params[:skip_build] @index_store_path = expand_and_verify_path(params[:index_store_path]) @results = nil end
Public Instance Methods
expand_and_verify_path(path)
click to toggle source
# File lib/fastlane/plugin/periphery/actions/periphery_action.rb, line 29 def expand_and_verify_path(path) return nil if path.nil? path = File.expand_path(path) UI.user_error!("File or directory does not exist at path '#{path}'") unless File.exist?(path) path end
find_derived_data_path()
click to toggle source
# File lib/fastlane/plugin/periphery/actions/periphery_action.rb, line 112 def find_derived_data_path # These values are set by other actions that may have been used to build an app previously candidates = [ Actions.lane_context[SharedValues::SCAN_DERIVED_DATA_PATH], Actions.lane_context[SharedValues::XCODEBUILD_DERIVED_DATA_PATH] ] # Return the first candidate where the value was set and the directory still exists candidates.find { |x| !x.nil? && File.exist?(x) } end
perform_scan()
click to toggle source
# File lib/fastlane/plugin/periphery/actions/periphery_action.rb, line 60 def perform_scan # Run the periphery scan command and collect the output UI.message("Performing scan. This might take a few moments...") output = Actions.sh_control_output(scan_command, print_command_output: false, error_callback: lambda { |result| UI.error(result) UI.user_error!("The scan could not be completed successfully") }) # Decode the JSON output and assign to the property/lane_context @results = JSON.parse(output).map { |raw| Result.new(raw) } Actions.lane_context[SharedValues::PERIPHERY_RESULTS] = results end
print_summary()
click to toggle source
# File lib/fastlane/plugin/periphery/actions/periphery_action.rb, line 123 def print_summary # Group the results by their first hint (assume there is only one). grouped_results = results .group_by { |result| result.hints.first } .transform_values(&:count) # Print the counts in a table FastlaneCore::PrintTable.print_values(config: grouped_results, title: 'Summary of Results') unless Helper.test? end
resolve_index_store_path()
click to toggle source
# File lib/fastlane/plugin/periphery/actions/periphery_action.rb, line 100 def resolve_index_store_path # If it was explicitly specified, return the path to the index store return index_store_path unless index_store_path.nil? # Alternatively, use the derived data path defined by a prior action derived_data_path = find_derived_data_path return File.join(derived_data_path, 'Index', 'DataStore') unless derived_data_path.nil? # Fail if we couldn't automatically resolve the path UI.user_error!("The index store path could not be resolved. Either specify it using the index_store_path argument or provide a path to derived data when using build_app or xcodebuild actions.") end
run()
click to toggle source
# File lib/fastlane/plugin/periphery/actions/periphery_action.rb, line 46 def run verify_executable perform_scan print_summary results end
scan_command()
click to toggle source
# File lib/fastlane/plugin/periphery/actions/periphery_action.rb, line 73 def scan_command # Build up the initial part of the command command = [ executable, 'scan', '--disable-update-check', '--format', 'json' ] # Specify the path to the config if it was provided if config command << '--config' command << config end # Support --skip-build mode if skip_build || !index_store_path.nil? command << '--skip-build' command << '--index-store-path' command << resolve_index_store_path end # Return the complete array of arguments command end
verify_executable()
click to toggle source
# File lib/fastlane/plugin/periphery/actions/periphery_action.rb, line 53 def verify_executable version = Actions.sh_control_output([executable, 'version'], print_command_output: false).strip! UI.message("Using periphery version #{version}") rescue UI.user_error!("Unable to invoke periphery executable '#{executable}'. Is it installed?") end