<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,7 +4,7 @@ module ActionView
     # Methods are provided for phone numbers, currency, percentage,
     # precision, positional notation, and file size.
     module NumberHelper
-      # Formats a +number+ into a US phone number (e.g., (555) 123-9876). You can customize the format
+      # Formats a +number+ into a phone number (e.g., (555) 123-9876). You can customize the format
       # in the +options+ hash.
       #
       # ==== Options
@@ -13,6 +13,7 @@ module ActionView
       # * &lt;tt&gt;:extension&lt;/tt&gt;  - Specifies an extension to add to the end of the
       #   generated number.
       # * &lt;tt&gt;:country_code&lt;/tt&gt;  - Sets the country code for the phone number.
+      # * &lt;tt&gt;:groupings&lt;/tt&gt;     - Specifies alternate groupings (must specify 3-element array; defaults to [3, 3, 4])
       #
       # ==== Examples
       #  number_to_phone(1235551234)                                        # =&gt; 123-555-1234
@@ -20,6 +21,10 @@ module ActionView
       #  number_to_phone(1235551234, :delimiter =&gt; &quot; &quot;)                     # =&gt; 123 555 1234
       #  number_to_phone(1235551234, :area_code =&gt; true, :extension =&gt; 555) # =&gt; (123) 555-1234 x 555
       #  number_to_phone(1235551234, :country_code =&gt; 1)                    # =&gt; +1-123-555-1234
+      #  number_to_phone('0212345678', :groupings =&gt; [2, 4, 4],
+      #                  :area_code =&gt; true, :delimiter =&gt; &quot; &quot;)             # =&gt; (02) 1234 5678
+      #  number_to_phone('0412345678', :groupings =&gt; [4, 3, 3],
+      #                  :delimiter =&gt; &quot; &quot;)                                 # =&gt; 0412 345 678
       #
       #  number_to_phone(1235551234, :country_code =&gt; 1, :extension =&gt; 1343, :delimiter =&gt; &quot;.&quot;)
       #  =&gt; +1.123.555.1234 x 1343
@@ -30,14 +35,17 @@ module ActionView
         delimiter    = options[:delimiter] || &quot;-&quot;
         extension    = options[:extension].to_s.strip || nil
         country_code = options[:country_code] || nil
+        g1, g2, g3   = options[:groupings] || [3, 3, 4]
+
+        re = Regexp.new(&quot;([0-9]{1,#{g1}})([0-9]{#{g2}})([0-9]{#{g3}})$&quot;)
 
         begin
           str = &quot;&quot;
           str &lt;&lt; &quot;+#{country_code}#{delimiter}&quot; unless country_code.blank?
           str &lt;&lt; if area_code
-            number.gsub!(/([0-9]{1,3})([0-9]{3})([0-9]{4}$)/,&quot;(\\1) \\2#{delimiter}\\3&quot;)
+            number.gsub!(re, &quot;(\\1) \\2#{delimiter}\\3&quot;)
           else
-            number.gsub!(/([0-9]{1,3})([0-9]{3})([0-9]{4})$/,&quot;\\1#{delimiter}\\2#{delimiter}\\3&quot;)
+            number.gsub!(re, &quot;\\1#{delimiter}\\2#{delimiter}\\3&quot;)
           end
           str &lt;&lt; &quot; x #{extension}&quot; unless extension.blank?
           str</diff>
      <filename>actionpack/lib/action_view/helpers/number_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,6 +14,8 @@ class NumberHelperTest &lt; ActionView::TestCase
     assert_equal(&quot;+18005551212&quot;, number_to_phone(8005551212, :country_code =&gt; 1, :delimiter =&gt; ''))
     assert_equal(&quot;22-555-1212&quot;, number_to_phone(225551212))
     assert_equal(&quot;+45-22-555-1212&quot;, number_to_phone(225551212, :country_code =&gt; 45))
+    assert_equal(&quot;(02) 1234 5678&quot;, number_to_phone('0212345678', :area_code =&gt; true, :delimiter =&gt; ' ', :groupings =&gt; [2, 4, 4]))
+    assert_equal(&quot;0412 345 678&quot;, number_to_phone('0412345678', :delimiter =&gt; ' ', :groupings =&gt; [4, 3, 3]))
     assert_equal(&quot;x&quot;, number_to_phone(&quot;x&quot;))
     assert_nil number_to_phone(nil)
   end</diff>
      <filename>actionpack/test/template/number_helper_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a03e2b356c66ddc8809fa2b23a2a7d652f173b8b</id>
    </parent>
  </parents>
  <author>
    <name>Tim Morgan</name>
    <email>tim@timmorgan.org</email>
  </author>
  <url>http://github.com/seven1m/rails/commit/519d85dc528d75463f12fcbff642d23836475645</url>
  <id>519d85dc528d75463f12fcbff642d23836475645</id>
  <committed-date>2008-10-21T20:03:06-07:00</committed-date>
  <authored-date>2008-10-21T20:03:06-07:00</authored-date>
  <message>Add 'groupings' option to number_to_phone helper.</message>
  <tree>8ff8481511d342abae89d9e52440a8c84141c321</tree>
  <committer>
    <name>Tim Morgan</name>
    <email>tim@timmorgan.org</email>
  </committer>
</commit>
