Sha256: 0b91dd46e184a498f8108b3acd4915fa0580bfc95c00a92715de1ac46f5581e8

Contents?: true

Size: 1011 Bytes

Versions: 9

Compression:

Stored size: 1011 Bytes

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_by": "name"
    }
  JSON

  def up
    Card.ensure name: "style: mods", codename: "style_mods", type: :pointer
    Card.ensure name: "style: right sidebar", codename: "style_right_sidebar"
    Card::Cache.reset_all

    Card.ensure name: "Bootswatch skin", type: :cardtype, 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

9 entries across 9 versions & 1 rubygems

Version Path
card-mod-bootstrap-0.15.6 db/migrate_core_cards/20180423170283_add_type_bootswatch_skin.rb
card-mod-bootstrap-0.15.5 db/migrate_core_cards/20180423170283_add_type_bootswatch_skin.rb
card-mod-bootstrap-0.15.4 db/migrate_core_cards/20180423170283_add_type_bootswatch_skin.rb
card-mod-bootstrap-0.15.3 db/migrate_core_cards/20180423170283_add_type_bootswatch_skin.rb
card-mod-bootstrap-0.15.1.2 db/migrate_core_cards/20180423170283_add_type_bootswatch_skin.rb
card-mod-bootstrap-0.15.2.pre1 db/migrate_core_cards/20180423170283_add_type_bootswatch_skin.rb
card-mod-bootstrap-0.15.1.1 db/migrate_core_cards/20180423170283_add_type_bootswatch_skin.rb
card-mod-bootstrap-0.15.1 db/migrate_core_cards/20180423170283_add_type_bootswatch_skin.rb
card-mod-bootstrap-0.15.0 db/migrate_core_cards/20180423170283_add_type_bootswatch_skin.rb