Permalink
Browse files

Options are now set properly and feedback is shown when a file is cha…

…nged.
  • Loading branch information...
1 parent 7aec169 commit 18a5a2b03d704893de4bfb15f98c53fd56cfd06c @hawx hawx committed with thibaudgg Oct 21, 2010
Showing with 11 additions and 23 deletions.
  1. +1 −1 Gemfile.lock
  2. +8 −6 lib/guard/sass.rb
  3. +2 −16 spec/guard/sass_spec.rb
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- guard-sass (1.0.0)
+ guard-sass (0.0.3)
guard (~> 0.1.0)
haml (~> 3.0.0)
View
@@ -6,8 +6,14 @@
module Guard
class Sass < Guard
- VERSION = '0.0.2'
+ VERSION = '0.0.3'
attr_accessor :options
+
+ def initialize(watchers = [], options = {})
+ @watchers, @options = watchers, options
+ @options[:output] ||= 'css'
+ @options[:load_paths] ||= Dir.glob('*')
+ end
# Builds the sass or scss. Determines engine to use by extension
@@ -41,18 +47,14 @@ def get_output(file)
# ================
# = Guard method =
# ================
-
- def start
- @options[:output] = options[:output] || 'css'
- @options[:load_paths] = Dir.glob('*')
- end
# Build the files given
def run_on_change(paths)
paths.each do |file|
unless File.basename(file)[0] == "_"
File.open(get_output(file), 'w') {|f| f.write(build_sass(file)) }
end
+ puts "-> rebuilt #{file}"
end
end
View
@@ -3,26 +3,12 @@
describe Guard::Sass do
subject { Guard::Sass.new }
- describe "start" do
+ describe "initialize" do
it "should set default output path" do
- subject.start
subject.options[:output].should == 'css'
end
end
-
- describe "getting sass files" do
- it "should get the files under the path given" do
- result = subject.get_sass_files(['sass-test/_sass'])
- result.should == ["sass-test/_sass/print.scss", "sass-test/_sass/screen.sass"]
- end
-
- it "should ignore files beginning with an underscore" do
- result = subject.get_sass_files(['sass-test/_sass'])
- result.should_not include "sass-test/_sass/_settings.sass"
- end
- end
-
describe "building sass to css" do
it "should convert sass to css" do
file = "sass-test/_sass/screen.sass"
@@ -73,7 +59,7 @@
it "should change the folder to /css (by default)" do
subject.options[:output] = "css"
r = subject.get_output("sass-test/_sass/screen.scss")
- File.dirname(r).should == "sass-test/css"
+ File.dirname(r).should == "sass-test/_sass/../css"
end
it "should not change the file name" do

0 comments on commit 18a5a2b

Please sign in to comment.