guard-sass 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +1 -1
- data/README.md +34 -30
- data/lib/guard/sass/runner.rb +25 -24
- data/lib/guard/sass/version.rb +1 -1
- data/lib/guard/sass.rb +43 -34
- metadata +33 -14
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# Guard-Sass
|
2
2
|
|
3
|
-
guard-sass compiles or validates your sass (and scss) files automatically when
|
3
|
+
guard-sass compiles or validates your sass (and scss) files automatically when
|
4
4
|
changed.
|
5
5
|
|
6
6
|
|
7
7
|
## Install
|
8
8
|
|
9
|
-
You will need to have [guard](http://github.com/guard/guard) to continue, so
|
9
|
+
You will need to have [guard](http://github.com/guard/guard) to continue, so
|
10
10
|
install it now!
|
11
11
|
|
12
12
|
Install the gem with:
|
@@ -44,22 +44,22 @@ If your output directory is the same as the input directory, you can simply skip
|
|
44
44
|
|
45
45
|
### Rails App With the Asset Pipeline
|
46
46
|
|
47
|
-
With the introduction of the [asset pipeline][rpipe] in Rails 3.1 there is no
|
48
|
-
need to compile your Sass stylesheets with this Guard. However, if you would
|
49
|
-
still like to have feedback on the validation of your stylesheets (preferably
|
50
|
-
with a Growl notification) directly after you save a change, then you can still
|
47
|
+
With the introduction of the [asset pipeline][rpipe] in Rails 3.1 there is no
|
48
|
+
need to compile your Sass stylesheets with this Guard. However, if you would
|
49
|
+
still like to have feedback on the validation of your stylesheets (preferably
|
50
|
+
with a Growl notification) directly after you save a change, then you can still
|
51
51
|
use this Guard and simply skip generation of the output file:
|
52
52
|
|
53
53
|
guard 'sass', :input => 'app/assets/stylesheets', :noop => true
|
54
54
|
|
55
|
-
This gives you (almost) immediate feedback on whether the changes made are valid,
|
56
|
-
and is much faster than making a subsequent request to your Rails application.
|
57
|
-
If you just want to be notified when an error occurs you can hide the success
|
55
|
+
This gives you (almost) immediate feedback on whether the changes made are valid,
|
56
|
+
and is much faster than making a subsequent request to your Rails application.
|
57
|
+
If you just want to be notified when an error occurs you can hide the success
|
58
58
|
compilation message:
|
59
59
|
|
60
|
-
guard 'sass',
|
61
|
-
:input => 'app/assets/stylesheets',
|
62
|
-
:noop => true,
|
60
|
+
guard 'sass',
|
61
|
+
:input => 'app/assets/stylesheets',
|
62
|
+
:noop => true,
|
63
63
|
:hide_success => true
|
64
64
|
|
65
65
|
### Rails App Without the Asset Pipeline
|
@@ -85,32 +85,36 @@ The following options can be passed to guard-sass:
|
|
85
85
|
:input => 'sass' # Relative path to the input directory.
|
86
86
|
# A suffix `/(.+\.s[ac]ss)` will be added to this option.
|
87
87
|
# default: nil
|
88
|
-
|
88
|
+
|
89
89
|
:output => 'stylesheets' # Relative path to the output directory.
|
90
90
|
# default: 'css' or the :input option when supplied
|
91
|
-
|
91
|
+
|
92
92
|
:all_on_start => true # Compiles all sass files on start
|
93
93
|
# default: false
|
94
|
-
|
94
|
+
|
95
95
|
:extension => '' # Extension used for written files.
|
96
96
|
# default: '.css'
|
97
|
-
|
97
|
+
|
98
98
|
:hide_success => true # Disable successful compilation messages.
|
99
99
|
# default: false
|
100
|
-
|
100
|
+
|
101
101
|
:shallow => true # Do not create nested output directories.
|
102
102
|
# default: false
|
103
|
-
|
104
|
-
:style => :nested # Controls the output style. Accepted options are :nested,
|
103
|
+
|
104
|
+
:style => :nested # Controls the output style. Accepted options are :nested,
|
105
105
|
# :compact, :compressed and :expanded
|
106
106
|
# default: :nested
|
107
|
-
|
107
|
+
|
108
108
|
:load_paths => ['sass/partials'] # Paths for sass to find imported sass files from.
|
109
|
-
# default:
|
110
|
-
|
109
|
+
# default: template locations provided by the sass gem
|
110
|
+
|
111
111
|
:noop => true # No operation: Do not write output file
|
112
112
|
# default: false
|
113
|
-
|
113
|
+
|
114
|
+
:line_numbers => true # Add human readable source filname and line number
|
115
|
+
# information as comments.
|
116
|
+
# default: false
|
117
|
+
|
114
118
|
:debug_info => true # File and line number info for FireSass.
|
115
119
|
# default: false
|
116
120
|
|
@@ -129,7 +133,7 @@ These are equivalent to
|
|
129
133
|
guard 'sass', :output => 'styles' do
|
130
134
|
watch %r{^sass/(.+\.s[ac]ss)$}
|
131
135
|
end
|
132
|
-
|
136
|
+
|
133
137
|
guard 'sass' do
|
134
138
|
watch %r{^stylesheets/(.+\.s[ac]ss)$}
|
135
139
|
end
|
@@ -139,7 +143,7 @@ These are equivalent to
|
|
139
143
|
By default the guard detects nested directories and writes files into the output
|
140
144
|
directory with the same structure.
|
141
145
|
|
142
|
-
The Guard detects by default nested directories and creates these within the
|
146
|
+
The Guard detects by default nested directories and creates these within the
|
143
147
|
output directory. The detection is based on the match of the watch regular expression:
|
144
148
|
|
145
149
|
A file
|
@@ -158,10 +162,10 @@ will be compiled to
|
|
158
162
|
|
159
163
|
public/stylesheets/form/button.css
|
160
164
|
|
161
|
-
Note the parenthesis around `.+\.s[ac]ss`. This enables guard-sass to place
|
165
|
+
Note the parenthesis around `.+\.s[ac]ss`. This enables guard-sass to place
|
162
166
|
the full path that was matched inside the parenthesis into the proper output directory.
|
163
167
|
|
164
|
-
This behaviour can be switched off by passing the option `:shallow => true` to the
|
168
|
+
This behaviour can be switched off by passing the option `:shallow => true` to the
|
165
169
|
Guard, so that all stylesheets will be compiled directly to the output directory.
|
166
170
|
So the previous example would have compiled to `public/stylesheets/button.css`.
|
167
171
|
|
@@ -181,7 +185,7 @@ on `#guard` (irc.freenode.net).
|
|
181
185
|
|
182
186
|
Have a look at the [GitHub contributor][contrib] list to see all contributors.
|
183
187
|
|
184
|
-
Since this Guard is very close to [guard-coffeescript][gcs], some features have been
|
188
|
+
Since this Guard is very close to [guard-coffeescript][gcs], some features have been
|
185
189
|
incorporated into guard-sass.
|
186
190
|
|
187
191
|
|
@@ -189,7 +193,7 @@ incorporated into guard-sass.
|
|
189
193
|
|
190
194
|
(The MIT License)
|
191
195
|
|
192
|
-
Copyright (c) 2010 -
|
196
|
+
Copyright (c) 2010 - 2012 Joshua Hawxwell
|
193
197
|
|
194
198
|
Permission is hereby granted, free of charge, to any person obtaining
|
195
199
|
a copy of this software and associated documentation files (the
|
@@ -216,4 +220,4 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
216
220
|
[rpipe]: http://guides.rubyonrails.org/asset_pipeline.html
|
217
221
|
[issues]: http://github.com/hawx/guard-sass/issues
|
218
222
|
[ggroup]: http://groups.google.com/group/guard-dev
|
219
|
-
[contrib]: http://github.com/hawx/guard-sass/contributors
|
223
|
+
[contrib]: http://github.com/hawx/guard-sass/contributors
|
data/lib/guard/sass/runner.rb
CHANGED
@@ -2,11 +2,11 @@ require 'sass'
|
|
2
2
|
|
3
3
|
module Guard
|
4
4
|
class Sass
|
5
|
-
|
5
|
+
|
6
6
|
class Runner
|
7
|
-
|
7
|
+
|
8
8
|
attr_reader :options
|
9
|
-
|
9
|
+
|
10
10
|
# @param watchers [Array<Guard::Watcher>]
|
11
11
|
# @param options [Hash] See Guard::Sass::DEFAULTS for available options
|
12
12
|
def initialize(watchers, options={})
|
@@ -14,14 +14,14 @@ module Guard
|
|
14
14
|
@options = options
|
15
15
|
@formatter = Formatter.new(:hide_success => options[:hide_success])
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
# @param files [Array<String>]
|
19
19
|
# @return [Array<Array,Boolean>]
|
20
20
|
def run(files)
|
21
21
|
changed_files, errors = compile_files(files)
|
22
22
|
[changed_files, errors.empty?]
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
private
|
26
26
|
|
27
27
|
# @param files [Array<String>] Files to compile
|
@@ -30,45 +30,46 @@ module Guard
|
|
30
30
|
def compile_files(files)
|
31
31
|
errors = []
|
32
32
|
changed_files = []
|
33
|
-
|
33
|
+
|
34
34
|
# Assume partials have been checked for previously, so no partials are included here
|
35
|
-
files.each do |file|
|
35
|
+
files.each do |file|
|
36
36
|
begin
|
37
37
|
css_file = write_file(compile(file), get_output_dir(file), file)
|
38
38
|
message = options[:noop] ? "verified #{file}" : "compiled #{file} to #{css_file}"
|
39
39
|
@formatter.success "-> #{message}", :notification => message
|
40
40
|
changed_files << css_file
|
41
|
-
|
41
|
+
|
42
42
|
rescue ::Sass::SyntaxError => e
|
43
43
|
message = (options[:noop] ? 'validation' : 'rebuild') + " of #{file} failed"
|
44
44
|
errors << message
|
45
45
|
@formatter.error "Sass > #{e.sass_backtrace_str(file)}", :notification => message
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
[changed_files.compact, errors]
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
# @param file [String] Path to sass/scss file to compile
|
53
53
|
# @return [String] Compiled css.
|
54
54
|
def compile(file)
|
55
|
-
content = IO.read(
|
56
|
-
|
55
|
+
content = IO.read(file)
|
56
|
+
|
57
57
|
sass_options = {
|
58
|
-
:syntax
|
59
|
-
:load_paths
|
60
|
-
:style
|
61
|
-
:debug_info
|
58
|
+
:syntax => file[-4..-1].to_sym,
|
59
|
+
:load_paths => options[:load_paths],
|
60
|
+
:style => options[:style],
|
61
|
+
:debug_info => options[:debug_info],
|
62
|
+
:line_numbers => options[:line_numbers]
|
62
63
|
}
|
63
|
-
|
64
|
+
|
64
65
|
::Sass::Engine.new(content, sass_options).render
|
65
66
|
end
|
66
|
-
|
67
|
+
|
67
68
|
# @param file [String]
|
68
69
|
# @return [String] Directory to write +file+ to
|
69
70
|
def get_output_dir(file)
|
70
71
|
folder = options[:output]
|
71
|
-
|
72
|
+
|
72
73
|
unless options[:shallow]
|
73
74
|
@watchers.product([file]).each do |watcher, file|
|
74
75
|
if matches = file.match(watcher.pattern)
|
@@ -79,10 +80,10 @@ module Guard
|
|
79
80
|
end
|
80
81
|
end
|
81
82
|
end
|
82
|
-
|
83
|
+
|
83
84
|
folder
|
84
85
|
end
|
85
|
-
|
86
|
+
|
86
87
|
# Write file contents, creating directories where required.
|
87
88
|
#
|
88
89
|
# @param content [String] Contents of the file
|
@@ -96,10 +97,10 @@ module Guard
|
|
96
97
|
FileUtils.mkdir_p(dir)
|
97
98
|
File.open(path, 'w') {|f| f.write(content) }
|
98
99
|
end
|
99
|
-
|
100
|
+
|
100
101
|
path
|
101
102
|
end
|
102
|
-
|
103
|
+
|
103
104
|
end
|
104
105
|
end
|
105
|
-
end
|
106
|
+
end
|
data/lib/guard/sass/version.rb
CHANGED
data/lib/guard/sass.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
+
require 'sass/plugin'
|
2
|
+
|
1
3
|
require 'guard'
|
2
4
|
require 'guard/guard'
|
3
5
|
require 'guard/watcher'
|
4
6
|
|
5
7
|
module Guard
|
6
8
|
class Sass < Guard
|
7
|
-
|
8
|
-
autoload :Runner, 'guard/sass/runner'
|
9
|
-
autoload :Formatter, 'guard/sass/formatter'
|
10
9
|
|
11
10
|
DEFAULTS = {
|
12
11
|
:all_on_start => false,
|
@@ -14,22 +13,25 @@ module Guard
|
|
14
13
|
:extension => '.css',
|
15
14
|
:style => :nested,
|
16
15
|
:shallow => false,
|
16
|
+
:line_numbers => false,
|
17
17
|
:debug_info => false,
|
18
18
|
:noop => false,
|
19
19
|
:hide_success => false,
|
20
|
-
:load_paths =>
|
20
|
+
:load_paths => ::Sass::Plugin.template_location_array.map(&:first)
|
21
21
|
}
|
22
22
|
|
23
23
|
# @param watchers [Array<Guard::Watcher>]
|
24
24
|
# @param options [Hash]
|
25
25
|
# @option options [String] :input
|
26
26
|
# The input directory
|
27
|
-
# @option options [String] :output
|
27
|
+
# @option options [String] :output
|
28
28
|
# The output directory
|
29
29
|
# @option options [Array<String>] :load_paths
|
30
|
-
# List of directories you can @import from
|
31
|
-
# @option options [Boolean] :shallow
|
30
|
+
# List of directories you can @import from
|
31
|
+
# @option options [Boolean] :shallow
|
32
32
|
# Whether to output nested directories
|
33
|
+
# @option options [Boolean] :line_numbers
|
34
|
+
# Whether to output human readable line numbers as comments in the file
|
33
35
|
# @option options [Boolean] :debug_info
|
34
36
|
# Whether to output file and line number info for FireSass
|
35
37
|
# @option options [Boolean] :noop
|
@@ -39,56 +41,56 @@ module Guard
|
|
39
41
|
# @option options [Symbol] :style
|
40
42
|
# See http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#output_style
|
41
43
|
def initialize(watchers=[], options={})
|
44
|
+
load_paths = options.delete(:load_paths) || []
|
45
|
+
|
42
46
|
if options[:input]
|
47
|
+
load_paths << options[:input]
|
43
48
|
options[:output] = options[:input] unless options.has_key?(:output)
|
44
49
|
watchers << ::Guard::Watcher.new(%r{^#{ options.delete(:input) }/(.+\.s[ac]ss)$})
|
45
50
|
end
|
46
|
-
|
51
|
+
|
47
52
|
options = DEFAULTS.merge(options)
|
53
|
+
options[:load_paths] += load_paths
|
54
|
+
|
48
55
|
@runner = Runner.new(watchers, options)
|
49
56
|
super(watchers, options)
|
50
57
|
end
|
51
|
-
|
52
|
-
def partial?(path)
|
53
|
-
File.basename(path)[0,1] == "_"
|
54
|
-
end
|
55
58
|
|
56
59
|
# If option set to run all on start, run all when started.
|
60
|
+
#
|
61
|
+
# @raise [:task_has_failed]
|
57
62
|
def start
|
58
|
-
if options[:all_on_start]
|
59
|
-
run_all
|
60
|
-
end
|
63
|
+
run_all if options[:all_on_start]
|
61
64
|
end
|
62
65
|
|
63
66
|
# Build all files being watched
|
64
67
|
#
|
65
|
-
# @
|
68
|
+
# @raise [:task_has_failed]
|
66
69
|
def run_all
|
67
|
-
|
68
|
-
|
69
|
-
self,
|
70
|
-
Dir.glob(File.join(::Guard.listener.directory, '**', '*.s[ac]ss')).
|
71
|
-
map {|f| f[::Guard.listener.directory.size+1..-1] }.
|
72
|
-
reject {|f| partial?(f) }
|
73
|
-
)
|
74
|
-
)
|
70
|
+
files = Dir.glob('**/*.s[ac]ss').reject {|f| partial?(f) }
|
71
|
+
run_on_changes Watcher.match_files(self, files)
|
75
72
|
end
|
76
|
-
|
73
|
+
|
77
74
|
# Build the files given. If a 'partial' file is found (begins with '_') calls
|
78
75
|
# {#run_all} as we don't know which other files need to use it.
|
79
|
-
#
|
76
|
+
#
|
80
77
|
# @param paths [Array<String>]
|
81
|
-
# @
|
82
|
-
def
|
83
|
-
|
84
|
-
|
85
|
-
|
78
|
+
# @raise [:task_has_failed]
|
79
|
+
def run_on_changes(paths)
|
80
|
+
return run_all if paths.any? {|f| partial?(f) }
|
81
|
+
|
86
82
|
changed_files, success = @runner.run(paths)
|
87
|
-
|
88
83
|
notify changed_files
|
89
|
-
|
84
|
+
|
85
|
+
throw :task_has_failed unless success
|
86
|
+
end
|
87
|
+
|
88
|
+
# Restore previous behaviour, when a file is removed we don't want to call
|
89
|
+
# {#run_on_changes}.
|
90
|
+
def run_on_removals(paths)
|
91
|
+
|
90
92
|
end
|
91
|
-
|
93
|
+
|
92
94
|
# Notify other guards about files that have been changed so that other guards can
|
93
95
|
# work on the changed files.
|
94
96
|
#
|
@@ -100,5 +102,12 @@ module Guard
|
|
100
102
|
end
|
101
103
|
end
|
102
104
|
|
105
|
+
def partial?(path)
|
106
|
+
File.basename(path)[0,1] == "_"
|
107
|
+
end
|
108
|
+
|
103
109
|
end
|
104
110
|
end
|
111
|
+
|
112
|
+
require 'guard/sass/runner'
|
113
|
+
require 'guard/sass/formatter'
|
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.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,27 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 1.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.1.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: sass
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,21 +37,31 @@ dependencies:
|
|
32
37
|
version: '3.1'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.1'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: bundler
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
42
52
|
- !ruby/object:Gem::Version
|
43
|
-
version: 1.0
|
53
|
+
version: '1.0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rspec
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>'
|
@@ -54,7 +69,12 @@ dependencies:
|
|
54
69
|
version: 2.0.0.rc
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>'
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.0.0.rc
|
58
78
|
description: Guard::Sass automatically rebuilds sass (like sass --watch)
|
59
79
|
email:
|
60
80
|
- m@hawx.me
|
@@ -89,9 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
109
|
version: 1.3.6
|
90
110
|
requirements: []
|
91
111
|
rubyforge_project: guard-sass
|
92
|
-
rubygems_version: 1.8.
|
112
|
+
rubygems_version: 1.8.23
|
93
113
|
signing_key:
|
94
114
|
specification_version: 3
|
95
115
|
summary: Guard gem for Sass
|
96
116
|
test_files: []
|
97
|
-
has_rdoc:
|