guard-haml 0.1.2 → 0.2.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.
Files changed (3) hide show
  1. data/README.md +12 -1
  2. data/lib/guard/haml.rb +18 -3
  3. metadata +10 -10
data/README.md CHANGED
@@ -16,4 +16,15 @@ Add it to your Gemfile if you're using bundler (you should)
16
16
 
17
17
  Add a basic guard setup:
18
18
 
19
- guard init haml
19
+ guard init haml
20
+
21
+ ## Options
22
+
23
+ If you want to change the output directory use the `output` option in your
24
+ Guardfile, e.g.:
25
+
26
+ guard 'haml', :output => 'public' do
27
+ watch %r{^src/.+(\.html\.haml)}
28
+ end
29
+
30
+ This output is relative to the Guardfile.
data/lib/guard/haml.rb CHANGED
@@ -5,7 +5,7 @@ require 'haml'
5
5
  module Guard
6
6
  class Haml < Guard
7
7
 
8
- VERSION = '0.1.2'
8
+ VERSION = '0.2.0'
9
9
 
10
10
  def initialize(watchers = [], options = {})
11
11
  @watchers, @options = watchers, options
@@ -17,6 +17,21 @@ module Guard
17
17
  engine = ::Haml::Engine.new(content, @haml_options)
18
18
  engine.render
19
19
  end
20
+
21
+ # Get the file path to output the html based on the file being
22
+ # built. The output path is relative to where guard is being run.
23
+ #
24
+ # @param file [String] path to file being built
25
+ # @return [String] path to file where output should be written
26
+ #
27
+ def get_output(file)
28
+ if @options[:output]
29
+ FileUtils.mkdir_p(@options[:output])
30
+ File.join(@options[:output], File.basename(file).split('.')[0..-2].join('.'))
31
+ else
32
+ file.split('.')[0..-2].join('.')
33
+ end
34
+ end
20
35
 
21
36
  def run_all
22
37
  patterns = @watchers.map { |w| w.pattern }
@@ -29,10 +44,10 @@ module Guard
29
44
 
30
45
  def run_on_change(paths)
31
46
  paths.each do |file|
32
- output_file = file.split('.')[0..-2].join('.')
47
+ output_file = get_output(file)
33
48
  File.open(output_file, 'w') { |f| f.write(compile_haml(file)) }
34
49
  puts "# compiled haml in '#{file}' to html in '#{output_file}'"
35
50
  end
36
51
  end
37
52
  end
38
- end
53
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-haml
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease: false
4
+ hash: 23
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
8
  - 2
10
- version: 0.1.2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Immanuel H\xC3\xA4ussermann"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-25 00:00:00 +02:00
18
+ date: 2011-05-31 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -29,10 +29,10 @@ dependencies:
29
29
  - 0
30
30
  - 3
31
31
  version: "0.3"
32
+ type: :runtime
32
33
  requirement: *id001
33
- name: guard
34
34
  prerelease: false
35
- type: :runtime
35
+ name: guard
36
36
  - !ruby/object:Gem::Dependency
37
37
  version_requirements: &id002 !ruby/object:Gem::Requirement
38
38
  none: false
@@ -44,10 +44,10 @@ dependencies:
44
44
  - 3
45
45
  - 0
46
46
  version: "3.0"
47
+ type: :runtime
47
48
  requirement: *id002
48
- name: haml
49
49
  prerelease: false
50
- type: :runtime
50
+ name: haml
51
51
  description: Compiles file.html.haml into file.html
52
52
  email:
53
53
  - haeussermann@gmail.com
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  requirements: []
93
93
 
94
94
  rubyforge_project: guard-haml
95
- rubygems_version: 1.3.7
95
+ rubygems_version: 1.6.2
96
96
  signing_key:
97
97
  specification_version: 3
98
98
  summary: Guard gem for Haml