Module: PGit::Helpers::Heredoc
- Defined in:
- lib/pgit/helpers/heredoc.rb
Class Method Summary collapse
Class Method Details
.remove_front_spaces(string) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/pgit/helpers/heredoc.rb', line 4 def self.remove_front_spaces(string) space_lengths = string.split("\n").select do |s| s.match(/\S/) end.map {|s| s.scan(/^\s*/).first.length } min_length = space_lengths.inject(100) do |accum, value| accum > value ? value : accum end string.gsub!(/^\s{#{min_length}}/, '') end |