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.16/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
#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
#error_collection, #outcome, #response_body, #result, #serializer, #success?
Methods included from TruncatedInspect
Constructor Details
#initialize(argv, command:, exit: true, stdout: $stdout, stderr: $stderr, stdin: $stdin) ⇒ Request
Returns a new instance of Request.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 20 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.
7 8 9 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 7 def action @action end |
#action_options ⇒ Object
Returns the value of attribute action_options.
7 8 9 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 7 def @action_options end |
#argument ⇒ Object
Returns the value of attribute argument.
7 8 9 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 7 def argument @argument end |
#argv ⇒ Object
Returns the value of attribute argv.
7 8 9 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 7 def argv @argv end |
#command ⇒ Object
Returns the value of attribute command.
7 8 9 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 7 def command @command end |
#exit ⇒ Object
Returns the value of attribute exit.
7 8 9 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 7 def exit @exit end |
#globalish_options ⇒ Object
Returns the value of attribute globalish_options.
7 8 9 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 7 def @globalish_options end |
#inputs_argv ⇒ Object
Returns the value of attribute inputs_argv.
7 8 9 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 7 def inputs_argv @inputs_argv end |
#single_command_mode ⇒ Object
Returns the value of attribute single_command_mode.
7 8 9 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 7 def single_command_mode @single_command_mode end |
#stderr ⇒ Object
Returns the value of attribute stderr.
7 8 9 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 7 def stderr @stderr end |
#stdin ⇒ Object
Returns the value of attribute stdin.
7 8 9 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 7 def stdin @stdin end |
#stdout ⇒ Object
Returns the value of attribute stdout.
7 8 9 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 7 def stdout @stdout end |
Instance Method Details
#action_parser ⇒ Object
89 90 91 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 89 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.
64 65 66 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 64 def full_command_name argument end |
#globalish_parser ⇒ Object
85 86 87 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 85 def globalish_parser @globalish_parser ||= GlobalishParser.new end |
#input_serializer ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 41 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, "Unknown input format: #{input_format}" # :nocov: end serializer_class.new(nil) end end |
#inputs ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 68 def inputs @inputs ||= if [:stdin] input_serializer.deserialize(stdin.read) else result = inputs_parser.parse(inputs_argv) result.parsed end end |
#inputs_parser ⇒ Object
77 78 79 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 77 def inputs_parser @inputs_parser ||= inputs_parser_for end |
#inputs_parser_for(command_class = self.command_class) ⇒ Object
81 82 83 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 81 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
37 38 39 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/request.rb', line 37 def single_command_mode? !!command end |