simplified regexps
This commit is contained in:
@@ -225,7 +225,7 @@ class Post < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def remove_favorite(user)
|
||||
self.fav_string.gsub!(/fav:#{user.name}\b\s*/, " ")
|
||||
self.fav_string.gsub!(/(?:\A| )fav:#{user.name}(?:\Z| )/, " ")
|
||||
self.fav_string.strip!
|
||||
Favorite.destroy(user, self)
|
||||
end
|
||||
@@ -454,7 +454,7 @@ class Post < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def remove_pool(pool)
|
||||
self.pool_string.gsub!(/pool:#{pool.name}\b\s*/, " ")
|
||||
self.pool_string.gsub!(/(?:\A| )pool:#{pool.name}(?:\Z| )/, " ")
|
||||
self.pool_string.strip!
|
||||
end
|
||||
end
|
||||
|
||||
@@ -40,7 +40,7 @@ class TagAlias < ActiveRecord::Base
|
||||
def update_posts
|
||||
Post.find_by_tags(antecedent_name).find_each do |post|
|
||||
escaped_antecedent_name = Regexp.escape(antecedent_name)
|
||||
fixed_tags = post.tag_string.sub(/\A#{escaped_antecedent_name} | #{escaped_antecedent_name} | #{escaped_antecedent_name}\Z/, " #{consequent_name} ").strip
|
||||
fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{consequent_name} ").strip
|
||||
post.update_attributes(
|
||||
:tag_string => fixed_tags,
|
||||
:updater_id => updater_id,
|
||||
|
||||
@@ -69,7 +69,7 @@ class TagImplication < ActiveRecord::Base
|
||||
def update_posts
|
||||
Post.find_by_tags(antecedent_name).find_each do |post|
|
||||
escaped_antecedent_name = Regexp.escape(antecedent_name)
|
||||
fixed_tags = post.tag_string.sub(/\A#{escaped_antecedent_name} | #{escaped_antecedent_name} | #{escaped_antecedent_name}\Z/, " #{antecedent_name} #{descendant_names} ").strip
|
||||
fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{antecedent_name} #{descendant_names} ").strip
|
||||
post.update_attributes(
|
||||
:tag_string => fixed_tags,
|
||||
:updater_id => updater_id,
|
||||
|
||||
Reference in New Issue
Block a user