module EnvSetting::Formatter

Public Class Methods

formatted_error(var, description) click to toggle source
# File lib/env_setting/formatter.rb, line 3
    def self.formatted_error(var, description)
      indent 4, <<-EOS

  Missing required environment variable: #{var}#{ description and "\n" <<
  unindent(description) }
      EOS
    end
indent(width, string) click to toggle source
# File lib/env_setting/formatter.rb, line 16
def self.indent(width, string)
  string.gsub "\n", "\n#{' ' * width}"
end
unindent(string) click to toggle source
# File lib/env_setting/formatter.rb, line 11
def self.unindent(string)
  width = string.scan(/^ */).map(&:length).min
  string.gsub(/^ {#{width}}/, '')
end