Class: Foobara::CommandConnectors::ShCliConnector::Request
- Inherits:
-
Foobara::CommandConnector::Request
- Object
- Foobara::CommandConnector::Request
- Foobara::CommandConnectors::ShCliConnector::Request
- Defined in:
- foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb
Constant Summary
Constants included from TruncatedInspect
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#action_options ⇒ Object
Returns the value of attribute action_options.
-
#argument ⇒ Object
Returns the value of attribute argument.
-
#argv ⇒ Object
Returns the value of attribute argv.
-
#command ⇒ Object
Returns the value of attribute command.
-
#exit ⇒ Object
Returns the value of attribute exit.
-
#globalish_options ⇒ Object
Returns the value of attribute globalish_options.
-
#inputs_argv ⇒ Object
Returns the value of attribute inputs_argv.
-
#single_command_mode ⇒ Object
Returns the value of attribute single_command_mode.
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdin ⇒ Object
Returns the value of attribute stdin.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
Attributes inherited from Foobara::CommandConnector::Request
#authenticated_credential, #authenticated_user, #command_class, #command_connector, #error, #response, #serializers
Instance Method Summary collapse
- #action_parser ⇒ Object
-
#full_command_name ⇒ Object
TODO: we might not have the full command name here…
- #globalish_parser ⇒ Object
-
#initialize(argv, command:, exit: true, stdout: $stdout, stderr: $stderr, stdin: $stdin) ⇒ Request
constructor
A new instance of Request.
- #input_serializer ⇒ Object
- #inputs ⇒ Object
- #inputs_parser ⇒ Object
- #inputs_parser_for(command_class = self.command_class) ⇒ Object
- #single_command_mode? ⇒ Boolean
Methods inherited from Foobara::CommandConnector::Request
#authenticate, #authenticator, #error_collection, #mutate_request, #outcome, #relevant_entity_classes, #response_body, #result, #serializer, #success?
Methods included from NestedTransactionable
#auto_detect_current_transactions, #commit_transaction, #commit_transaction_if_open, #open_transaction, #opened_transactions, #relevant_entity_classes, relevant_entity_classes_for_type, #relevant_entity_classes_for_type, #rollback_transaction, #transactions, #use_transaction, with_needed_transactions_for_type
Methods included from Foobara::Concern
foobara_class_methods_module_for, foobara_concern?, included
Methods included from TruncatedInspect
Constructor Details
#initialize(argv, command:, exit: true, stdout: $stdout, stderr: $stderr, stdin: $stdin) ⇒ Request
Returns a new instance of Request.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 22 def initialize(argv, command:, exit: true, stdout: $stdout, stderr: $stderr, stdin: $stdin) self.command = command self.argv = argv self.exit = exit self.stdin = stdin self.stdout = stdout self.stderr = stderr begin parse! rescue ParseError => e self.error = e end super() end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
9 10 11 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 9 def action @action end |
#action_options ⇒ Object
Returns the value of attribute action_options.
9 10 11 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 9 def @action_options end |
#argument ⇒ Object
Returns the value of attribute argument.
9 10 11 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 9 def argument @argument end |
#argv ⇒ Object
Returns the value of attribute argv.
9 10 11 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 9 def argv @argv end |
#command ⇒ Object
Returns the value of attribute command.
9 10 11 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 9 def command @command end |
#exit ⇒ Object
Returns the value of attribute exit.
9 10 11 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 9 def exit @exit end |
#globalish_options ⇒ Object
Returns the value of attribute globalish_options.
9 10 11 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 9 def @globalish_options end |
#inputs_argv ⇒ Object
Returns the value of attribute inputs_argv.
9 10 11 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 9 def inputs_argv @inputs_argv end |
#single_command_mode ⇒ Object
Returns the value of attribute single_command_mode.
9 10 11 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 9 def single_command_mode @single_command_mode end |
#stderr ⇒ Object
Returns the value of attribute stderr.
9 10 11 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 9 def stderr @stderr end |
#stdin ⇒ Object
Returns the value of attribute stdin.
9 10 11 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 9 def stdin @stdin end |
#stdout ⇒ Object
Returns the value of attribute stdout.
9 10 11 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 9 def stdout @stdout end |
Instance Method Details
#action_parser ⇒ Object
91 92 93 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 91 def action_parser @action_parser ||= ActionParser.new end |
#full_command_name ⇒ Object
TODO: we might not have the full command name here… that should be fine. TODO: rename this.
66 67 68 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 66 def full_command_name argument end |
#globalish_parser ⇒ Object
87 88 89 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 87 def globalish_parser @globalish_parser ||= GlobalishParser.new end |
#input_serializer ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 43 def input_serializer @input_serializer ||= begin input_format = [:input_format] serializer_class = if input_format.nil? # TODO: refactor this to some default setting Foobara::CommandConnectors::Serializers::YamlSerializer else Serializer.serializer_from_symbol(input_format) end unless serializer_class # :nocov: raise ParseError.new(message: "Unknown input format: #{input_format}") # :nocov: end serializer_class.new(nil) end end |
#inputs ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 70 def inputs @inputs ||= if [:stdin] input_serializer.deserialize(stdin.read) else result = inputs_parser.parse(inputs_argv) result.parsed end end |
#inputs_parser ⇒ Object
79 80 81 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 79 def inputs_parser @inputs_parser ||= inputs_parser_for end |
#inputs_parser_for(command_class = self.command_class) ⇒ Object
83 84 85 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 83 def inputs_parser_for(command_class = self.command_class) InputsParser.new(command_class.inputs_type, always_prefix_inputs: command_connector.always_prefix_inputs) end |
#single_command_mode? ⇒ Boolean
39 40 41 |
# File 'foobara-sh-cli-connector-0.0.17/src/sh_cli_connector/request.rb', line 39 def single_command_mode? !!command end |