Sha256: 33419a07618964f4e5e0e254406652f1e941d03089bebc69ca01eff64dd0d209

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

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

require_relative "lib/skin"

class AddTypeBootswatchSkin < Cardio::Migration::Core
  STYLE_INPUT_SEARCH = <<-JSON.strip_heredoc
    {"type": {"codename": ["in", "skin", "bootswatch_skin", "customized_bootswatch_skin"]}, "sort": "name"}
  JSON
  def up
    ensure_card "style: mods", codename: "style_mods",
                               type_id: Card::PointerID
    ensure_card "style: right sidebar", codename: "style_right_sidebar"
    Card::Cache.reset_all

    ensure_card "Bootswatch skin", type_id: Card::CardtypeID,
                                   codename: "bootswatch_skin"
    update_card! %i[style right options], content: STYLE_INPUT_SEARCH
    Card::Cache.reset_all
    change_type_of_skins
  end

  def change_type_of_skins
    Skin.themes.each do |theme_name|
      skin_name = Skin.new(theme_name).skin_name
      puts "updating #{skin_name}"
      card = Card.fetch(skin_name)
      next puts "card not found" unless card
      card.update! type_id: Card::BootswatchSkinID
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
card-mod-bootstrap-0.11.4 db/migrate_core_cards/20180423170283_add_type_bootswatch_skin.rb
card-mod-bootstrap-0.11.3 db/migrate_core_cards/20180423170283_add_type_bootswatch_skin.rb
card-mod-bootstrap-0.11.2 db/migrate_core_cards/20180423170283_add_type_bootswatch_skin.rb
card-mod-bootstrap-0.11.1 db/migrate_core_cards/20180423170283_add_type_bootswatch_skin.rb
card-mod-bootstrap-0.11.0 db/migrate_core_cards/20180423170283_add_type_bootswatch_skin.rb