Sha256: eb0058fd191f1958c37cc4dafa1ba9fb66b8ce74688e06e405d9567eabc1eec1

Contents?: true

Size: 1.3 KB

Versions: 7

Compression:

Stored size: 1.3 KB

Contents

== String#indent

  require 'facets/string/indent'

positive

  "xyz".indent(4).assert == '    xyz'
  "  xyz".indent(2).assert == '    xyz'

multiline positive

  "abc\nxyz".indent(2).assert ==  "  abc\n  xyz"

zero

  'xyz'.indent(0).assert == 'xyz'

negative

  '    xyz'.indent(-2).assert == '  xyz'
  '  xyz'.  indent(-2).assert == 'xyz'

multiline negative

  "    abc\n    xyz".indent(-2).assert == "  abc\n  xyz"

negative more than is possible

  '  xyz'.indent(-3).assert == 'xyz'

non-space positive

  "xyz".indent(4, '-').assert == '----xyz'

non-space zero

  'xyz'.indent(0, '-').assert == 'xyz'

non-space negative non-matching character

  '    xyz'.indent(-2, '-').assert == '    xyz'
  '  xyz'.  indent(-2, '-').assert == '  xyz'

non-space negative

  '----xyz'.indent(-2, '-').assert == '--xyz'
  '--xyz'.indent(-2, '-').assert == 'xyz'

Special regular expresion characters are escaped.

ensure '.' is treated literally and not as wildcard

  '  xyz'.indent(-2, '.').assert == '  xyz'
  '..xyz'.indent(-2, '.').assert == 'xyz'

ensure '*' is treated literally and not as wildcard

  '  xyz'.indent(-2, '*').assert == '  xyz'
  '**xyz'.indent(-2, '*').assert == 'xyz'

ensure '^' is treated literally and not as line start

  '  xyz'.indent(-2, '^').assert == '  xyz'
  '^^xyz'.indent(-2, '^').assert == 'xyz'

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
facets-3.0.0 demo/core/string/indent.rdoc
facets-2.9.3 qed/core/string/indent.rdoc
facets-2.9.2 qed/core/string/indent.rdoc
facets-2.9.1 qed/core/string/indent.rdoc
facets-2.9.0 qed/core/string/indent.rdoc
facets-2.9.0.pre.2 qed/core/string/indent.rdoc
facets-2.9.0.pre.1 qed/core/string/indent.rdoc