Module | Pry::Helpers::CommandHelpers |
In: |
lib/pry/helpers/command_helpers.rb
|
Some editors that run outside the terminal allow you to control whether or not to block the process from which they were launched (in this case, Pry). For those editors, return the flag that produces the desired behavior.
Get the name of the binary that Pry.config.editor points to.
This is useful for deciding which flags we pass to the editor as we can just use the program‘s name and ignore any absolute paths.
@example
Pry.config.editor="/home/conrad/bin/textmate -w" editor_name # => textmate
Return the file and line for a Binding. @param [Binding] target The binding @return [Array] The file and line
Restrict a string to the given range of lines (1-indexed) @param [String] content The string. @param [Range, Fixnum] lines The line(s) to restrict it to. @return [String] The resulting string.
Return the syntax for a given editor for starting the editor and moving to a particular line within that file
Open a temp file and yield it to the block, closing it after @return [String] The path of the temp file
Remove any common leading whitespace from every line in `text`.
This can be used to make a HEREDOC line up with the left margin, without sacrificing the indentation level of the source code.
e.g.
opt.banner unindent <<-USAGE Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "Ut enim ad minim veniam." USAGE
Heavily based on textwrap.dedent from Python, which is:
Copyright (C) 1999-2001 Gregory P. Ward. Copyright (C) 2002, 2003 Python Software Foundation. Written by Greg Ward <gward@python.net> Licensed under <http://docs.python.org/license.html> From <http://hg.python.org/cpython/file/6b9f0a6efaeb/Lib/textwrap.py>
@param [String] text The text from which to remove indentation @return [String] The text with indentation stripped.