guard-haml 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011 by Immanuel Häussermann
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Guard::Haml
2
+
3
+ Guard yo Haml, guard yo html cuz they compilin errybody out here.
4
+
5
+ ## Install
6
+
7
+ As the gem name suggests this is a guard extension. Make sure you get [guard](http://github.com/guard/guard) first.
8
+
9
+ Install the gem:
10
+
11
+ gem install guard-haml
12
+
13
+ Add it to your Gemfile if you're using bundler (you should)
14
+
15
+ gem 'guard-haml'
16
+
17
+ Add a basic guard setup:
18
+
19
+ guard init haml
@@ -0,0 +1,3 @@
1
+ guard 'haml' do
2
+ watch(/^.+(\.html\.haml)/)
3
+ end
data/lib/guard/haml.rb ADDED
@@ -0,0 +1,37 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+ require 'haml'
4
+
5
+ module Guard
6
+ class Haml < Guard
7
+
8
+ VERSION = '0.1.0'
9
+
10
+ def initialize(watchers = [], options = {})
11
+ @watchers, @options = watchers, options
12
+ end
13
+
14
+ def compile_haml file
15
+ content = File.new(file).read
16
+ engine = ::Haml::Engine.new(content)
17
+ engine.render
18
+ end
19
+
20
+ def run_all
21
+ patterns = @watchers.map { |w| w.pattern }
22
+ files = Dir.glob('**/*.*')
23
+ paths = files.map do |file|
24
+ patterns.map { |pattern| file if file.match(Regexp.new(pattern)) }
25
+ end
26
+ run_on_change(paths.flatten.compact)
27
+ end
28
+
29
+ def run_on_change(paths)
30
+ paths.each do |file|
31
+ output_file = file.split('.')[0..-2].join('.')
32
+ File.open(output_file, 'w') { |f| f.write(compile_haml(file)) }
33
+ puts "# compiled haml in '#{file}' to html in '#{output_file}'"
34
+ end
35
+ end
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-haml
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - "Immanuel H\xC3\xA4ussermann"
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-30 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ hash: 13
28
+ segments:
29
+ - 0
30
+ - 3
31
+ version: "0.3"
32
+ type: :runtime
33
+ requirement: *id001
34
+ prerelease: false
35
+ name: guard
36
+ - !ruby/object:Gem::Dependency
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 7
43
+ segments:
44
+ - 3
45
+ - 0
46
+ version: "3.0"
47
+ type: :runtime
48
+ requirement: *id002
49
+ prerelease: false
50
+ name: haml
51
+ description: Compiles file.html.haml into file.html
52
+ email:
53
+ - haeussermann@gmail.com
54
+ executables: []
55
+
56
+ extensions: []
57
+
58
+ extra_rdoc_files: []
59
+
60
+ files:
61
+ - lib/guard/haml/templates/Guardfile
62
+ - lib/guard/haml.rb
63
+ - LICENSE
64
+ - README.md
65
+ has_rdoc: true
66
+ homepage: ""
67
+ licenses: []
68
+
69
+ post_install_message:
70
+ rdoc_options: []
71
+
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ hash: 3
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ requirements: []
93
+
94
+ rubyforge_project: guard-haml
95
+ rubygems_version: 1.6.2
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: Guard gem for Haml
99
+ test_files: []
100
+