guard-haml 0.3.3 → 0.4
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/README.md +8 -0
- data/lib/guard/haml.rb +7 -6
- data/lib/guard/haml/version.rb +1 -1
- data/spec/guard/haml_spec.rb +10 -6
- metadata +9 -9
data/README.md
CHANGED
@@ -38,6 +38,14 @@ If you maintain your haml files in a directory that should not be part of the ou
|
|
38
38
|
So when you edit a file `src/partials/_partial.html.haml`
|
39
39
|
it will be outputted in `public/partials/_partial.html` without the `src`.
|
40
40
|
|
41
|
+
If you want to pass options to the Haml engine, you can set the `haml_options` option, e.g.:
|
42
|
+
|
43
|
+
guard 'haml', :output => 'public', :input => 'src', :haml_options => { :ugly => true } do
|
44
|
+
watch %r{^src/.+(\.html\.haml)}
|
45
|
+
end
|
46
|
+
|
47
|
+
This will produce compressed HTML. See [Haml Reference](http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#options) for more details.
|
48
|
+
|
41
49
|
## Development
|
42
50
|
|
43
51
|
* Source is hosted on [Github: guard-haml](https://github.com/manufaktor/guard-haml)
|
data/lib/guard/haml.rb
CHANGED
@@ -14,12 +14,13 @@ module Guard
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def compile_haml file
|
17
|
-
content = File.new(file).read
|
18
17
|
begin
|
19
|
-
|
18
|
+
content = File.new(file).read
|
19
|
+
engine = ::Haml::Engine.new(content, (@options[:haml_options] || {}))
|
20
20
|
engine.render
|
21
21
|
rescue StandardError => error
|
22
|
-
::Guard::UI.
|
22
|
+
::Guard::UI.error "HAML Error: " + error.message
|
23
|
+
throw :task_has_failed
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -46,10 +47,10 @@ module Guard
|
|
46
47
|
end
|
47
48
|
|
48
49
|
def run_all
|
49
|
-
|
50
|
+
run_on_changes(Watcher.match_files(self, Dir.glob(File.join('**', '*.*'))))
|
50
51
|
end
|
51
52
|
|
52
|
-
def
|
53
|
+
def run_on_changes(paths)
|
53
54
|
paths.each do |file|
|
54
55
|
output_file = get_output(file)
|
55
56
|
FileUtils.mkdir_p File.dirname(output_file)
|
@@ -63,7 +64,7 @@ module Guard
|
|
63
64
|
def notify(changed_files)
|
64
65
|
::Guard.guards.reject{ |guard| guard == self }.each do |guard|
|
65
66
|
paths = Watcher.match_files(guard, changed_files)
|
66
|
-
guard.
|
67
|
+
guard.run_on_changes paths unless paths.empty?
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
data/lib/guard/haml/version.rb
CHANGED
data/spec/guard/haml_spec.rb
CHANGED
@@ -57,12 +57,16 @@ describe Guard::Haml do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
describe '
|
60
|
+
describe '#run_on_changes' do
|
61
61
|
it 'should notify other guards upon completion' do
|
62
|
-
|
63
|
-
|
64
|
-
Guard.stub(:guards).and_return([subject, other_guard])
|
65
|
-
subject.notify([])
|
62
|
+
subject.should_receive(:notify).with([])
|
63
|
+
subject.run_on_changes([])
|
66
64
|
end
|
67
|
-
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#compile_haml' do
|
68
|
+
it 'throws :task_has_failed when an error occurs' do
|
69
|
+
expect { subject.compile_haml('') }.to throw_symbol :task_has_failed
|
70
|
+
end
|
71
|
+
end
|
68
72
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-haml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.4'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ 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: &70267091645620 !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'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70267091645620
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: haml
|
27
|
-
requirement: &
|
27
|
+
requirement: &70267091645120 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '3.0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70267091645120
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70267091644740 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70267091644740
|
47
47
|
description: Compiles file.html.haml into file.html
|
48
48
|
email:
|
49
49
|
- haeussermann@gmail.com
|