Skip to content

Instantly share code, notes, and snippets.

@rubypanther
Created March 31, 2011 03:20
Show Gist options
  • Save rubypanther/895764 to your computer and use it in GitHub Desktop.
Save rubypanther/895764 to your computer and use it in GitHub Desktop.
remove extra indentation
#!/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