Froze rails gems
[depot.git] / vendor / rails / actionmailer / lib / action_mailer / vendor / text-format-0.6.3 / text / format.rb
diff --git a/vendor/rails/actionmailer/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb b/vendor/rails/actionmailer/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb
new file mode 100755 (executable)
index 0000000..de054db
--- /dev/null
@@ -0,0 +1,1466 @@
+#--\r
+# Text::Format for Ruby\r
+# Version 0.63\r
+#\r
+# Copyright (c) 2002 - 2003 Austin Ziegler\r
+#\r
+# $Id: format.rb,v 1.1.1.1 2004/10/14 11:59:57 webster132 Exp $\r
+#\r
+# ==========================================================================\r
+# Revision History ::\r
+# YYYY.MM.DD  Change ID   Developer\r
+#             Description\r
+# --------------------------------------------------------------------------\r
+# 2002.10.18              Austin Ziegler\r
+#             Fixed a minor problem with tabs not being counted. Changed\r
+#             abbreviations from Hash to Array to better suit Ruby's\r
+#             capabilities. Fixed problems with the way that Array arguments\r
+#             are handled in calls to the major object types, excepting in\r
+#             Text::Format#expand and Text::Format#unexpand (these will\r
+#             probably need to be fixed).\r
+# 2002.10.30              Austin Ziegler\r
+#             Fixed the ordering of the <=> for binary tests. Fixed\r
+#             Text::Format#expand and Text::Format#unexpand to handle array\r
+#             arguments better.\r
+# 2003.01.24              Austin Ziegler\r
+#             Fixed a problem with Text::Format::RIGHT_FILL handling where a\r
+#             single word is larger than #columns. Removed Comparable\r
+#             capabilities (<=> doesn't make sense; == does). Added Symbol\r
+#             equivalents for the Hash initialization. Hash initialization has\r
+#             been modified so that values are set as follows (Symbols are\r
+#             highest priority; strings are middle; defaults are lowest):\r
+#                 @columns = arg[:columns] || arg['columns'] || @columns\r
+#             Added #hard_margins, #split_rules, #hyphenator, and #split_words.\r
+# 2003.02.07              Austin Ziegler\r
+#             Fixed the installer for proper case-sensitive handling.\r
+# 2003.03.28              Austin Ziegler\r
+#             Added the ability for a hyphenator to receive the formatter\r
+#             object. Fixed a bug for strings matching /\A\s*\Z/ failing\r
+#             entirely. Fixed a test case failing under 1.6.8. \r
+# 2003.04.04              Austin Ziegler\r
+#             Handle the case of hyphenators returning nil for first/rest.\r
+# 2003.09.17          Austin Ziegler\r
+#             Fixed a problem where #paragraphs(" ") was raising\r
+#             NoMethodError.\r
+#\r
+# ==========================================================================\r
+#++\r
+\r
+module Text #:nodoc:\r
+   # Text::Format for Ruby is copyright 2002 - 2005 by Austin Ziegler. It\r
+   # is available under Ruby's licence, the Perl Artistic licence, or the\r
+   # GNU GPL version 2 (or at your option, any later version). As a\r
+   # special exception, for use with official Rails (provided by the\r
+   # rubyonrails.org development team) and any project created with\r
+   # official Rails, the following alternative MIT-style licence may be\r
+   # used:\r
+   #\r
+   # == Text::Format Licence for Rails and Rails Applications\r
+   # Permission is hereby granted, free of charge, to any person\r
+   # obtaining a copy of this software and associated documentation files\r
+   # (the "Software"), to deal in the Software without restriction,\r
+   # including without limitation the rights to use, copy, modify, merge,\r
+   # publish, distribute, sublicense, and/or sell copies of the Software,\r
+   # and to permit persons to whom the Software is furnished to do so,\r
+   # subject to the following conditions:\r
+   #\r
+   # * The names of its contributors may not be used to endorse or\r
+   #   promote products derived from this software without specific prior\r
+   #   written permission.\r
+   #\r
+   # The above copyright notice and this permission notice shall be\r
+   # included in all copies or substantial portions of the Software.\r
+   #\r
+   # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+   # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+   # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+   # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+   # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+   # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+   # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+   # SOFTWARE.  \r
+   class Format\r
+    VERSION = '0.63'\r
+\r
+      # Local abbreviations. More can be added with Text::Format.abbreviations\r
+    ABBREV = [ 'Mr', 'Mrs', 'Ms', 'Jr', 'Sr' ]\r
+\r
+      # Formatting values\r
+    LEFT_ALIGN  = 0\r
+    RIGHT_ALIGN = 1\r
+    RIGHT_FILL  = 2\r
+    JUSTIFY     = 3\r
+\r
+      # Word split modes (only applies when #hard_margins is true).\r
+    SPLIT_FIXED                     = 1\r
+    SPLIT_CONTINUATION              = 2\r
+    SPLIT_HYPHENATION               = 4\r
+    SPLIT_CONTINUATION_FIXED        = SPLIT_CONTINUATION | SPLIT_FIXED\r
+    SPLIT_HYPHENATION_FIXED         = SPLIT_HYPHENATION | SPLIT_FIXED\r
+    SPLIT_HYPHENATION_CONTINUATION  = SPLIT_HYPHENATION | SPLIT_CONTINUATION\r
+    SPLIT_ALL                       = SPLIT_HYPHENATION | SPLIT_CONTINUATION | SPLIT_FIXED\r
+\r
+      # Words forcibly split by Text::Format will be stored as split words.\r
+      # This class represents a word forcibly split.\r
+    class SplitWord\r
+        # The word that was split.\r
+      attr_reader :word\r
+        # The first part of the word that was split.\r
+      attr_reader :first\r
+        # The remainder of the word that was split.\r
+      attr_reader :rest\r
+\r
+      def initialize(word, first, rest) #:nodoc:\r
+        @word = word\r
+        @first = first\r
+        @rest = rest\r
+      end\r
+    end\r
+\r
+  private\r
+    LEQ_RE = /[.?!]['"]?$/\r
+\r
+    def brk_re(i) #:nodoc:\r
+      %r/((?:\S+\s+){#{i}})(.+)/\r
+    end\r
+\r
+    def posint(p) #:nodoc:\r
+      p.to_i.abs\r
+    end\r
+\r
+  public\r
+      # Compares two Text::Format objects. All settings of the objects are\r
+      # compared *except* #hyphenator. Generated results (e.g., #split_words)\r
+      # are not compared, either.\r
+    def ==(o)\r
+      (@text          ==  o.text)           &&\r
+      (@columns       ==  o.columns)        &&\r
+      (@left_margin   ==  o.left_margin)    &&\r
+      (@right_margin  ==  o.right_margin)   &&\r
+      (@hard_margins  ==  o.hard_margins)   &&\r
+      (@split_rules   ==  o.split_rules)    &&\r
+      (@first_indent  ==  o.first_indent)   &&\r
+      (@body_indent   ==  o.body_indent)    &&\r
+      (@tag_text      ==  o.tag_text)       &&\r
+      (@tabstop       ==  o.tabstop)        &&\r
+      (@format_style  ==  o.format_style)   &&\r
+      (@extra_space   ==  o.extra_space)    &&\r
+      (@tag_paragraph ==  o.tag_paragraph)  &&\r
+      (@nobreak       ==  o.nobreak)        &&\r
+      (@abbreviations ==  o.abbreviations)  &&\r
+      (@nobreak_regex ==  o.nobreak_regex)\r
+    end\r
+\r
+      # The text to be manipulated. Note that value is optional, but if the\r
+      # formatting functions are called without values, this text is what will\r
+      # be formatted.\r
+      #\r
+      # *Default*::       <tt>[]</tt>\r
+      # <b>Used in</b>::  All methods\r
+    attr_accessor :text\r
+\r
+      # The total width of the format area. The margins, indentation, and text\r
+      # are formatted into this space.\r
+      #\r
+      #                             COLUMNS\r
+      #  <-------------------------------------------------------------->\r
+      #  <-----------><------><---------------------------><------------>\r
+      #   left margin  indent  text is formatted into here  right margin\r
+      #\r
+      # *Default*::       <tt>72</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>,\r
+      #                   <tt>#center</tt>\r
+    attr_reader :columns\r
+\r
+      # The total width of the format area. The margins, indentation, and text\r
+      # are formatted into this space. The value provided is silently\r
+      # converted to a positive integer.\r
+      #\r
+      #                             COLUMNS\r
+      #  <-------------------------------------------------------------->\r
+      #  <-----------><------><---------------------------><------------>\r
+      #   left margin  indent  text is formatted into here  right margin\r
+      #\r
+      # *Default*::       <tt>72</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>,\r
+      #                   <tt>#center</tt>\r
+    def columns=(c)\r
+      @columns = posint(c)\r
+    end\r
+\r
+      # The number of spaces used for the left margin.\r
+      #\r
+      #                             columns\r
+      #  <-------------------------------------------------------------->\r
+      #  <-----------><------><---------------------------><------------>\r
+      #   LEFT MARGIN  indent  text is formatted into here  right margin\r
+      #\r
+      # *Default*::       <tt>0</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>,\r
+      #                   <tt>#center</tt>\r
+    attr_reader :left_margin\r
+\r
+      # The number of spaces used for the left margin. The value provided is\r
+      # silently converted to a positive integer value.\r
+      #\r
+      #                             columns\r
+      #  <-------------------------------------------------------------->\r
+      #  <-----------><------><---------------------------><------------>\r
+      #   LEFT MARGIN  indent  text is formatted into here  right margin\r
+      #\r
+      # *Default*::       <tt>0</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>,\r
+      #                   <tt>#center</tt>\r
+    def left_margin=(left)\r
+      @left_margin = posint(left)\r
+    end\r
+\r
+      # The number of spaces used for the right margin.\r
+      #\r
+      #                             columns\r
+      #  <-------------------------------------------------------------->\r
+      #  <-----------><------><---------------------------><------------>\r
+      #   left margin  indent  text is formatted into here  RIGHT MARGIN\r
+      #\r
+      # *Default*::       <tt>0</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>,\r
+      #                   <tt>#center</tt>\r
+    attr_reader :right_margin\r
+\r
+      # The number of spaces used for the right margin. The value provided is\r
+      # silently converted to a positive integer value.\r
+      #\r
+      #                             columns\r
+      #  <-------------------------------------------------------------->\r
+      #  <-----------><------><---------------------------><------------>\r
+      #   left margin  indent  text is formatted into here  RIGHT MARGIN\r
+      #\r
+      # *Default*::       <tt>0</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>,\r
+      #                   <tt>#center</tt>\r
+    def right_margin=(r)\r
+      @right_margin = posint(r)\r
+    end\r
+\r
+      # The number of spaces to indent the first line of a paragraph.\r
+      #\r
+      #                             columns\r
+      #  <-------------------------------------------------------------->\r
+      #  <-----------><------><---------------------------><------------>\r
+      #   left margin  INDENT  text is formatted into here  right margin\r
+      #\r
+      # *Default*::       <tt>4</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    attr_reader :first_indent\r
+\r
+      # The number of spaces to indent the first line of a paragraph. The\r
+      # value provided is silently converted to a positive integer value.\r
+      #\r
+      #                             columns\r
+      #  <-------------------------------------------------------------->\r
+      #  <-----------><------><---------------------------><------------>\r
+      #   left margin  INDENT  text is formatted into here  right margin\r
+      #\r
+      # *Default*::       <tt>4</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    def first_indent=(f)\r
+      @first_indent = posint(f)\r
+    end\r
+\r
+      # The number of spaces to indent all lines after the first line of a\r
+      # paragraph.\r
+      #\r
+      #                             columns\r
+      #  <-------------------------------------------------------------->\r
+      #  <-----------><------><---------------------------><------------>\r
+      #   left margin  INDENT  text is formatted into here  right margin\r
+      #\r
+      # *Default*::       <tt>0</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+  attr_reader :body_indent\r
+\r
+      # The number of spaces to indent all lines after the first line of\r
+      # a paragraph. The value provided is silently converted to a\r
+      # positive integer value.\r
+      #\r
+      #                             columns\r
+      #  <-------------------------------------------------------------->\r
+      #  <-----------><------><---------------------------><------------>\r
+      #   left margin  INDENT  text is formatted into here  right margin\r
+      #\r
+      # *Default*::       <tt>0</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    def body_indent=(b)\r
+      @body_indent = posint(b)\r
+    end\r
+\r
+      # Normally, words larger than the format area will be placed on a line\r
+      # by themselves. Setting this to +true+ will force words larger than the\r
+      # format area to be split into one or more "words" each at most the size\r
+      # of the format area. The first line and the original word will be\r
+      # placed into <tt>#split_words</tt>. Note that this will cause the\r
+      # output to look *similar* to a #format_style of JUSTIFY. (Lines will be\r
+      # filled as much as possible.)\r
+      #\r
+      # *Default*::       +false+\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    attr_accessor :hard_margins\r
+\r
+      # An array of words split during formatting if #hard_margins is set to\r
+      # +true+.\r
+      #   #split_words << Text::Format::SplitWord.new(word, first, rest)\r
+    attr_reader :split_words\r
+\r
+      # The object responsible for hyphenating. It must respond to\r
+      # #hyphenate_to(word, size) or #hyphenate_to(word, size, formatter) and\r
+      # return an array of the word split into two parts; if there is a\r
+      # hyphenation mark to be applied, responsibility belongs to the\r
+      # hyphenator object. The size is the MAXIMUM size permitted, including\r
+      # any hyphenation marks. If the #hyphenate_to method has an arity of 3,\r
+      # the formatter will be provided to the method. This allows the\r
+      # hyphenator to make decisions about the hyphenation based on the\r
+      # formatting rules.\r
+      #\r
+      # *Default*::       +nil+\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    attr_reader :hyphenator\r
+\r
+      # The object responsible for hyphenating. It must respond to\r
+      # #hyphenate_to(word, size) and return an array of the word hyphenated\r
+      # into two parts. The size is the MAXIMUM size permitted, including any\r
+      # hyphenation marks.\r
+      #\r
+      # *Default*::       +nil+\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    def hyphenator=(h)\r
+      raise ArgumentError, "#{h.inspect} is not a valid hyphenator." unless h.respond_to?(:hyphenate_to)\r
+      arity = h.method(:hyphenate_to).arity\r
+      raise ArgumentError, "#{h.inspect} must have exactly two or three arguments." unless [2, 3].include?(arity)\r
+      @hyphenator = h\r
+      @hyphenator_arity = arity\r
+    end\r
+\r
+      # Specifies the split mode; used only when #hard_margins is set to\r
+      # +true+. Allowable values are:\r
+      # [+SPLIT_FIXED+]         The word will be split at the number of\r
+      #                         characters needed, with no marking at all.\r
+      #      repre\r
+      #      senta\r
+      #      ion\r
+      # [+SPLIT_CONTINUATION+]  The word will be split at the number of\r
+      #                         characters needed, with a C-style continuation\r
+      #                         character. If a word is the only item on a\r
+      #                         line and it cannot be split into an\r
+      #                         appropriate size, SPLIT_FIXED will be used.\r
+      #       repr\\r
+      #       esen\\r
+      #       tati\\r
+      #       on\r
+      # [+SPLIT_HYPHENATION+]   The word will be split according to the\r
+      #                         hyphenator specified in #hyphenator. If there\r
+      #                         is no #hyphenator specified, works like\r
+      #                         SPLIT_CONTINUATION. The example is using\r
+      #                         TeX::Hyphen. If a word is the only item on a\r
+      #                         line and it cannot be split into an\r
+      #                         appropriate size, SPLIT_CONTINUATION mode will\r
+      #                         be used.\r
+      #       rep-\r
+      #       re-\r
+      #       sen-\r
+      #       ta-\r
+      #       tion\r
+      #\r
+      # *Default*::       <tt>Text::Format::SPLIT_FIXED</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    attr_reader :split_rules\r
+\r
+      # Specifies the split mode; used only when #hard_margins is set to\r
+      # +true+. Allowable values are:\r
+      # [+SPLIT_FIXED+]         The word will be split at the number of\r
+      #                         characters needed, with no marking at all.\r
+      #      repre\r
+      #      senta\r
+      #      ion\r
+      # [+SPLIT_CONTINUATION+]  The word will be split at the number of\r
+      #                         characters needed, with a C-style continuation\r
+      #                         character.\r
+      #       repr\\r
+      #       esen\\r
+      #       tati\\r
+      #       on\r
+      # [+SPLIT_HYPHENATION+]   The word will be split according to the\r
+      #                         hyphenator specified in #hyphenator. If there\r
+      #                         is no #hyphenator specified, works like\r
+      #                         SPLIT_CONTINUATION. The example is using\r
+      #                         TeX::Hyphen as the #hyphenator.\r
+      #       rep-\r
+      #       re-\r
+      #       sen-\r
+      #       ta-\r
+      #       tion\r
+      #\r
+      # These values can be bitwise ORed together (e.g., <tt>SPLIT_FIXED |\r
+      # SPLIT_CONTINUATION</tt>) to provide fallback split methods. In the\r
+      # example given, an attempt will be made to split the word using the\r
+      # rules of SPLIT_CONTINUATION; if there is not enough room, the word\r
+      # will be split with the rules of SPLIT_FIXED. These combinations are\r
+      # also available as the following values:\r
+      # * +SPLIT_CONTINUATION_FIXED+\r
+      # * +SPLIT_HYPHENATION_FIXED+\r
+      # * +SPLIT_HYPHENATION_CONTINUATION+\r
+      # * +SPLIT_ALL+\r
+      #\r
+      # *Default*::       <tt>Text::Format::SPLIT_FIXED</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    def split_rules=(s)\r
+      raise ArgumentError, "Invalid value provided for split_rules." if ((s < SPLIT_FIXED) || (s > SPLIT_ALL))\r
+      @split_rules = s\r
+    end\r
+\r
+      # Indicates whether sentence terminators should be followed by a single\r
+      # space (+false+), or two spaces (+true+).\r
+      #\r
+      # *Default*::       +false+\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    attr_accessor :extra_space\r
+\r
+      # Defines the current abbreviations as an array. This is only used if\r
+      # extra_space is turned on.\r
+      #\r
+      # If one is abbreviating "President" as "Pres." (abbreviations =\r
+      # ["Pres"]), then the results of formatting will be as illustrated in\r
+      # the table below:\r
+      #\r
+      #       extra_space  |  include?        |  !include?\r
+      #         true       |  Pres. Lincoln   |  Pres.  Lincoln\r
+      #         false      |  Pres. Lincoln   |  Pres. Lincoln\r
+      #\r
+      # *Default*::       <tt>{}</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    attr_accessor :abbreviations\r
+\r
+      # Indicates whether the formatting of paragraphs should be done with\r
+      # tagged paragraphs. Useful only with <tt>#tag_text</tt>.\r
+      #\r
+      # *Default*::       +false+\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    attr_accessor :tag_paragraph\r
+\r
+      # The array of text to be placed before each paragraph when\r
+      # <tt>#tag_paragraph</tt> is +true+. When <tt>#format()</tt> is called,\r
+      # only the first element of the array is used. When <tt>#paragraphs</tt>\r
+      # is called, then each entry in the array will be used once, with\r
+      # corresponding paragraphs. If the tag elements are exhausted before the\r
+      # text is exhausted, then the remaining paragraphs will not be tagged.\r
+      # Regardless of indentation settings, a blank line will be inserted\r
+      # between all paragraphs when <tt>#tag_paragraph</tt> is +true+.\r
+      #\r
+      # *Default*::       <tt>[]</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    attr_accessor :tag_text\r
+\r
+      # Indicates whether or not the non-breaking space feature should be\r
+      # used.\r
+      #\r
+      # *Default*::       +false+\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    attr_accessor :nobreak\r
+\r
+      # A hash which holds the regular expressions on which spaces should not\r
+      # be broken. The hash is set up such that the key is the first word and\r
+      # the value is the second word.\r
+      #\r
+      # For example, if +nobreak_regex+ contains the following hash:\r
+      #\r
+      #   { '^Mrs?\.$' => '\S+$', '^\S+$' => '^(?:S|J)r\.$'}\r
+      #\r
+      # Then "Mr. Jones", "Mrs. Jones", and "Jones Jr." would not be broken.\r
+      # If this simple matching algorithm indicates that there should not be a\r
+      # break at the current end of line, then a backtrack is done until there\r
+      # are two words on which line breaking is permitted. If two such words\r
+      # are not found, then the end of the line will be broken *regardless*.\r
+      # If there is a single word on the current line, then no backtrack is\r
+      # done and the word is stuck on the end.\r
+      #\r
+      # *Default*::       <tt>{}</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    attr_accessor :nobreak_regex\r
+\r
+      # Indicates the number of spaces that a single tab represents.\r
+      #\r
+      # *Default*::       <tt>8</tt>\r
+      # <b>Used in</b>::  <tt>#expand</tt>, <tt>#unexpand</tt>,\r
+      #                   <tt>#paragraphs</tt>\r
+    attr_reader :tabstop\r
+\r
+      # Indicates the number of spaces that a single tab represents.\r
+      #\r
+      # *Default*::       <tt>8</tt>\r
+      # <b>Used in</b>::  <tt>#expand</tt>, <tt>#unexpand</tt>,\r
+      #                   <tt>#paragraphs</tt>\r
+    def tabstop=(t)\r
+      @tabstop = posint(t)\r
+    end\r
+\r
+      # Specifies the format style. Allowable values are:\r
+      # [+LEFT_ALIGN+]    Left justified, ragged right.\r
+      #      |A paragraph that is|\r
+      #      |left aligned.|\r
+      # [+RIGHT_ALIGN+]   Right justified, ragged left.\r
+      #      |A paragraph that is|\r
+      #      |     right aligned.|\r
+      # [+RIGHT_FILL+]    Left justified, right ragged, filled to width by\r
+      #                   spaces. (Essentially the same as +LEFT_ALIGN+ except\r
+      #                   that lines are padded on the right.)\r
+      #      |A paragraph that is|\r
+      #      |left aligned.      |\r
+      # [+JUSTIFY+]       Fully justified, words filled to width by spaces,\r
+      #                   except the last line.\r
+      #      |A paragraph  that|\r
+      #      |is     justified.|\r
+      #\r
+      # *Default*::       <tt>Text::Format::LEFT_ALIGN</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    attr_reader :format_style\r
+\r
+      # Specifies the format style. Allowable values are:\r
+      # [+LEFT_ALIGN+]    Left justified, ragged right.\r
+      #      |A paragraph that is|\r
+      #      |left aligned.|\r
+      # [+RIGHT_ALIGN+]   Right justified, ragged left.\r
+      #      |A paragraph that is|\r
+      #      |     right aligned.|\r
+      # [+RIGHT_FILL+]    Left justified, right ragged, filled to width by\r
+      #                   spaces. (Essentially the same as +LEFT_ALIGN+ except\r
+      #                   that lines are padded on the right.)\r
+      #      |A paragraph that is|\r
+      #      |left aligned.      |\r
+      # [+JUSTIFY+]       Fully justified, words filled to width by spaces.\r
+      #      |A paragraph  that|\r
+      #      |is     justified.|\r
+      #\r
+      # *Default*::       <tt>Text::Format::LEFT_ALIGN</tt>\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    def format_style=(fs)\r
+      raise ArgumentError, "Invalid value provided for format_style." if ((fs < LEFT_ALIGN) || (fs > JUSTIFY))\r
+      @format_style = fs\r
+    end\r
+\r
+      # Indicates that the format style is left alignment.\r
+      #\r
+      # *Default*::       +true+\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    def left_align?\r
+      return @format_style == LEFT_ALIGN\r
+    end\r
+\r
+      # Indicates that the format style is right alignment.\r
+      #\r
+      # *Default*::       +false+\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    def right_align?\r
+      return @format_style == RIGHT_ALIGN\r
+    end\r
+\r
+      # Indicates that the format style is right fill.\r
+      #\r
+      # *Default*::       +false+\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    def right_fill?\r
+      return @format_style == RIGHT_FILL\r
+    end\r
+\r
+      # Indicates that the format style is full justification.\r
+      #\r
+      # *Default*::       +false+\r
+      # <b>Used in</b>::  <tt>#format</tt>, <tt>#paragraphs</tt>\r
+    def justify?\r
+      return @format_style == JUSTIFY\r
+    end\r
+\r
+      # The default implementation of #hyphenate_to implements\r
+      # SPLIT_CONTINUATION.\r
+    def hyphenate_to(word, size)\r
+      [word[0 .. (size - 2)] + "\\", word[(size - 1) .. -1]]\r
+    end\r
+\r
+  private\r
+    def __do_split_word(word, size) #:nodoc:\r
+      [word[0 .. (size - 1)], word[size .. -1]]\r
+    end\r
+\r
+    def __format(to_wrap) #:nodoc:\r
+      words = to_wrap.split(/\s+/).compact\r
+      words.shift if words[0].nil? or words[0].empty?\r
+      to_wrap = []\r
+\r
+      abbrev = false\r
+      width = @columns - @first_indent - @left_margin - @right_margin\r
+      indent_str = ' ' * @first_indent\r
+      first_line = true\r
+      line = words.shift\r
+      abbrev = __is_abbrev(line) unless line.nil? || line.empty?\r
+\r
+      while w = words.shift\r
+        if (w.size + line.size < (width - 1)) ||\r
+           ((line !~ LEQ_RE || abbrev) && (w.size + line.size < width))\r
+          line << " " if (line =~ LEQ_RE) && (not abbrev)\r
+          line << " #{w}"\r
+        else\r
+          line, w = __do_break(line, w) if @nobreak\r
+          line, w = __do_hyphenate(line, w, width) if @hard_margins\r
+          if w.index(/\s+/)\r
+            w, *w2 = w.split(/\s+/)\r
+            words.unshift(w2)\r
+            words.flatten!\r
+          end\r
+          to_wrap << __make_line(line, indent_str, width, w.nil?) unless line.nil?\r
+          if first_line\r
+            first_line = false\r
+            width = @columns - @body_indent - @left_margin - @right_margin\r
+            indent_str = ' ' * @body_indent\r
+          end\r
+          line = w\r
+        end\r
+\r
+        abbrev = __is_abbrev(w) unless w.nil?\r
+      end\r
+\r
+      loop do\r
+        break if line.nil? or line.empty?\r
+        line, w = __do_hyphenate(line, w, width) if @hard_margins\r
+        to_wrap << __make_line(line, indent_str, width, w.nil?)\r
+        line = w\r
+      end\r
+\r
+      if (@tag_paragraph && (to_wrap.size > 0)) then\r
+        clr = %r{`(\w+)'}.match([caller(1)].flatten[0])[1]\r
+        clr = "" if clr.nil?\r
+\r
+        if ((not @tag_text[0].nil?) && (@tag_cur.size < 1) &&\r
+            (clr != "__paragraphs")) then\r
+          @tag_cur = @tag_text[0]\r
+        end\r
+\r
+        fchar = /(\S)/.match(to_wrap[0])[1]\r
+        white = to_wrap[0].index(fchar)\r
+        if ((white - @left_margin - 1) > @tag_cur.size) then\r
+          white = @tag_cur.size + @left_margin\r
+          to_wrap[0].gsub!(/^ {#{white}}/, "#{' ' * @left_margin}#{@tag_cur}")\r
+        else\r
+          to_wrap.unshift("#{' ' * @left_margin}#{@tag_cur}\n")\r
+        end\r
+      end\r
+      to_wrap.join('')\r
+    end\r
+\r
+      # format lines in text into paragraphs with each element of @wrap a\r
+      # paragraph; uses Text::Format.format for the formatting\r
+    def __paragraphs(to_wrap) #:nodoc:\r
+      if ((@first_indent == @body_indent) || @tag_paragraph) then\r
+        p_end = "\n"\r
+      else\r
+        p_end = ''\r
+      end\r
+\r
+      cnt = 0\r
+      ret = []\r
+      to_wrap.each do |tw|\r
+        @tag_cur = @tag_text[cnt] if @tag_paragraph\r
+        @tag_cur = '' if @tag_cur.nil?\r
+        line = __format(tw)\r
+        ret << "#{line}#{p_end}" if (not line.nil?) && (line.size > 0)\r
+        cnt += 1\r
+      end\r
+\r
+      ret[-1].chomp! unless ret.empty?\r
+      ret.join('')\r
+    end\r
+\r
+      # center text using spaces on left side to pad it out empty lines\r
+      # are preserved\r
+    def __center(to_center) #:nodoc:\r
+      tabs = 0\r
+      width = @columns - @left_margin - @right_margin\r
+      centered = []\r
+      to_center.each do |tc|\r
+        s = tc.strip\r
+        tabs = s.count("\t")\r
+        tabs = 0 if tabs.nil?\r
+        ct = ((width - s.size - (tabs * @tabstop) + tabs) / 2)\r
+        ct = (width - @left_margin - @right_margin) - ct\r
+        centered << "#{s.rjust(ct)}\n"\r
+      end\r
+      centered.join('')\r
+    end\r
+\r
+      # expand tabs to spaces should be similar to Text::Tabs::expand\r
+    def __expand(to_expand) #:nodoc:\r
+      expanded = []\r
+      to_expand.split("\n").each { |te| expanded << te.gsub(/\t/, ' ' * @tabstop) }\r
+      expanded.join('')\r
+    end\r
+\r
+    def __unexpand(to_unexpand) #:nodoc:\r
+      unexpanded = []\r
+      to_unexpand.split("\n").each { |tu| unexpanded << tu.gsub(/ {#{@tabstop}}/, "\t") }\r
+      unexpanded.join('')\r
+    end\r
+\r
+    def __is_abbrev(word) #:nodoc:\r
+        # remove period if there is one.\r
+      w = word.gsub(/\.$/, '') unless word.nil?\r
+      return true if (!@extra_space || ABBREV.include?(w) || @abbreviations.include?(w))\r
+      false\r
+    end\r
+\r
+    def __make_line(line, indent, width, last = false) #:nodoc:\r
+      lmargin = " " * @left_margin\r
+      fill = " " * (width - line.size) if right_fill? && (line.size <= width)\r
+\r
+      if (justify? && ((not line.nil?) && (not line.empty?)) && line =~ /\S+\s+\S+/ && !last)\r
+        spaces = width - line.size\r
+        words = line.split(/(\s+)/)\r
+        ws = spaces / (words.size / 2)\r
+        spaces = spaces % (words.size / 2) if ws > 0\r
+        words.reverse.each do |rw|\r
+          next if (rw =~ /^\S/)\r
+          rw.sub!(/^/, " " * ws)\r
+          next unless (spaces > 0)\r
+          rw.sub!(/^/, " ")\r
+          spaces -= 1\r
+        end\r
+        line = words.join('')\r
+      end\r
+      line = "#{lmargin}#{indent}#{line}#{fill}\n" unless line.nil?\r
+      if right_align? && (not line.nil?)\r
+        line.sub(/^/, " " * (@columns - @right_margin - (line.size - 1)))\r
+      else\r
+        line\r
+      end\r
+    end\r
+\r
+    def __do_hyphenate(line, next_line, width) #:nodoc:\r
+      rline = line.dup rescue line\r
+      rnext = next_line.dup rescue next_line\r
+      loop do\r
+        if rline.size == width\r
+          break\r
+        elsif rline.size > width\r
+          words = rline.strip.split(/\s+/)\r
+          word = words[-1].dup\r
+          size = width - rline.size + word.size\r
+          if (size <= 0)\r
+            words[-1] = nil\r
+            rline = words.join(' ').strip\r
+            rnext = "#{word} #{rnext}".strip\r
+            next\r
+          end\r
+\r
+          first = rest = nil\r
+\r
+          if ((@split_rules & SPLIT_HYPHENATION) != 0)\r
+            if @hyphenator_arity == 2\r
+              first, rest = @hyphenator.hyphenate_to(word, size)\r
+            else\r
+              first, rest = @hyphenator.hyphenate_to(word, size, self)\r
+            end\r
+          end\r
+\r
+          if ((@split_rules & SPLIT_CONTINUATION) != 0) and first.nil?\r
+            first, rest = self.hyphenate_to(word, size)\r
+          end\r
+\r
+          if ((@split_rules & SPLIT_FIXED) != 0) and first.nil?\r
+            first.nil? or @split_rules == SPLIT_FIXED\r
+            first, rest = __do_split_word(word, size)\r
+          end\r
+\r
+          if first.nil?\r
+            words[-1] = nil\r
+            rest = word\r
+          else\r
+            words[-1] = first\r
+            @split_words << SplitWord.new(word, first, rest)\r
+          end\r
+          rline = words.join(' ').strip\r
+          rnext = "#{rest} #{rnext}".strip\r
+          break\r
+        else\r
+          break if rnext.nil? or rnext.empty? or rline.nil? or rline.empty?\r
+          words = rnext.split(/\s+/)\r
+          word = words.shift\r
+          size = width - rline.size - 1\r
+\r
+          if (size <= 0)\r
+            rnext = "#{word} #{words.join(' ')}".strip\r
+            break\r
+          end\r
+\r
+          first = rest = nil\r
+\r
+          if ((@split_rules & SPLIT_HYPHENATION) != 0)\r
+            if @hyphenator_arity == 2\r
+              first, rest = @hyphenator.hyphenate_to(word, size)\r
+            else\r
+              first, rest = @hyphenator.hyphenate_to(word, size, self)\r
+            end\r
+          end\r
+\r
+          first, rest = self.hyphenate_to(word, size) if ((@split_rules & SPLIT_CONTINUATION) != 0) and first.nil?\r
+\r
+          first, rest = __do_split_word(word, size) if ((@split_rules & SPLIT_FIXED) != 0) and first.nil?\r
+\r
+          if (rline.size + (first ? first.size : 0)) < width\r
+            @split_words << SplitWord.new(word, first, rest)\r
+            rline = "#{rline} #{first}".strip\r
+            rnext = "#{rest} #{words.join(' ')}".strip\r
+          end\r
+          break\r
+        end\r
+      end\r
+      [rline, rnext]\r
+    end\r
+\r
+    def __do_break(line, next_line) #:nodoc:\r
+      no_brk = false\r
+      words = []\r
+      words = line.split(/\s+/) unless line.nil?\r
+      last_word = words[-1]\r
+\r
+      @nobreak_regex.each { |k, v| no_brk = ((last_word =~ /#{k}/) and (next_line =~ /#{v}/)) }\r
+\r
+      if no_brk && words.size > 1\r
+        i = words.size\r
+        while i > 0\r
+          no_brk = false\r
+          @nobreak_regex.each { |k, v| no_brk = ((words[i + 1] =~ /#{k}/) && (words[i] =~ /#{v}/)) }\r
+          i -= 1\r
+          break if not no_brk\r
+        end\r
+        if i > 0\r
+          l = brk_re(i).match(line)\r
+          line.sub!(brk_re(i), l[1])\r
+          next_line = "#{l[2]} #{next_line}"\r
+          line.sub!(/\s+$/, '')\r
+        end\r
+      end\r
+      [line, next_line]\r
+    end\r
+\r
+    def __create(arg = nil, &block) #:nodoc:\r
+        # Format::Text.new(text-to-wrap)\r
+      @text = arg unless arg.nil?\r
+        # Defaults\r
+      @columns          = 72\r
+      @tabstop          = 8\r
+      @first_indent     = 4\r
+      @body_indent      = 0\r
+      @format_style     = LEFT_ALIGN\r
+      @left_margin      = 0\r
+      @right_margin     = 0\r
+      @extra_space      = false\r
+      @text             = Array.new if @text.nil?\r
+      @tag_paragraph    = false\r
+      @tag_text         = Array.new\r
+      @tag_cur          = ""\r
+      @abbreviations    = Array.new\r
+      @nobreak          = false\r
+      @nobreak_regex    = Hash.new\r
+      @split_words      = Array.new\r
+      @hard_margins     = false\r
+      @split_rules      = SPLIT_FIXED\r
+      @hyphenator       = self\r
+      @hyphenator_arity = self.method(:hyphenate_to).arity\r
+\r
+      instance_eval(&block) unless block.nil?\r
+    end\r
+\r
+  public\r
+      # Formats text into a nice paragraph format. The text is separated\r
+      # into words and then reassembled a word at a time using the settings\r
+      # of this Format object. If a word is larger than the number of\r
+      # columns available for formatting, then that word will appear on the\r
+      # line by itself.\r
+      #\r
+      # If +to_wrap+ is +nil+, then the value of <tt>#text</tt> will be\r
+      # worked on.\r
+    def format(to_wrap = nil)\r
+      to_wrap = @text if to_wrap.nil?\r
+      if to_wrap.class == Array\r
+        __format(to_wrap[0])\r
+      else\r
+        __format(to_wrap)\r
+      end\r
+    end\r
+\r
+      # Considers each element of text (provided or internal) as a paragraph.\r
+      # If <tt>#first_indent</tt> is the same as <tt>#body_indent</tt>, then\r
+      # paragraphs will be separated by a single empty line in the result;\r
+      # otherwise, the paragraphs will follow immediately after each other.\r
+      # Uses <tt>#format</tt> to do the heavy lifting.\r
+    def paragraphs(to_wrap = nil)\r
+      to_wrap = @text if to_wrap.nil?\r
+      __paragraphs([to_wrap].flatten)\r
+    end\r
+\r
+      # Centers the text, preserving empty lines and tabs.\r
+    def center(to_center = nil)\r
+      to_center = @text if to_center.nil?\r
+      __center([to_center].flatten)\r
+    end\r
+\r
+      # Replaces all tab characters in the text with <tt>#tabstop</tt> spaces.\r
+    def expand(to_expand = nil)\r
+      to_expand = @text if to_expand.nil?\r
+      if to_expand.class == Array\r
+        to_expand.collect { |te| __expand(te) }\r
+      else\r
+        __expand(to_expand)\r
+      end\r
+    end\r
+\r
+      # Replaces all occurrences of <tt>#tabstop</tt> consecutive spaces\r
+      # with a tab character.\r
+    def unexpand(to_unexpand = nil)\r
+      to_unexpand = @text if to_unexpand.nil?\r
+      if to_unexpand.class == Array\r
+        to_unexpand.collect { |te| v << __unexpand(te) }\r
+      else\r
+        __unexpand(to_unexpand)\r
+      end\r
+    end\r
+\r
+      # This constructor takes advantage of a technique for Ruby object\r
+      # construction introduced by Andy Hunt and Dave Thomas (see reference),\r
+      # where optional values are set using commands in a block.\r
+      #\r
+      #   Text::Format.new {\r
+      #       columns         = 72\r
+      #       left_margin     = 0\r
+      #       right_margin    = 0\r
+      #       first_indent    = 4\r
+      #       body_indent     = 0\r
+      #       format_style    = Text::Format::LEFT_ALIGN\r
+      #       extra_space     = false\r
+      #       abbreviations   = {}\r
+      #       tag_paragraph   = false\r
+      #       tag_text        = []\r
+      #       nobreak         = false\r
+      #       nobreak_regex   = {}\r
+      #       tabstop         = 8\r
+      #       text            = nil\r
+      #   }\r
+      #\r
+      # As shown above, +arg+ is optional. If +arg+ is specified and is a\r
+      # +String+, then arg is used as the default value of <tt>#text</tt>.\r
+      # Alternately, an existing Text::Format object can be used or a Hash can\r
+      # be used. With all forms, a block can be specified.\r
+      #\r
+      # *Reference*:: "Object Construction and Blocks"\r
+      #               <http://www.pragmaticprogrammer.com/ruby/articles/insteval.html>\r
+      #\r
+    def initialize(arg = nil, &block)\r
+      case arg\r
+      when Text::Format\r
+        __create(arg.text) do\r
+          @columns        = arg.columns\r
+          @tabstop        = arg.tabstop\r
+          @first_indent   = arg.first_indent\r
+          @body_indent    = arg.body_indent\r
+          @format_style   = arg.format_style\r
+          @left_margin    = arg.left_margin\r
+          @right_margin   = arg.right_margin\r
+          @extra_space    = arg.extra_space\r
+          @tag_paragraph  = arg.tag_paragraph\r
+          @tag_text       = arg.tag_text\r
+          @abbreviations  = arg.abbreviations\r
+          @nobreak        = arg.nobreak\r
+          @nobreak_regex  = arg.nobreak_regex\r
+          @text           = arg.text\r
+          @hard_margins   = arg.hard_margins\r
+          @split_words    = arg.split_words\r
+          @split_rules    = arg.split_rules\r
+          @hyphenator     = arg.hyphenator\r
+        end\r
+        instance_eval(&block) unless block.nil?\r
+      when Hash\r
+        __create do\r
+          @columns       = arg[:columns]       || arg['columns']       || @columns\r
+          @tabstop       = arg[:tabstop]       || arg['tabstop']       || @tabstop\r
+          @first_indent  = arg[:first_indent]  || arg['first_indent']  || @first_indent\r
+          @body_indent   = arg[:body_indent]   || arg['body_indent']   || @body_indent\r
+          @format_style  = arg[:format_style]  || arg['format_style']  || @format_style\r
+          @left_margin   = arg[:left_margin]   || arg['left_margin']   || @left_margin\r
+          @right_margin  = arg[:right_margin]  || arg['right_margin']  || @right_margin\r
+          @extra_space   = arg[:extra_space]   || arg['extra_space']   || @extra_space\r
+          @text          = arg[:text]          || arg['text']          || @text\r
+          @tag_paragraph = arg[:tag_paragraph] || arg['tag_paragraph'] || @tag_paragraph\r
+          @tag_text      = arg[:tag_text]      || arg['tag_text']      || @tag_text\r
+          @abbreviations = arg[:abbreviations] || arg['abbreviations'] || @abbreviations\r
+          @nobreak       = arg[:nobreak]       || arg['nobreak']       || @nobreak\r
+          @nobreak_regex = arg[:nobreak_regex] || arg['nobreak_regex'] || @nobreak_regex\r
+          @hard_margins  = arg[:hard_margins]  || arg['hard_margins']  || @hard_margins\r
+          @split_rules   = arg[:split_rules] || arg['split_rules'] || @split_rules\r
+          @hyphenator    = arg[:hyphenator] || arg['hyphenator'] || @hyphenator\r
+        end\r
+        instance_eval(&block) unless block.nil?\r
+      when String\r
+        __create(arg, &block)\r
+      when NilClass\r
+        __create(&block)\r
+      else\r
+        raise TypeError\r
+      end\r
+    end\r
+  end\r
+end\r
+\r
+if __FILE__ == $0\r
+  require 'test/unit'\r
+\r
+  class TestText__Format < Test::Unit::TestCase #:nodoc:\r
+    attr_accessor :format_o\r
+\r
+    GETTYSBURG = <<-'EOS'\r
+    Four score and seven years ago our fathers brought forth on this\r
+    continent a new nation, conceived in liberty and dedicated to the\r
+    proposition that all men are created equal. Now we are engaged in\r
+    a great civil war, testing whether that nation or any nation so\r
+    conceived and so dedicated can long endure. We are met on a great\r
+    battlefield of that war. We have come to dedicate a portion of\r
+    that field as a final resting-place for those who here gave their\r
+    lives that that nation might live. It is altogether fitting and\r
+    proper that we should do this. But in a larger sense, we cannot\r
+    dedicate, we cannot consecrate, we cannot hallow this ground.\r
+    The brave men, living and dead who struggled here have consecrated\r
+    it far above our poor power to add or detract. The world will\r
+    little note nor long remember what we say here, but it can never\r
+    forget what they did here. It is for us the living rather to be\r
+    dedicated here to the unfinished work which they who fought here\r
+    have thus far so nobly advanced. It is rather for us to be here\r
+    dedicated to the great task remaining before us--that from these\r
+    honored dead we take increased devotion to that cause for which\r
+    they gave the last full measure of devotion--that we here highly\r
+    resolve that these dead shall not have died in vain, that this\r
+    nation under God shall have a new birth of freedom, and that\r
+    government of the people, by the people, for the people shall\r
+    not perish from the earth.\r
+\r
+            -- Pres. Abraham Lincoln, 19 November 1863\r
+    EOS\r
+\r
+    FIVE_COL = "Four \nscore\nand s\neven \nyears\nago o\nur fa\nthers\nbroug\nht fo\nrth o\nn thi\ns con\ntinen\nt a n\new na\ntion,\nconce\nived \nin li\nberty\nand d\nedica\nted t\no the\npropo\nsitio\nn tha\nt all\nmen a\nre cr\neated\nequal\n. Now\nwe ar\ne eng\naged \nin a \ngreat\ncivil\nwar, \ntesti\nng wh\nether\nthat \nnatio\nn or \nany n\nation\nso co\nnceiv\ned an\nd so \ndedic\nated \ncan l\nong e\nndure\n. We \nare m\net on\na gre\nat ba\nttlef\nield \nof th\nat wa\nr. We\nhave \ncome \nto de\ndicat\ne a p\nortio\nn of \nthat \nfield\nas a \nfinal\nresti\nng-pl\nace f\nor th\nose w\nho he\nre ga\nve th\neir l\nives \nthat \nthat \nnatio\nn mig\nht li\nve. I\nt is \naltog\nether\nfitti\nng an\nd pro\nper t\nhat w\ne sho\nuld d\no thi\ns. Bu\nt in \na lar\nger s\nense,\nwe ca\nnnot \ndedic\nate, \nwe ca\nnnot \nconse\ncrate\n, we \ncanno\nt hal\nlow t\nhis g\nround\n. The\nbrave\nmen, \nlivin\ng and\ndead \nwho s\ntrugg\nled h\nere h\nave c\nonsec\nrated\nit fa\nr abo\nve ou\nr poo\nr pow\ner to\nadd o\nr det\nract.\nThe w\norld \nwill \nlittl\ne not\ne nor\nlong \nremem\nber w\nhat w\ne say\nhere,\nbut i\nt can\nnever\nforge\nt wha\nt the\ny did\nhere.\nIt is\nfor u\ns the\nlivin\ng rat\nher t\no be \ndedic\nated \nhere \nto th\ne unf\ninish\ned wo\nrk wh\nich t\nhey w\nho fo\nught \nhere \nhave \nthus \nfar s\no nob\nly ad\nvance\nd. It\nis ra\nther \nfor u\ns to \nbe he\nre de\ndicat\ned to\nthe g\nreat \ntask \nremai\nning \nbefor\ne us-\n-that\nfrom \nthese\nhonor\ned de\nad we\ntake \nincre\nased \ndevot\nion t\no tha\nt cau\nse fo\nr whi\nch th\ney ga\nve th\ne las\nt ful\nl mea\nsure \nof de\nvotio\nn--th\nat we\nhere \nhighl\ny res\nolve \nthat \nthese\ndead \nshall\nnot h\nave d\nied i\nn vai\nn, th\nat th\nis na\ntion \nunder\nGod s\nhall \nhave \na new\nbirth\nof fr\needom\n, and\nthat \ngover\nnment\nof th\ne peo\nple, \nby th\ne peo\nple, \nfor t\nhe pe\nople \nshall\nnot p\nerish\nfrom \nthe e\narth.\n-- Pr\nes. A\nbraha\nm Lin\ncoln,\n19 No\nvembe\nr 186\n3    \n"\r
+\r
+    FIVE_CNT = "Four \nscore\nand  \nseven\nyears\nago  \nour  \nfath\\\ners  \nbrou\\\nght  \nforth\non t\\\nhis  \ncont\\\ninent\na new\nnati\\\non,  \nconc\\\neived\nin l\\\niber\\\nty a\\\nnd d\\\nedic\\\nated \nto t\\\nhe p\\\nropo\\\nsiti\\\non t\\\nhat  \nall  \nmen  \nare  \ncrea\\\nted  \nequa\\\nl. N\\\now we\nare  \nenga\\\nged  \nin a \ngreat\ncivil\nwar, \ntest\\\ning  \nwhet\\\nher  \nthat \nnati\\\non or\nany  \nnati\\\non so\nconc\\\neived\nand  \nso d\\\nedic\\\nated \ncan  \nlong \nendu\\\nre.  \nWe a\\\nre m\\\net on\na gr\\\neat  \nbatt\\\nlefi\\\neld  \nof t\\\nhat  \nwar. \nWe h\\\nave  \ncome \nto d\\\nedic\\\nate a\nport\\\nion  \nof t\\\nhat  \nfield\nas a \nfinal\nrest\\\ning-\\\nplace\nfor  \nthose\nwho  \nhere \ngave \ntheir\nlives\nthat \nthat \nnati\\\non m\\\night \nlive.\nIt is\nalto\\\ngeth\\\ner f\\\nitti\\\nng a\\\nnd p\\\nroper\nthat \nwe s\\\nhould\ndo t\\\nhis. \nBut  \nin a \nlarg\\\ner s\\\nense,\nwe c\\\nannot\ndedi\\\ncate,\nwe c\\\nannot\ncons\\\necra\\\nte,  \nwe c\\\nannot\nhall\\\now t\\\nhis  \ngrou\\\nnd.  \nThe  \nbrave\nmen, \nlivi\\\nng a\\\nnd d\\\nead  \nwho  \nstru\\\nggled\nhere \nhave \ncons\\\necra\\\nted  \nit f\\\nar a\\\nbove \nour  \npoor \npower\nto a\\\ndd or\ndetr\\\nact. \nThe  \nworld\nwill \nlitt\\\nle n\\\note  \nnor  \nlong \nreme\\\nmber \nwhat \nwe s\\\nay h\\\nere, \nbut  \nit c\\\nan n\\\never \nforg\\\net w\\\nhat  \nthey \ndid  \nhere.\nIt is\nfor  \nus t\\\nhe l\\\niving\nrath\\\ner to\nbe d\\\nedic\\\nated \nhere \nto t\\\nhe u\\\nnfin\\\nished\nwork \nwhich\nthey \nwho  \nfoug\\\nht h\\\nere  \nhave \nthus \nfar  \nso n\\\nobly \nadva\\\nnced.\nIt is\nrath\\\ner f\\\nor us\nto be\nhere \ndedi\\\ncated\nto t\\\nhe g\\\nreat \ntask \nrema\\\nining\nbefo\\\nre u\\\ns--t\\\nhat  \nfrom \nthese\nhono\\\nred  \ndead \nwe t\\\nake  \nincr\\\neased\ndevo\\\ntion \nto t\\\nhat  \ncause\nfor  \nwhich\nthey \ngave \nthe  \nlast \nfull \nmeas\\\nure  \nof d\\\nevot\\\nion-\\\n-that\nwe h\\\nere  \nhigh\\\nly r\\\nesol\\\nve t\\\nhat  \nthese\ndead \nshall\nnot  \nhave \ndied \nin v\\\nain, \nthat \nthis \nnati\\\non u\\\nnder \nGod  \nshall\nhave \na new\nbirth\nof f\\\nreed\\\nom,  \nand  \nthat \ngove\\\nrnme\\\nnt of\nthe  \npeop\\\nle,  \nby t\\\nhe p\\\neopl\\\ne, f\\\nor t\\\nhe p\\\neople\nshall\nnot  \nperi\\\nsh f\\\nrom  \nthe  \neart\\\nh. --\nPres.\nAbra\\\nham  \nLinc\\\noln, \n19 N\\\novem\\\nber  \n1863 \n"\r
+\r
+      # Tests both abbreviations and abbreviations=\r
+    def test_abbreviations\r
+      abbr = ["    Pres. Abraham Lincoln\n", "    Pres.  Abraham Lincoln\n"]\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert_equal([], @format_o.abbreviations)\r
+      assert_nothing_raised { @format_o.abbreviations = [ 'foo', 'bar' ] }\r
+      assert_equal([ 'foo', 'bar' ], @format_o.abbreviations)\r
+      assert_equal(abbr[0], @format_o.format(abbr[0]))\r
+      assert_nothing_raised { @format_o.extra_space = true }\r
+      assert_equal(abbr[1], @format_o.format(abbr[0]))\r
+      assert_nothing_raised { @format_o.abbreviations = [ "Pres" ] }\r
+      assert_equal([ "Pres" ], @format_o.abbreviations)\r
+      assert_equal(abbr[0], @format_o.format(abbr[0]))\r
+      assert_nothing_raised { @format_o.extra_space = false }\r
+      assert_equal(abbr[0], @format_o.format(abbr[0]))\r
+    end\r
+\r
+      # Tests both body_indent and body_indent=\r
+    def test_body_indent\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert_equal(0, @format_o.body_indent)\r
+      assert_nothing_raised { @format_o.body_indent = 7 }\r
+      assert_equal(7, @format_o.body_indent)\r
+      assert_nothing_raised { @format_o.body_indent = -3 }\r
+      assert_equal(3, @format_o.body_indent)\r
+      assert_nothing_raised { @format_o.body_indent = "9" }\r
+      assert_equal(9, @format_o.body_indent)\r
+      assert_nothing_raised { @format_o.body_indent = "-2" }\r
+      assert_equal(2, @format_o.body_indent)\r
+      assert_match(/^  [^ ]/, @format_o.format(GETTYSBURG).split("\n")[1])\r
+    end\r
+\r
+      # Tests both columns and columns=\r
+    def test_columns\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert_equal(72, @format_o.columns)\r
+      assert_nothing_raised { @format_o.columns = 7 }\r
+      assert_equal(7, @format_o.columns)\r
+      assert_nothing_raised { @format_o.columns = -3 }\r
+      assert_equal(3, @format_o.columns)\r
+      assert_nothing_raised { @format_o.columns = "9" }\r
+      assert_equal(9, @format_o.columns)\r
+      assert_nothing_raised { @format_o.columns = "-2" }\r
+      assert_equal(2, @format_o.columns)\r
+      assert_nothing_raised { @format_o.columns = 40 }\r
+      assert_equal(40, @format_o.columns)\r
+      assert_match(/this continent$/,\r
+                   @format_o.format(GETTYSBURG).split("\n")[1])\r
+    end\r
+\r
+      # Tests both extra_space and extra_space=\r
+    def test_extra_space\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert(!@format_o.extra_space)\r
+      assert_nothing_raised { @format_o.extra_space = true }\r
+      assert(@format_o.extra_space)\r
+        # The behaviour of extra_space is tested in test_abbreviations. There\r
+        # is no need to reproduce it here.\r
+    end\r
+\r
+      # Tests both first_indent and first_indent=\r
+    def test_first_indent\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert_equal(4, @format_o.first_indent)\r
+      assert_nothing_raised { @format_o.first_indent = 7 }\r
+      assert_equal(7, @format_o.first_indent)\r
+      assert_nothing_raised { @format_o.first_indent = -3 }\r
+      assert_equal(3, @format_o.first_indent)\r
+      assert_nothing_raised { @format_o.first_indent = "9" }\r
+      assert_equal(9, @format_o.first_indent)\r
+      assert_nothing_raised { @format_o.first_indent = "-2" }\r
+      assert_equal(2, @format_o.first_indent)\r
+      assert_match(/^  [^ ]/, @format_o.format(GETTYSBURG).split("\n")[0])\r
+    end\r
+\r
+    def test_format_style\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert_equal(Text::Format::LEFT_ALIGN, @format_o.format_style)\r
+      assert_match(/^November 1863$/,\r
+                   @format_o.format(GETTYSBURG).split("\n")[-1])\r
+      assert_nothing_raised {\r
+        @format_o.format_style = Text::Format::RIGHT_ALIGN\r
+      }\r
+      assert_equal(Text::Format::RIGHT_ALIGN, @format_o.format_style)\r
+      assert_match(/^ +November 1863$/,\r
+                   @format_o.format(GETTYSBURG).split("\n")[-1])\r
+      assert_nothing_raised {\r
+        @format_o.format_style = Text::Format::RIGHT_FILL\r
+      }\r
+      assert_equal(Text::Format::RIGHT_FILL, @format_o.format_style)\r
+      assert_match(/^November 1863 +$/,\r
+                   @format_o.format(GETTYSBURG).split("\n")[-1])\r
+      assert_nothing_raised { @format_o.format_style = Text::Format::JUSTIFY }\r
+      assert_equal(Text::Format::JUSTIFY, @format_o.format_style)\r
+      assert_match(/^of freedom, and that government of the people, by the  people,  for  the$/,\r
+                   @format_o.format(GETTYSBURG).split("\n")[-3])\r
+      assert_raises(ArgumentError) { @format_o.format_style = 33 }\r
+    end\r
+\r
+    def test_tag_paragraph\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert(!@format_o.tag_paragraph)\r
+      assert_nothing_raised { @format_o.tag_paragraph = true }\r
+      assert(@format_o.tag_paragraph)\r
+      assert_not_equal(@format_o.paragraphs([GETTYSBURG, GETTYSBURG]),\r
+                       Text::Format.new.paragraphs([GETTYSBURG, GETTYSBURG]))\r
+    end\r
+\r
+    def test_tag_text\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert_equal([], @format_o.tag_text)\r
+      assert_equal(@format_o.format(GETTYSBURG),\r
+                   Text::Format.new.format(GETTYSBURG))\r
+      assert_nothing_raised {\r
+        @format_o.tag_paragraph = true\r
+        @format_o.tag_text = ["Gettysburg Address", "---"]\r
+      }\r
+      assert_not_equal(@format_o.format(GETTYSBURG),\r
+                       Text::Format.new.format(GETTYSBURG))\r
+      assert_not_equal(@format_o.paragraphs([GETTYSBURG, GETTYSBURG]),\r
+                       Text::Format.new.paragraphs([GETTYSBURG, GETTYSBURG]))\r
+      assert_not_equal(@format_o.paragraphs([GETTYSBURG, GETTYSBURG,\r
+                                             GETTYSBURG]),\r
+                       Text::Format.new.paragraphs([GETTYSBURG, GETTYSBURG,\r
+                                                    GETTYSBURG]))\r
+    end\r
+\r
+    def test_justify?\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert(!@format_o.justify?)\r
+      assert_nothing_raised {\r
+        @format_o.format_style = Text::Format::RIGHT_ALIGN\r
+      }\r
+      assert(!@format_o.justify?)\r
+      assert_nothing_raised {\r
+        @format_o.format_style = Text::Format::RIGHT_FILL\r
+      }\r
+      assert(!@format_o.justify?)\r
+      assert_nothing_raised {\r
+        @format_o.format_style = Text::Format::JUSTIFY\r
+      }\r
+      assert(@format_o.justify?)\r
+        # The format testing is done in test_format_style\r
+    end\r
+\r
+    def test_left_align?\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert(@format_o.left_align?)\r
+      assert_nothing_raised {\r
+        @format_o.format_style = Text::Format::RIGHT_ALIGN\r
+      }\r
+      assert(!@format_o.left_align?)\r
+      assert_nothing_raised {\r
+        @format_o.format_style = Text::Format::RIGHT_FILL\r
+      }\r
+      assert(!@format_o.left_align?)\r
+      assert_nothing_raised { @format_o.format_style = Text::Format::JUSTIFY }\r
+      assert(!@format_o.left_align?)\r
+        # The format testing is done in test_format_style\r
+    end\r
+\r
+    def test_left_margin\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert_equal(0, @format_o.left_margin)\r
+      assert_nothing_raised { @format_o.left_margin = -3 }\r
+      assert_equal(3, @format_o.left_margin)\r
+      assert_nothing_raised { @format_o.left_margin = "9" }\r
+      assert_equal(9, @format_o.left_margin)\r
+      assert_nothing_raised { @format_o.left_margin = "-2" }\r
+      assert_equal(2, @format_o.left_margin)\r
+      assert_nothing_raised { @format_o.left_margin = 7 }\r
+      assert_equal(7, @format_o.left_margin)\r
+      assert_nothing_raised {\r
+        ft = @format_o.format(GETTYSBURG).split("\n")\r
+        assert_match(/^ {11}Four score/, ft[0])\r
+        assert_match(/^ {7}November/, ft[-1])\r
+      }\r
+    end\r
+\r
+    def test_hard_margins\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert(!@format_o.hard_margins)\r
+      assert_nothing_raised {\r
+        @format_o.hard_margins = true\r
+        @format_o.columns = 5\r
+        @format_o.first_indent = 0\r
+        @format_o.format_style = Text::Format::RIGHT_FILL\r
+      }\r
+      assert(@format_o.hard_margins)\r
+      assert_equal(FIVE_COL, @format_o.format(GETTYSBURG))\r
+      assert_nothing_raised {\r
+        @format_o.split_rules |= Text::Format::SPLIT_CONTINUATION\r
+        assert_equal(Text::Format::SPLIT_CONTINUATION_FIXED,\r
+                     @format_o.split_rules)\r
+      }\r
+      assert_equal(FIVE_CNT, @format_o.format(GETTYSBURG))\r
+    end\r
+\r
+      # Tests both nobreak and nobreak_regex, since one is only useful\r
+      # with the other.\r
+    def test_nobreak\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert(!@format_o.nobreak)\r
+      assert(@format_o.nobreak_regex.empty?)\r
+      assert_nothing_raised {\r
+        @format_o.nobreak = true\r
+        @format_o.nobreak_regex = { '^this$' => '^continent$' }\r
+        @format_o.columns = 77\r
+      }\r
+      assert(@format_o.nobreak)\r
+      assert_equal({ '^this$' => '^continent$' }, @format_o.nobreak_regex)\r
+      assert_match(/^this continent/,\r
+                   @format_o.format(GETTYSBURG).split("\n")[1])\r
+    end\r
+\r
+    def test_right_align?\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert(!@format_o.right_align?)\r
+      assert_nothing_raised {\r
+        @format_o.format_style = Text::Format::RIGHT_ALIGN\r
+      }\r
+      assert(@format_o.right_align?)\r
+      assert_nothing_raised {\r
+        @format_o.format_style = Text::Format::RIGHT_FILL\r
+      }\r
+      assert(!@format_o.right_align?)\r
+      assert_nothing_raised { @format_o.format_style = Text::Format::JUSTIFY }\r
+      assert(!@format_o.right_align?)\r
+        # The format testing is done in test_format_style\r
+    end\r
+\r
+    def test_right_fill?\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert(!@format_o.right_fill?)\r
+      assert_nothing_raised {\r
+        @format_o.format_style = Text::Format::RIGHT_ALIGN\r
+      }\r
+      assert(!@format_o.right_fill?)\r
+      assert_nothing_raised {\r
+        @format_o.format_style = Text::Format::RIGHT_FILL\r
+      }\r
+      assert(@format_o.right_fill?)\r
+      assert_nothing_raised {\r
+        @format_o.format_style = Text::Format::JUSTIFY\r
+      }\r
+      assert(!@format_o.right_fill?)\r
+        # The format testing is done in test_format_style\r
+    end\r
+\r
+    def test_right_margin\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert_equal(0, @format_o.right_margin)\r
+      assert_nothing_raised { @format_o.right_margin = -3 }\r
+      assert_equal(3, @format_o.right_margin)\r
+      assert_nothing_raised { @format_o.right_margin = "9" }\r
+      assert_equal(9, @format_o.right_margin)\r
+      assert_nothing_raised { @format_o.right_margin = "-2" }\r
+      assert_equal(2, @format_o.right_margin)\r
+      assert_nothing_raised { @format_o.right_margin = 7 }\r
+      assert_equal(7, @format_o.right_margin)\r
+      assert_nothing_raised {\r
+        ft = @format_o.format(GETTYSBURG).split("\n")\r
+        assert_match(/^ {4}Four score.*forth on$/, ft[0])\r
+        assert_match(/^November/, ft[-1])\r
+      }\r
+    end\r
+\r
+    def test_tabstop\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert_equal(8, @format_o.tabstop)\r
+      assert_nothing_raised { @format_o.tabstop = 7 }\r
+      assert_equal(7, @format_o.tabstop)\r
+      assert_nothing_raised { @format_o.tabstop = -3 }\r
+      assert_equal(3, @format_o.tabstop)\r
+      assert_nothing_raised { @format_o.tabstop = "9" }\r
+      assert_equal(9, @format_o.tabstop)\r
+      assert_nothing_raised { @format_o.tabstop = "-2" }\r
+      assert_equal(2, @format_o.tabstop)\r
+    end\r
+\r
+    def test_text\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert_equal([], @format_o.text)\r
+      assert_nothing_raised { @format_o.text = "Test Text" }\r
+      assert_equal("Test Text", @format_o.text)\r
+      assert_nothing_raised { @format_o.text = ["Line 1", "Line 2"] }\r
+      assert_equal(["Line 1", "Line 2"], @format_o.text)\r
+    end\r
+\r
+    def test_s_new\r
+          # new(NilClass) { block }\r
+      assert_nothing_raised do\r
+        @format_o = Text::Format.new {\r
+          self.text = "Test 1, 2, 3"\r
+        }\r
+      end\r
+      assert_equal("Test 1, 2, 3", @format_o.text)\r
+\r
+        # new(Hash Symbols)\r
+      assert_nothing_raised { @format_o = Text::Format.new(:columns => 72) }\r
+      assert_equal(72, @format_o.columns)\r
+\r
+        # new(Hash String)\r
+      assert_nothing_raised { @format_o = Text::Format.new('columns' => 72) }\r
+      assert_equal(72, @format_o.columns)\r
+\r
+        # new(Hash) { block }\r
+      assert_nothing_raised do\r
+        @format_o = Text::Format.new('columns' => 80) {\r
+          self.text = "Test 4, 5, 6"\r
+        }\r
+      end\r
+      assert_equal("Test 4, 5, 6", @format_o.text)\r
+      assert_equal(80, @format_o.columns)\r
+\r
+        # new(Text::Format)\r
+      assert_nothing_raised do\r
+        fo = Text::Format.new(@format_o)\r
+        assert(fo == @format_o)\r
+      end\r
+\r
+        # new(Text::Format) { block }\r
+      assert_nothing_raised do\r
+        fo = Text::Format.new(@format_o) { self.columns = 79 }\r
+        assert(fo != @format_o)\r
+      end\r
+\r
+          # new(String)\r
+      assert_nothing_raised { @format_o = Text::Format.new("Test A, B, C") }\r
+      assert_equal("Test A, B, C", @format_o.text)\r
+\r
+          # new(String) { block }\r
+      assert_nothing_raised do\r
+        @format_o = Text::Format.new("Test X, Y, Z") { self.columns = -5 }\r
+      end\r
+      assert_equal("Test X, Y, Z", @format_o.text)\r
+      assert_equal(5, @format_o.columns)\r
+    end\r
+\r
+    def test_center\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert_nothing_raised do\r
+        ct = @format_o.center(GETTYSBURG.split("\n")).split("\n")\r
+        assert_match(/^    Four score and seven years ago our fathers brought forth on this/, ct[0])\r
+        assert_match(/^                       not perish from the earth./, ct[-3])\r
+      end\r
+    end\r
+\r
+    def test_expand\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert_equal("          ", @format_o.expand("\t  "))\r
+      assert_nothing_raised { @format_o.tabstop = 4 }\r
+      assert_equal("      ", @format_o.expand("\t  "))\r
+    end\r
+\r
+    def test_unexpand\r
+      assert_nothing_raised { @format_o = Text::Format.new }\r
+      assert_equal("\t  ", @format_o.unexpand("          "))\r
+      assert_nothing_raised { @format_o.tabstop = 4 }\r
+      assert_equal("\t  ", @format_o.unexpand("      "))\r
+    end\r
+\r
+    def test_space_only\r
+      assert_equal("", Text::Format.new.format(" "))\r
+      assert_equal("", Text::Format.new.format("\n"))\r
+      assert_equal("", Text::Format.new.format("        "))\r
+      assert_equal("", Text::Format.new.format("    \n"))\r
+      assert_equal("", Text::Format.new.paragraphs("\n"))\r
+      assert_equal("", Text::Format.new.paragraphs(" "))\r
+      assert_equal("", Text::Format.new.paragraphs("        "))\r
+      assert_equal("", Text::Format.new.paragraphs("    \n"))\r
+      assert_equal("", Text::Format.new.paragraphs(["\n"]))\r
+      assert_equal("", Text::Format.new.paragraphs([" "]))\r
+      assert_equal("", Text::Format.new.paragraphs(["        "]))\r
+      assert_equal("", Text::Format.new.paragraphs(["    \n"]))\r
+    end\r
+\r
+    def test_splendiferous\r
+      h = nil\r
+      test = "This is a splendiferous test"\r
+      assert_nothing_raised { @format_o = Text::Format.new(:columns => 6, :left_margin => 0, :indent => 0, :first_indent => 0) }\r
+      assert_match(/^splendiferous$/, @format_o.format(test))\r
+      assert_nothing_raised { @format_o.hard_margins = true }\r
+      assert_match(/^lendif$/, @format_o.format(test))\r
+      assert_nothing_raised { h = Object.new }\r
+      assert_nothing_raised do\r
+        @format_o.split_rules = Text::Format::SPLIT_HYPHENATION\r
+        class << h #:nodoc:\r
+          def hyphenate_to(word, size)\r
+            return ["", word] if size < 2\r
+            [word[0 ... size], word[size .. -1]]\r
+          end\r
+        end\r
+        @format_o.hyphenator = h\r
+      end\r
+      assert_match(/^iferou$/, @format_o.format(test))\r
+      assert_nothing_raised { h = Object.new }\r
+      assert_nothing_raised do\r
+        class << h #:nodoc:\r
+          def hyphenate_to(word, size, formatter)\r
+            return ["", word] if word.size < formatter.columns\r
+            [word[0 ... size], word[size .. -1]]\r
+          end\r
+        end\r
+        @format_o.hyphenator = h\r
+      end\r
+      assert_match(/^ferous$/, @format_o.format(test))\r
+    end\r
+  end\r
+end\r