Sha256: bbdf7f672aaa8cc16d6781ed1e44879ec22a3a6fb16868a8a2093f668ad4aa2f

Contents?: true

Size: 735 Bytes

Versions: 1

Compression:

Stored size: 735 Bytes

Contents

##
# This is for annotations which do not have any content, i.e. no enclosed
# text or other annotations. This is mostly relevant for stripping where
# this means that simply removing the annotation would leave an extra space.
#
# Prepending this module to processors for these kinds of annotations
# prevents that.
module NoContent
  def join_parts(prefix, text, suffix)
    leading_ws = /\A\s/
    trailing_ws = /\s\z/

    if text == ""
      if prefix =~ trailing_ws && suffix =~ leading_ws
        prefix.sub(trailing_ws, "") + suffix
      elsif prefix == ""
        suffix.sub(leading_ws, "")
      elsif suffix == ""
        prefix.sub(trailing_ws, "")
      else
        super
      end
    else
      super
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ssmd-0.7.6 lib/ssmd/processors/concerns/no_content.rb