Sha256: f7e05eeeadd2d319a6d0c0ea6904093f280213c58474396c46e63e98260a33e3

Contents?: true

Size: 816 Bytes

Versions: 13

Compression:

Stored size: 816 Bytes

Contents

# -*- encoding : utf-8 -*-

class FixModFiles < Card::Migration::Core
  def up
    Card.search(type: "image").each do |card|
      next unless card.coded?
      next unless card.content.include?("05_standard") ||
                  card.content.include?("06_bootstrap")
      new_content = card.content.sub("05_standard", "standard")
                        .sub("06_bootstrap", "bootstrap")
      card.update_column :db_content, new_content

      update_history card
    end
  end

  def update_history card
    card.actions.each do |action|
      next unless (content_change = action.change(:db_content))
      new_value = content_change.value.gsub("05_standard", "standard")
                                .gsub("06_bootstrap", "bootstrap")
      content_change.update_column :value, new_value
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
card-1.92.2 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.92.1 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.92 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.91 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.21.0 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.20.4 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.20.3 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.20.2 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.20.1 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.20.0 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.19.6 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.19.5 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.19.4 db/migrate_core_cards/20160914132636_fix_mod_files.rb