Class: Inspec::EnvPrinter::TemplateContext
- Inherits:
-
Object
- Object
- Inspec::EnvPrinter::TemplateContext
- Defined in:
- lib/inspec/env_printer.rb
Instance Method Summary collapse
- #commands_for_thor_class(thor_class) ⇒ Object
- #descript_line_for_command(c) ⇒ Object
- #descript_lines_for_class(thor_class) ⇒ Object
-
#get_bindings ⇒ Object
rubocop:disable Naming/AccessorMethodName.
-
#initialize(command_class) ⇒ TemplateContext
constructor
A new instance of TemplateContext.
- #subcommands_with_commands ⇒ Object
- #subcommands_with_commands_and_descriptions ⇒ Object
-
#top_level_commands ⇒ Object
The following functions all assume that @command_class is something that provides a Thor-like API.
- #top_level_commands_with_descriptions ⇒ Object
Constructor Details
#initialize(command_class) ⇒ TemplateContext
Returns a new instance of TemplateContext.
107 108 109 |
# File 'lib/inspec/env_printer.rb', line 107 def initialize(command_class) @command_class = command_class end |
Instance Method Details
#commands_for_thor_class(thor_class) ⇒ Object
143 144 145 |
# File 'lib/inspec/env_printer.rb', line 143 def commands_for_thor_class(thor_class) thor_class.all_commands.values.map { |c| c.usage.split.first } end |
#descript_line_for_command(c) ⇒ Object
151 152 153 |
# File 'lib/inspec/env_printer.rb', line 151 def descript_line_for_command(c) "#{c.usage.split.first}:#{Shellwords.escape(c.description)}" end |
#descript_lines_for_class(thor_class) ⇒ Object
147 148 149 |
# File 'lib/inspec/env_printer.rb', line 147 def descript_lines_for_class(thor_class) thor_class.all_commands.values.map { |c| descript_line_for_command(c) } end |
#get_bindings ⇒ Object
rubocop:disable Naming/AccessorMethodName
111 112 113 |
# File 'lib/inspec/env_printer.rb', line 111 def get_bindings # rubocop:disable Naming/AccessorMethodName binding end |
#subcommands_with_commands ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/inspec/env_printer.rb', line 127 def subcommands_with_commands ret = {} @command_class.subcommand_classes.each do |k, v| ret[k] = commands_for_thor_class(v) end ret end |
#subcommands_with_commands_and_descriptions ⇒ Object
135 136 137 138 139 140 141 |
# File 'lib/inspec/env_printer.rb', line 135 def subcommands_with_commands_and_descriptions ret = {} @command_class.subcommand_classes.each do |k, v| ret[k] = descript_lines_for_class(v) end ret end |
#top_level_commands ⇒ Object
The following functions all assume that @command_class is something that provides a Thor-like API
119 120 121 |
# File 'lib/inspec/env_printer.rb', line 119 def top_level_commands commands_for_thor_class(@command_class) end |
#top_level_commands_with_descriptions ⇒ Object
123 124 125 |
# File 'lib/inspec/env_printer.rb', line 123 def top_level_commands_with_descriptions descript_lines_for_class(@command_class) end |