Sha256: a68216b0e396bcebafbc88d5d25631245bb216571f592726195d3837dd8c4409

Contents?: true

Size: 334 Bytes

Versions: 9

Compression:

Stored size: 334 Bytes

Contents

module Runbook::Helpers
  module FormatHelper
    def deindent(str, padding: 0)
      lines = str.split("\n")
      indentations = lines.map { |l| l.size - l.gsub(/^\s+/, "").size }
      min_indentation = indentations.min
      lines.map! { |line| " " * padding + line[min_indentation..-1] }
      lines.join("\n")
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
careacademy-runbook-1.2.0 lib/runbook/helpers/format_helper.rb
runbook-1.1.0 lib/runbook/helpers/format_helper.rb
runbook-1.0.0 lib/runbook/helpers/format_helper.rb
runbook-0.16.1 lib/runbook/helpers/format_helper.rb
runbook-0.16.0 lib/runbook/helpers/format_helper.rb
runbook-0.15.0 lib/runbook/helpers/format_helper.rb
runbook-0.14.0 lib/runbook/helpers/format_helper.rb
runbook-0.13.0 lib/runbook/helpers/format_helper.rb
runbook-0.12.1 lib/runbook/helpers/format_helper.rb