Permalink
Browse files

No commit message

  • Loading branch information...
1 parent 8a59051 commit d6a43bee9d02a972e3c0c08c01bee5a5e4814a73 @jviney jviney committed Oct 3, 2007
Showing with 8 additions and 11 deletions.
  1. +1 −8 CHANGELOG
  2. +1 −1 lib/acts_as_taggable.rb
  3. +4 −2 lib/tag_list.rb
  4. +2 −0 test/tag_list_test.rb
View
@@ -8,7 +8,7 @@
* Remove TagList.parse, use TagList.from instead.
-* Add :parse option to TagList#new and TagList#add.
+* Add :parse option to TagList#new, TagList#add, and TagList#remove.
tag_list = TagList.new("One, Two", :parse => true) # ["One", "Two"]
@@ -35,13 +35,6 @@
* Make the TagList class inherit from Array.
- BACKWARDS INCOMPATIBILITY:
-
- TagList#initialize, TagList#add, and TagList#remove no longer accept array arguments.
-
- Old: TagList.new(["One", "Two"])
- New: TagList.new("One", "Two")
-
* Deprecate obsolete TagList#names.
[6 September 2007]
View
@@ -41,7 +41,7 @@ def find_tagged_with(*args)
end
def find_options_for_find_tagged_with(tags, options = {})
- tags = tags.is_a?(Array) ? TagList.new(*tags.map(&:to_s)) : TagList.from(tags)
+ tags = tags.is_a?(Array) ? TagList.new(tags.map(&:to_s)) : TagList.from(tags)
return {} if tags.empty?
View
@@ -59,8 +59,10 @@ def extract_and_apply_options!(args)
options.assert_valid_keys :parse
if options[:parse]
- args.map! { |a| self.class.from(a) }.flatten!
+ args.map! { |a| self.class.from(a) }
end
+
+ args.flatten!
end
class << self
@@ -76,7 +78,7 @@ def from(string)
string.gsub!(/"(.*?)"\s*#{delimiter}?\s*/) { tag_list << $1; "" }
string.gsub!(/'(.*?)'\s*#{delimiter}?\s*/) { tag_list << $1; "" }
- tag_list.add(*string.split(delimiter))
+ tag_list.add(string.split(delimiter))
end
end
end
View
@@ -77,11 +77,13 @@ def test_add
assert_equal %w(One), tag_list
assert_equal %w(One Two), tag_list.add("Two")
+ assert_equal %w(One Two Three), tag_list.add(["Three"])
end
def test_remove
tag_list = TagList.new("One", "Two")
assert_equal %w(Two), tag_list.remove("One")
+ assert_equal %w(), tag_list.remove(["Two"])
end
def test_new_with_parsing

0 comments on commit d6a43be

Please sign in to comment.