Class: Fastlane::SocketServerActionCommandExecutor
- Inherits:
-
CommandExecutor
- Object
- CommandExecutor
- Fastlane::SocketServerActionCommandExecutor
- Defined in:
- fastlane/lib/fastlane/server/socket_server_action_command_executor.rb
Overview
Handles receiving commands from the socket server, finding the Action to be invoked, invoking it, and returning any return values
Instance Attribute Summary collapse
-
#actions_requiring_special_handling ⇒ Object
Returns the value of attribute actions_requiring_special_handling.
-
#runner ⇒ Object
Returns the value of attribute runner.
Instance Method Summary collapse
- #class_ref_for_action(named: nil) ⇒ Object
- #execute(command: nil, target_object: nil) ⇒ Object
-
#initialize ⇒ SocketServerActionCommandExecutor
constructor
A new instance of SocketServerActionCommandExecutor.
- #run(action_named: nil, action_class_ref: nil, parameter_map: nil) ⇒ Object
-
#run_action_requiring_special_handling(command: nil, parameter_map: nil, action_return_type: nil) ⇒ Object
Some actions have special handling in fast_file.rb, that means we can’t directly call the action but we have to use the same logic that is in fast_file.rb instead.
Constructor Details
#initialize ⇒ SocketServerActionCommandExecutor
Returns a new instance of SocketServerActionCommandExecutor.
12 13 14 15 16 |
# File 'fastlane/lib/fastlane/server/socket_server_action_command_executor.rb', line 12 def initialize Fastlane.load_actions @runner = Runner.new @actions_requiring_special_handling = ["sh"].to_set end |
Instance Attribute Details
#actions_requiring_special_handling ⇒ Object
Returns the value of attribute actions_requiring_special_handling.
10 11 12 |
# File 'fastlane/lib/fastlane/server/socket_server_action_command_executor.rb', line 10 def actions_requiring_special_handling @actions_requiring_special_handling end |
#runner ⇒ Object
Returns the value of attribute runner.
9 10 11 |
# File 'fastlane/lib/fastlane/server/socket_server_action_command_executor.rb', line 9 def runner @runner end |
Instance Method Details
#class_ref_for_action(named: nil) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'fastlane/lib/fastlane/server/socket_server_action_command_executor.rb', line 56 def class_ref_for_action(named: nil) class_ref = Actions.action_class_ref(named) unless class_ref if Fastlane::Actions.formerly_bundled_actions.include?(action) # This was a formerly bundled action which is now a plugin. UI.verbose(caller.join("\n")) UI.user_error!("The action '#{action}' is no longer bundled with fastlane. You can install it using `fastlane add_plugin #{action}`") else Fastlane::ActionsList.print_suggestions(action) UI.user_error!("Action '#{action}' not available, run `fastlane actions` to get a full list") end end return class_ref end |
#execute(command: nil, target_object: nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'fastlane/lib/fastlane/server/socket_server_action_command_executor.rb', line 18 def execute(command: nil, target_object: nil) action_name = command.method_name action_class_ref = class_ref_for_action(named: action_name) parameter_map = {} closure_argument_value = nil command.args.each do |arg| arg_value = arg.value if arg.value_type.to_s.to_sym == :string_closure closure = proc { |string_value| closure_argument_value = string_value } arg_value = closure end parameter_map[arg.name.to_sym] = arg_value end if @actions_requiring_special_handling.include?(action_name) command_return = run_action_requiring_special_handling( command: command, parameter_map: parameter_map, action_return_type: action_class_ref.return_type ) return command_return end action_return = run( action_named: action_name, action_class_ref: action_class_ref, parameter_map: parameter_map ) command_return = ActionCommandReturn.new( return_value: action_return, return_value_type: action_class_ref.return_type, closure_argument_value: closure_argument_value ) return command_return end |
#run(action_named: nil, action_class_ref: nil, parameter_map: nil) ⇒ Object
72 73 74 75 |
# File 'fastlane/lib/fastlane/server/socket_server_action_command_executor.rb', line 72 def run(action_named: nil, action_class_ref: nil, parameter_map: nil) action_return = runner.execute_action(action_named, action_class_ref, [parameter_map], custom_dir: '.') return action_return end |
#run_action_requiring_special_handling(command: nil, parameter_map: nil, action_return_type: nil) ⇒ Object
Some actions have special handling in fast_file.rb, that means we can’t directly call the action but we have to use the same logic that is in fast_file.rb instead. That’s where this switch statement comes into play
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'fastlane/lib/fastlane/server/socket_server_action_command_executor.rb', line 80 def run_action_requiring_special_handling(command: nil, parameter_map: nil, action_return_type: nil) action_return = nil closure_argument_value = nil # only used if the action uses it case command.method_name when "sh" error_callback = proc { |string_value| closure_argument_value = string_value } command_param = parameter_map[:command] log_param = parameter_map[:log] action_return = Fastlane::FastFile.sh(command_param, log: log_param, error_callback: error_callback) end command_return = ActionCommandReturn.new( return_value: action_return, return_value_type: action_return_type, closure_argument_value: closure_argument_value ) return command_return end |