free_mutant/spec/support/compress_helper.rb

10 lines
275 B
Ruby
Raw Normal View History

2012-08-16 12:02:03 -04:00
module CompressHelper
def strip_indent(string)
lines = string.lines
match = /\A( *)/.match(lines.first)
2014-08-11 10:29:32 -04:00
return string unless match
2012-08-16 12:02:03 -04:00
whitespaces = match[1].to_s.length
lines.map { |line| line[whitespaces..-1] }.join
2012-08-16 12:02:03 -04:00
end
2016-04-10 17:33:47 -04:00
end # CompressHelper