-
Notifications
You must be signed in to change notification settings - Fork 0
/
sass.rb
executable file
·46 lines (39 loc) · 912 Bytes
/
sass.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env ruby
require "rubygems"
require "sass/plugin"
require "find"
$default_base_dir = "static"
def get_template_locations(base_dir)
result = {}
Find.find(base_dir) do |path|
if FileTest.directory?(path)
if path.end_with?("css/sass")
result[path] = path.chomp("/sass")
Find.prune
else
next
end
end
end
result
end
def compiler
@compiler ||= Sass::Plugin::Compiler.new(:syntax => :scss).tap do |c|
c.options[:template_location] = get_template_locations($default_base_dir)
c.on_updated_stylesheet do |template, css|
puts template
end
puts c.options[:template_location].keys
puts
end
end
case ARGV[0]
when 'watch'
puts "Watching for changes in:"
compiler.watch
when 'build'
puts "Building stylesheets in:"
compiler.update_stylesheets
else
puts "usage: #{File.basename($0)} [ build | watch ]"
end