Created
March 31, 2011 03:20
-
-
Save rubypanther/895764 to your computer and use it in GitHub Desktop.
remove extra indentation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
data = if file = ARGV.shift | |
File.open(file).read | |
else | |
<<DATA | |
command "simple-prompt", "Toggle the simple prompt." do | |
case Pry.active_instance.prompt | |
when Pry::SIMPLE_PROMPT | |
Pry.active_instance.prompt = Pry::DEFAULT_PROMPT | |
else | |
Pry.active_instance.prompt = Pry::SIMPLE_PROMPT | |
end | |
end | |
DATA | |
end | |
def unindent_region string | |
indent = string[/^\s+/].size | |
unindented = "" | |
string.each_line do |line| | |
unindented << line[indent..-1] | |
end | |
unindented | |
end | |
print unindent_region(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment