guard-sass 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -23,27 +23,44 @@ And finally add a basic setup to your Guardfile with:
23
23
 
24
24
  ```ruby
25
25
  guard 'sass' do
26
- watch(%r{^sass/.+\.s[ac]ss})
26
+ watch(%r{^sass/(.+\.s[ac]ss)})
27
27
  end
28
28
  ```
29
29
 
30
- Defaults to writing to 'css/' but this can be changed....
30
+ Defaults to writing to 'css/' but this can be changed by setting the output option
31
31
 
32
32
  ```ruby
33
33
  guard 'sass', :output => 'styles' do
34
- watch(%r{^sass/.+\.s[ac]ss})
34
+ watch(%r{^sass/(.+\.s[ac]ss)})
35
35
  end
36
36
  ```
37
37
 
38
+ By default a file such as `sass/forms/buttons.sass` with the above guard file would be
39
+ output to `styles/forms/buttons.css` because `forms` would be matched with the parentheses.
40
+ This can be disabled by passing `:shallow => true` so that it would be written to
41
+ `styles/buttons.css` instead.
42
+
38
43
  guard-sass also has a short notation like [guard-coffeescript][gcs], this let's you define
39
44
  an input folder (with an optional output folder) and the watcher is defined for you.
40
45
 
41
46
  ```ruby
42
- guard 'sass', :input => 'sass', :output => 'css'
47
+ guard 'sass', :input => 'sass', :output => 'styles'
43
48
  # or
44
49
  guard 'sass', :input => 'stylesheets'
45
50
  ```
46
51
 
52
+ These are equivelant to
53
+
54
+ ```ruby
55
+ guard 'sass', :output => 'styles' do
56
+ watch %r{^sass/(.+\.s[ac]ss)$}
57
+ end
58
+
59
+ guard 'sass' do
60
+ watch %r{^stylesheets/(.+\.s[ac]ss)$}
61
+ end
62
+ ```
63
+
47
64
 
48
65
  ## Options
49
66
 
@@ -52,6 +69,8 @@ guard 'sass', :input => 'stylesheets'
52
69
  :output => 'css' # Relative path to the output directory
53
70
  :notification => false # Whether to display notifications after finished,
54
71
  # default: true
72
+ :shallow => true # Whether to output nested directories or just put css
73
+ # directly in output folder, default: false
55
74
  :load_paths => ['sass/partials'] # Paths for sass to find imported sass files from,
56
75
  # default: all directories under current
57
76
  ```
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  class SassVersion
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
data/lib/guard/sass.rb CHANGED
@@ -8,15 +8,16 @@ module Guard
8
8
  class Sass < Guard
9
9
 
10
10
  DEFAULTS = {
11
- :output => 'css',
12
- :notification => true,
11
+ :output => 'css', # Output directory
12
+ :notification => true, # Enable notifications?
13
+ :shallow => false, # Output nested directories?
13
14
  :load_paths => Dir.glob('**/**').find_all {|i| File.directory?(i) }
14
15
  }
15
16
 
16
17
  def initialize(watchers = [], options = {})
17
18
  if options[:input]
18
19
  options[:output] = options[:input] unless options.has_key?(:output)
19
- watchers << ::Guard::Watcher.new(%r{^#{options.delete(:input)}/.+\.s[ac]ss$})
20
+ watchers << ::Guard::Watcher.new(%r{^#{options.delete(:input)}/(.+\.s[ac]ss)$})
20
21
  end
21
22
 
22
23
  super(watchers, DEFAULTS.merge(options))
@@ -45,6 +46,18 @@ module Guard
45
46
  #
46
47
  def get_output(file)
47
48
  folder = File.join ::Guard.listener.directory, options[:output]
49
+
50
+ unless options[:shallow]
51
+ watchers.product([file]).each do |watcher, file|
52
+ if matches = file.match(watcher.pattern)
53
+ if matches[1]
54
+ folder = File.join(::Guard.listener.directory, options[:output], File.dirname(matches[1])).gsub(/\/\.$/, '')
55
+ break
56
+ end
57
+ end
58
+ end
59
+ end
60
+
48
61
  FileUtils.mkdir_p folder
49
62
  r = File.join folder, File.basename(file).split('.')[0]
50
63
  r << '.css'
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.2.0
4
+ version: 0.2.1
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-06-17 00:00:00.000000000 +01:00
12
+ date: 2011-06-18 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: &2156091280 !ruby/object:Gem::Requirement
17
+ requirement: &2151905780 !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: *2156091280
25
+ version_requirements: *2151905780
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: sass
28
- requirement: &2156090820 !ruby/object:Gem::Requirement
28
+ requirement: &2151905220 !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: *2156090820
36
+ version_requirements: *2151905220
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bundler
39
- requirement: &2156090360 !ruby/object:Gem::Requirement
39
+ requirement: &2151904520 !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: *2156090360
47
+ version_requirements: *2151904520
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rspec
50
- requirement: &2156089900 !ruby/object:Gem::Requirement
50
+ requirement: &2151903980 !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: *2156089900
58
+ version_requirements: *2151903980
59
59
  description: Guard::Sass automatically rebuilds sass (like sass --watch)
60
60
  email:
61
61
  - m@hawx.me