class PuppetDebugger::InputResponders::Whereami
Constants
- COMMAND_GROUP
- COMMAND_WORDS
- SUMMARY
Public Instance Methods
parse(num, default = 7)
click to toggle source
@return [Integer] @param num [String,Integer] number of lines @param defalt [Integer] - default value to return if supplied is less than 5
# File lib/plugins/puppet-debugger/input_responders/whereami.rb, line 34 def parse(num, default = 7) value = num.to_i value >= 5 ? value : default end
run(args = [])
click to toggle source
source_file and source_line_num instance variables must be set for this method to show the surrounding code @return [String] - string output of the code surrounded by the breakpoint or nil if file or line_num do not exist
# File lib/plugins/puppet-debugger/input_responders/whereami.rb, line 15 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 code.with_marker(line_num).around(line_num, num_lines) .with_line_numbers.with_indentation(5).with_file_reference.to_s end end