Skip to content

Instantly share code, notes, and snippets.

@tamouse
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamouse/2f6d4be6d979a4ab22ba to your computer and use it in GitHub Desktop.
Save tamouse/2f6d4be6d979a4ab22ba to your computer and use it in GitHub Desktop.
Rake task to update Jekyll repo with new TWBS version
require 'pathname'
require 'erb'
require 'yaml'
require 'active_support/core_ext/hash'
require 'highline/import'
jekyll_config = YAML.load(ERB.new(File.read('_config.yml')).result).deep_symbolize_keys
ROOTDIR = Pathname(File.expand_path("../", __FILE__))
PUBLICDIR = ROOTDIR.join(jekyll_config.fetch(:destination, '_site'))
SOURCEDIR = ROOTDIR.join(jekyll_config.fetch(:source, '.'))
SASSDIR = ROOTDIR.join(SOURCEDIR, jekyll_config.fetch(:sass,'_sass'))
TMPDIR = ROOTDIR.join('tmp')
def bootstrap_remote(version)
"https://github.com/twbs/bootstrap-sass/archive/v#{version}.tar.gz"
end
def bootstrap_archive(version)
"v#{version}.tar.gz"
end
def bootstrap_archive_dir(version)
"bootstrap-sass-#{version}"
end
namespace :bootstrap do
desc "Update Bootstrap Version"
task :update, :version do |t, args|
version = args.version || ask("Bootstrap Version? ") {|q| q.default = '3.2.0'}
cd TMPDIR do
sh "wget #{bootstrap_remote(version)}"
sh "tar zxvf #{bootstrap_archive(version)}"
end
assets = TMPDIR.join(bootstrap_archive_dir(version), "assets")
cd SASSDIR.join("bootstrap") do
rm_rf "*"
cp_r assets.join("stylesheets").children, "."
end
cd SOURCEDIR.join("javascripts") do
rm_rf "bootstrap*"
cp_r assets.join("javascripts").children, "."
end
cd SOURCEDIR.join("fonts") do
rm_rf "bootstrap"
cp_r assets.join("fonts/bootstrap"), "."
end
end
end

Let's say you have a Jekyll site that you are using bootstrap-sass on, and you want to update to a new version.

This rake task will pull in the new version, unpack it, and move things into the appropriate locations, based on your _config.yml file.

touche

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment