Sha256: d91865e1e4d51e04747b96061387a04c253e7ada5881e92b8229eeb310ef076f

Contents?: true

Size: 834 Bytes

Versions: 4

Compression:

Stored size: 834 Bytes

Contents

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

class FixModFiles < Cardio::Migration::Transform
  def up
    Card.search(type: "image").each do |card|
      next unless card.coded?
      next unless card.db_content.include?("05_standard") ||
                  card.db_content.include?("06_bootstrap")

      new_content = card.db_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

4 entries across 4 versions & 1 rubygems

Version Path
card-1.108.1 mod/core/data/transform/20160914132636_fix_mod_files.rb
card-1.108.0 mod/core/data/transform/20160914132636_fix_mod_files.rb
card-1.107.0 mod/core/data/transform/20160914132636_fix_mod_files.rb
card-1.106.0 mod/core/data/transform/20160914132636_fix_mod_files.rb