Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: be7edcd69e
Fetching contributors…

Cannot retrieve contributors at this time

92 lines (71 sloc) 2.369 kb
#
# This file is part of the "jQuery.Syntax" project, and is licensed under the GNU AGPLv3.
#
# See <jquery.syntax.js> for licensing details.
#
# Copyright 2010 Samuel Williams. All rights reserved.
#
require 'stringio'
require 'fileutils'
CACHE_FILE = "jquery.syntax.cache.js"
task :update_aliases do
code = StringIO.new
code.puts "// This file is automatically generated. Any changes may be lost."
code.puts "// The following declarations describes all resources that might be loaded dynamically."
code.puts
code.puts "// Brush Aliases"
Dir["jquery.syntax.brush.*.js"].each do |path|
File.open(path, "r") do |f|
first_line = f.readline
if first_line.match(/^\/\/ brush: (.+?) aliases: (.+)$/)
code.puts "Syntax.alias(#{$1}, #{$2});"
end
end
end
code.puts
code.puts "// CSS Extensions"
Dir["jquery.syntax.*.css"].each do |path|
basename = File.basename(path, ".css")
code.puts "Syntax.styles[#{basename.dump}] = #{path.dump};"
end
File.open(CACHE_FILE, "w") do |f|
f.write(code.string)
end
puts "*** Written updated cache file #{CACHE_FILE} ***"
puts code.string
end
task :clean_css do
Dir.glob(File.join(File.dirname(__FILE__), "jquery.syntax.*.css")) do |path|
FileUtils.rm path, :verbose => true
end
end
task :generate_css, [:theme,:override,:output] => [:clean_css] do |task, arguments|
theme = arguments[:theme] || "clean"
override = arguments[:override] || "master.sass"
output = arguments[:output] || File.dirname(__FILE__)
unless File.directory?(theme)
theme = File.join(File.dirname(__FILE__), "themes", theme)
end
unless File.directory?(theme)
$stderr.puts "Could not find theme #{theme}!"
exit 1
end
unless File.exist?(override)
override = File.join(theme, override)
end
unless File.exist?(override)
$stderr.puts "Could not find master/override #{override} in #{theme}."
end
Dir.glob(File.join(theme, "jquery.syntax.*.sass")) do |sass|
output_path = File.join(output, File.basename(sass, ".sass") + ".css")
puts "sass -I #{theme.dump} --stdin #{output_path}"
IO.popen("sass -I #{theme.dump} --stdin #{output_path}", "w") do |io|
io.puts("@import #{override}")
io.puts("@import #{File.basename(sass)}")
io.close_write
end
end
Rake::Task[:update_aliases].reenable
Rake::Task[:update_aliases].invoke
end
task :default => :update_aliases
Jump to Line
Something went wrong with that request. Please try again.