Class: Reviewer::Command::String
- Inherits:
-
Object
- Object
- Reviewer::Command::String
- Includes:
- Reviewer::Conversions
- Defined in:
- lib/reviewer/command/string.rb,
lib/reviewer/command/string/env.rb,
lib/reviewer/command/string/flags.rb more...
Overview
Assembles tool tool_settings into a usable command string for the command type
Defined Under Namespace
Instance Attribute Summary collapse
-
#command_type ⇒ Object
readonly
Returns the value of attribute command_type.
-
#tool_settings ⇒ Object
readonly
Returns the value of attribute tool_settings.
Instance Method Summary collapse
- #body ⇒ Object
-
#env_variables ⇒ String
The string of environment variables built from a tool’s configuration settings.
-
#flags ⇒ String
Gets the flags to be used in conjunction with the review command for a tool 1.
-
#initialize(command_type, tool_settings:) ⇒ String
constructor
A new instance of String.
- #to_a ⇒ Object
- #to_s ⇒ Object
Methods included from Reviewer::Conversions
Constructor Details
permalink #initialize(command_type, tool_settings:) ⇒ String
Returns a new instance of String.
14 15 16 17 |
# File 'lib/reviewer/command/string.rb', line 14 def initialize(command_type, tool_settings:) @command_type = command_type @tool_settings = tool_settings end |
Instance Attribute Details
permalink #command_type ⇒ Object (readonly)
Returns the value of attribute command_type.
12 13 14 |
# File 'lib/reviewer/command/string.rb', line 12 def command_type @command_type end |
permalink #tool_settings ⇒ Object (readonly)
Returns the value of attribute tool_settings.
12 13 14 |
# File 'lib/reviewer/command/string.rb', line 12 def tool_settings @tool_settings end |
Instance Method Details
permalink #body ⇒ Object
[View source]
41 42 43 |
# File 'lib/reviewer/command/string.rb', line 41 def body tool_settings.commands.fetch(command_type) end |
permalink #env_variables ⇒ String
The string of environment variables built from a tool’s configuration settings
37 38 39 |
# File 'lib/reviewer/command/string.rb', line 37 def env_variables Env.new(tool_settings.env).to_s end |
permalink #flags ⇒ String
Gets the flags to be used in conjunction with the review command for a tool
1. The `review` commands are the only commands that use flags
2. If no flags are configured, this won't do anything
50 51 52 53 54 |
# File 'lib/reviewer/command/string.rb', line 50 def flags return nil unless flags? Flags.new(tool_settings.flags).to_s end |
permalink #to_a ⇒ Object
[View source]
26 27 28 29 30 31 32 |
# File 'lib/reviewer/command/string.rb', line 26 def to_a [ env_variables, body, flags ].compact end |
permalink #to_s ⇒ Object
[View source]
19 20 21 22 23 24 |
# File 'lib/reviewer/command/string.rb', line 19 def to_s to_a .map(&:strip) # Remove extra spaces on the components .join(' ') # Merge the components .strip # Strip extra spaces from the end result end |