Skip to content

Instantly share code, notes, and snippets.

@mrkurt
Created April 20, 2010 17:07
Show Gist options
  • Save mrkurt/372755 to your computer and use it in GitHub Desktop.
Save mrkurt/372755 to your computer and use it in GitHub Desktop.
#adds tags where categories don't match up
if data.has_key?('categories')
tags = data['tags'] || []
placement_tags = []
data['categories'].values.map{|c| c.split('/')}.flatten.each do |cat|
unless cat.empty? || tags.include?(cat) || placement_tags.include?(cat)
cat = '@' + cat
placement_tags << cat unless tags.include?(cat) || placement_tags.include?(cat)
end
end
data['tags'] = placement_tags + tags
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment