Sha256: b7441271fa3b2a8ecb9048de29ea50dbd66e549381a05afc5e91d046991d3c7e
Contents?: true
Size: 1018 Bytes
Versions: 14
Compression:
Stored size: 1018 Bytes
Contents
# -*- encoding : utf-8 -*- class SearchCardContext < Card::Migration::Core def up sep = /\W/ replace = [ ["[lr]+", 'l\\1'], ["[LR]+", 'L\\1'], ["(?=[LR]*[lr]+)(?=[lr]*[LR]+)[lrLR]+", 'l\\1'], # mix of lowercase and uppercase l's and r's %w(left LL), %w(right LR), %w(self left), ["", "left"] ] Card.search(type_id: ["in", Card::SearchTypeID, Card::SetID]).each do |card| next unless card.cardname.junction? && card.real? content = card.content replace.each do |key, val| content.gsub!(/(#{sep})_(#{key})(?=#{sep})/, "\\1_#{val}") end card.update_column :db_content, content card.actions.each do |action| next unless (content_change = action.change :db_content) content = content_change.value replace.each do |key, val| content.gsub!(/(#{sep})_(#{key})(?=#{sep})/, "\\1_#{val}") end content_change.update_column :value, content end end end end
Version data entries
14 entries across 14 versions & 1 rubygems