Class: PuppetDebugger::InputResponders::Whereami
- Inherits:
-
PuppetDebugger::InputResponderPlugin
- Object
- PuppetDebugger::InputResponderPlugin
- PuppetDebugger::InputResponders::Whereami
- Defined in:
- lib/plugins/puppet-debugger/input_responders/whereami.rb
Constant Summary collapse
- COMMAND_WORDS =
%w(whereami)
- SUMMARY =
'Show code surrounding the current context.'
- COMMAND_GROUP =
:context
Instance Attribute Summary
Attributes inherited from PuppetDebugger::InputResponderPlugin
Instance Method Summary collapse
- #parse(num, default = 7) ⇒ Integer
-
#run(args = []) ⇒ String
source_file and source_line_num instance variables must be set for this method to show the surrounding code or line_num do not exist.
Methods inherited from PuppetDebugger::InputResponderPlugin
command_completion, command_group, command_words, details, execute, #modules_paths, #puppet_debugger_lib_dir, summary
Instance Method Details
#parse(num, default = 7) ⇒ Integer
32 33 34 35 |
# File 'lib/plugins/puppet-debugger/input_responders/whereami.rb', line 32 def parse(num, default = 7) value = num.to_i value >= 5 ? value : default end |
#run(args = []) ⇒ String
source_file and source_line_num instance variables must be set for this method to show the surrounding code or line_num do not exist
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/plugins/puppet-debugger/input_responders/whereami.rb', line 13 def run(args = []) num_lines = parse(args.first) file = debugger.source_file line_num = debugger.source_line_num if file && line_num if file == :code source_code = Puppet[:code] code = DebuggerCode.from_string(source_code, :puppet) else code = DebuggerCode.from_file(file, :puppet) end return code.with_marker(line_num).around(line_num, num_lines) .with_line_numbers.with_indentation(5).with_file_reference.to_s end end |