Permalink
Browse files

Documented (and tested) that delimiter can be a regexp.

  • Loading branch information...
1 parent ca28a1c commit d0f4eacf2d84c1fe2c6cca52f59f671344c99753 @eostrom eostrom committed Sep 8, 2009
Showing with 21 additions and 0 deletions.
  1. +11 −0 README.rdoc
  2. +10 −0 test/is_taggable_test.rb
View
@@ -41,6 +41,17 @@ You can also specify an output delimiter:
This example formats the list using standard punctuation and spacing, but doesn't require it from user input.
+The delimiter can be a regular expression, in which case an output delimiter is necessary:
+
+ IsTaggable::TagList.delimiter = /[, ]/
+ IsTaggable::TagList.output_delimiter = " "
+ u = User.create :language_list => "english, french"
+ u.language_list.to_s # => "english french"
+ u = User.create :language_list => "english french"
+ u.language_list.to_s # => "english french"
+
+In this example, your users can include commas (which will be ignored) or not.
+
== Get it
$ sudo gem install is_taggable
View
@@ -68,6 +68,16 @@
output
end
+ expect "english french german" do
+ IsTaggable::TagList.delimiter = /[, ]/
+ IsTaggable::TagList.output_delimiter = ' '
+ p = Post.new :language_list => "english,french, german"
+ output = p.language_list.to_s
+ IsTaggable::TagList.delimiter = ','
+ IsTaggable::TagList.output_delimiter = nil
+ output
+ end
+
# added - should clean up strings with arbitrary spaces around commas
expect ["spaces","should","not","matter"] do
p = Post.new

0 comments on commit d0f4eac

Please sign in to comment.