Sha256: 72229d7d34c68113a3d51e7f2455b38e1d724f9778437eca70ecbeaa83bce495

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

require "active_support"
require "uri/https"
require "open-uri"
require "fileutils"

THEMES = %w[Cerulean Cosmo Cyborg Darkly Flatly Journal Litera Lumen Lux Materia Minty
            Pulse Sandstone Simplex Slate Solar Spacelab Superhero United Yeti]
           .map(&:downcase).freeze

class Theme
  STORE_DIR = File.expand_path("../../db/migrate_core_cards/data/b4_themes", __FILE__).freeze
  BOOTSWATCH_HOST = "bootswatch.com".freeze
  VERSION = "4-alpha"

  def initialize name
    @theme = name
    @store_dir =  File.join STORE_DIR, @theme
    FileUtils.mkdir_p @store_dir
  end

  def store_path filename
    File.join @store_dir, filename
  end

  def uri object
    URI::HTTPS.build host: BOOTSWATCH_HOST, path: "/#{VERSION}/#{@theme}/#{object}"
  end
end

THEMES.each do |theme_name|
  theme = Theme.new theme_name
  %w[_variables.scss _bootswatch.scss thumbnail.png].each do |filename|
    File.open(theme.store_path(filename), "w") do |f|
      puts theme.uri(filename)
      f.puts theme.uri(filename).read
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
card-1.93.3 script/fetch_bootswatch_themes.rb
card-1.93.2 script/fetch_bootswatch_themes.rb
card-1.93.1 script/fetch_bootswatch_themes.rb
card-1.93.0 script/fetch_bootswatch_themes.rb
card-1.92.2 script/fetch_bootswatch_themes.rb
card-1.92.1 script/fetch_bootswatch_themes.rb
card-1.92 script/fetch_bootswatch_themes.rb
card-1.91 script/fetch_bootswatch_themes.rb