Made the 'rake examples' task use the command line tool instead of using custom code for compiling the examples.
3
.gitignore
vendored
@ -1,6 +1,7 @@
|
|||||||
*.DS_Store
|
*.DS_Store
|
||||||
tmp/*
|
tmp/*
|
||||||
built_examples/*
|
examples/*/stylesheets/*
|
||||||
|
examples/*/*.html
|
||||||
test/tmp
|
test/tmp
|
||||||
test/fixtures/stylesheets/*/tmp
|
test/fixtures/stylesheets/*/tmp
|
||||||
test/fixtures/stylesheets/*/saved
|
test/fixtures/stylesheets/*/saved
|
||||||
|
45
Rakefile
@ -63,49 +63,22 @@ task :examples do
|
|||||||
require 'haml'
|
require 'haml'
|
||||||
require 'sass'
|
require 'sass'
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
|
require 'lib/compass'
|
||||||
|
require 'lib/compass/exec'
|
||||||
FileList['examples/*'].each do |example|
|
FileList['examples/*'].each do |example|
|
||||||
puts "Compiling #{example} -> built_examples/#{example.sub(%r{.*/},'')}"
|
puts "\nCompiling #{example}"
|
||||||
|
puts "=" * "Compiling #{example}".length
|
||||||
# compile any haml templates to html
|
# compile any haml templates to html
|
||||||
FileList["#{example}/*.haml"].each do |haml_file|
|
FileList["#{example}/*.haml"].each do |haml_file|
|
||||||
basename = haml_file[9..-6]
|
basename = haml_file[0..-6]
|
||||||
engine = Haml::Engine.new(open(haml_file).read, :filename => haml_file)
|
engine = Haml::Engine.new(open(haml_file).read, :filename => haml_file)
|
||||||
target_dir = "built_examples/#{basename.sub(%r{/[^/]*$},'')}"
|
puts " haml #{File.basename(basename)}"
|
||||||
FileUtils.mkdir_p(target_dir)
|
output = open(basename,'w')
|
||||||
output = open("built_examples/#{basename}",'w')
|
|
||||||
output.write(engine.render)
|
output.write(engine.render)
|
||||||
output.close
|
output.close
|
||||||
end
|
end
|
||||||
# compile any sass templates to css
|
Dir.chdir example do
|
||||||
FileList["#{example}/stylesheets/**/[^_]*.sass"].each do |sass_file|
|
Compass::Exec::Compass.new([]).run!
|
||||||
basename = sass_file[9..-6]
|
|
||||||
css_filename = "built_examples/#{basename}.css"
|
|
||||||
compass_sass = File.dirname(__FILE__).sub(%r{.*/},'')
|
|
||||||
engine = Sass::Engine.new(open(sass_file).read,
|
|
||||||
:filename => sass_file,
|
|
||||||
:line_comments => true,
|
|
||||||
:css_filename => css_filename,
|
|
||||||
:load_paths => ["#{example}/stylesheets"] + Compass::Frameworks::ALL.map{|f| f.stylesheets_directory})
|
|
||||||
target_dir = "built_examples/#{basename.sub(%r{/[^/]*$},'')}"
|
|
||||||
FileUtils.mkdir_p(target_dir)
|
|
||||||
output = open(css_filename,'w')
|
|
||||||
output.write(engine.render)
|
|
||||||
output.close
|
|
||||||
end
|
|
||||||
# copy any other non-haml and non-sass files directly over
|
|
||||||
target_dir = "built_examples/#{example.sub(%r{.*/},'')}"
|
|
||||||
other_files = FileList["#{example}/**/*"]
|
|
||||||
other_files.exclude "**/*.sass", "**/*.haml"
|
|
||||||
other_files.each do |file|
|
|
||||||
|
|
||||||
if File.directory?(file)
|
|
||||||
FileUtils.mkdir_p(file)
|
|
||||||
elsif File.file?(file)
|
|
||||||
target_file = "#{target_dir}/#{file[(example.size+1)..-1]}"
|
|
||||||
# puts "mkdir -p #{File.dirname(target_file)}"
|
|
||||||
FileUtils.mkdir_p(File.dirname(target_file))
|
|
||||||
# puts "cp #{file} #{target_file}"
|
|
||||||
FileUtils.cp(file, target_file)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Before Width: | Height: | Size: 206 B After Width: | Height: | Size: 206 B |
Before Width: | Height: | Size: 206 B After Width: | Height: | Size: 206 B |
Before Width: | Height: | Size: 206 B After Width: | Height: | Size: 206 B |
Before Width: | Height: | Size: 51 B After Width: | Height: | Size: 51 B |