guard-sass 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Guard-Sass
2
2
 
3
+ guard-sass compiles your sass (and scss) files automatically when changed.
4
+
3
5
  ## Install
4
6
 
5
- You will need to have [guard](http://github.com/guard/guard) to contine, so install it now!.
7
+ You will need to have [guard](http://github.com/guard/guard) to continue, so install it now!.
6
8
 
7
9
  Install the gem with:
8
10
 
@@ -19,20 +21,47 @@ And finally add a basic setup to your Guardfile with:
19
21
 
20
22
  ## Usage
21
23
 
22
- A guard extension that allows you to easily rebuild .sass (or .scss) files when changed.
23
-
24
- guard 'sass' do
25
- watch(%r{^sass/(.*)})
26
- end
24
+ ```ruby
25
+ guard 'sass' do
26
+ watch(%r{^sass/.+\.s[ac]ss})
27
+ end
28
+ ```
27
29
 
28
30
  Defaults to writing to 'css/' but this can be changed....
29
31
 
30
- guard 'sass', :output => 'styles' do
31
- watch(%r{^sass/(.*)})
32
- end
32
+ ```ruby
33
+ guard 'sass', :output => 'styles' do
34
+ watch(%r{^sass/.+\.s[ac]ss})
35
+ end
36
+ ```
37
+
38
+ guard-sass also has a short notation like [guard-coffeescript][gcs], this let's you define
39
+ an input folder (with an optional output folder) and the watcher is defined for you.
40
+
41
+ ```ruby
42
+ guard 'sass', :input => 'sass', :output => 'css'
43
+ # or
44
+ guard 'sass', :input => 'stylesheets'
45
+ ```
46
+
47
+
48
+ ## Options
49
+
50
+ ```ruby
51
+ :input => 'sass' # Relative path to the input directory
52
+ :output => 'css' # Relative path to the output directory
53
+ :notification => false # Whether to display notifications after finished,
54
+ # default: true
55
+ :load_paths => ['sass/partials'] # Paths for sass to find imported sass files from,
56
+ # default: all directories under current
57
+ ```
33
58
 
34
59
 
35
60
  ## Contributors
36
61
 
37
62
  - snappycode (http://github.com/snappycode)
38
- - sauliusg (http://github.com/sauliusg)
63
+ - sauliusg (http://github.com/sauliusg)
64
+
65
+
66
+
67
+ [gcs]: http://github.com/netzpirat/guard-coffeescript "guard-coffeescript"
@@ -1,8 +1 @@
1
- guard 'sass' do
2
- watch(%r{^sass/.+\.s[ac]ss})
3
- end
4
-
5
- # # Optionally set output directory, defaults to 'css'
6
- # guard 'sass', :output => 'public/css' do
7
- # watch(%r{^sass/.+\.s[ac]ss})
8
- # end
1
+ guard 'sass', :input => 'sass', :output => 'css'
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  class SassVersion
3
- VERSION = '0.1.3'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
data/lib/guard/sass.rb CHANGED
@@ -7,14 +7,19 @@ require 'sass'
7
7
  module Guard
8
8
  class Sass < Guard
9
9
 
10
- attr_accessor :options
10
+ DEFAULTS = {
11
+ :output => 'css',
12
+ :notification => true,
13
+ :load_paths => Dir.glob('**/**').find_all {|i| File.directory?(i) }
14
+ }
11
15
 
12
16
  def initialize(watchers = [], options = {})
13
- super(watchers, {
14
- :output => 'css',
15
- :notifications => true,
16
- :load_paths => Dir.glob('**/**').find_all {|i| File.directory?(i)}
17
- }.merge(options))
17
+ if options[:input]
18
+ options[:output] = options[:input] unless options.has_key?(:output)
19
+ watchers << ::Guard::Watcher.new(%r{^#{options.delete(:input)}/.+\.s[ac]ss$})
20
+ end
21
+
22
+ super(watchers, DEFAULTS.merge(options))
18
23
  end
19
24
 
20
25
 
@@ -28,7 +33,7 @@ module Guard
28
33
  content = File.new(file).read
29
34
  # sass or scss?
30
35
  type = file[-4..-1].to_sym
31
- engine = ::Sass::Engine.new(content, {:syntax => type, :load_paths => @options[:load_paths]})
36
+ engine = ::Sass::Engine.new(content, {:syntax => type, :load_paths => options[:load_paths]})
32
37
  engine.render
33
38
  end
34
39
 
@@ -39,7 +44,7 @@ module Guard
39
44
  # @return [String] path to file where output should be written
40
45
  #
41
46
  def get_output(file)
42
- folder = File.join File.dirname(file), '..', @options[:output]
47
+ folder = File.join ::Guard.listener.directory, options[:output]
43
48
  FileUtils.mkdir_p folder
44
49
  r = File.join folder, File.basename(file).split('.')[0]
45
50
  r << '.css'
@@ -62,11 +67,11 @@ module Guard
62
67
  begin
63
68
  File.open(css_file, 'w') {|f| f.write(build_sass(file)) }
64
69
  ::Guard::UI.info "-> rebuilt #{file}", :reset => true
65
- ::Guard::Notifier.notify("rebuilt #{file}", :title => "Guard::Sass", :image => :success) if @options[:notifications]
70
+ ::Guard::Notifier.notify("rebuilt #{file}", :title => "Guard::Sass", :image => :success) if options[:notification]
66
71
  css_file
67
72
  rescue ::Sass::SyntaxError => e
68
73
  ::Guard::UI.error "Sass > #{e.sass_backtrace_str(file)}"
69
- ::Guard::Notifier.notify("rebuild failed > #{e.sass_backtrace_str(file)}", :title => "Guard::Sass", :image => :error) if @options[:notifications]
74
+ ::Guard::Notifier.notify("rebuild failed > #{e.sass_backtrace_str(file)}", :title => "Guard::Sass", :image => :error) if options[:notification]
70
75
  nil
71
76
  end
72
77
  end.compact
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-sass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-05-31 00:00:00.000000000 +01:00
12
+ date: 2011-06-17 00:00:00.000000000 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: guard
17
- requirement: &2152584000 !ruby/object:Gem::Requirement
17
+ requirement: &2156091280 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.2.1
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2152584000
25
+ version_requirements: *2156091280
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: sass
28
- requirement: &2152583540 !ruby/object:Gem::Requirement
28
+ requirement: &2156090820 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '3.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2152583540
36
+ version_requirements: *2156090820
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bundler
39
- requirement: &2152583080 !ruby/object:Gem::Requirement
39
+ requirement: &2156090360 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.0.2
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2152583080
47
+ version_requirements: *2156090360
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rspec
50
- requirement: &2152582620 !ruby/object:Gem::Requirement
50
+ requirement: &2156089900 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>'
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: 2.0.0.rc
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2152582620
58
+ version_requirements: *2156089900
59
59
  description: Guard::Sass automatically rebuilds sass (like sass --watch)
60
60
  email:
61
61
  - m@hawx.me