erb2haml 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +11 -0
- data/LICENSE +20 -0
- data/README.md +16 -0
- data/Rakefile +9 -0
- data/lib/erb2haml.rb +6 -0
- data/lib/erb2haml/railtie.rb +11 -0
- data/lib/erb2haml/railties/erb2haml.rake +42 -0
- metadata +109 -0
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
|
9
|
+
gem "haml"
|
10
|
+
gem "hpricot"
|
11
|
+
gem "ruby_parser"
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 David Leung
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
erb2haml
|
2
|
+
========
|
3
|
+
**erb2haml** adds a simple rake task to your Rails app that converts all ERB HTML files in `APP_HOME/app/views/` that hasn't already been converted to haml.
|
4
|
+
|
5
|
+
Getting Started
|
6
|
+
---------------
|
7
|
+
1. Add `gem erb2haml` to your Gemfile.
|
8
|
+
2. Run `rake haml:convert_erbs`
|
9
|
+
3. Watch your ERB files getting converted to haml.
|
10
|
+
|
11
|
+
And that's it!
|
12
|
+
|
13
|
+
Copyright
|
14
|
+
---------
|
15
|
+
Copyright (c) 2011 David Leung. See LICENSE for further details.
|
16
|
+
|
data/Rakefile
ADDED
data/lib/erb2haml.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
RED_FG ="\033[31m"
|
2
|
+
GREEN_FG = "\033[32m"
|
3
|
+
END_TEXT_STYLE = "\033[0m"
|
4
|
+
|
5
|
+
# Helper method to inject ASCII escape sequences for colorized output
|
6
|
+
def color(text, begin_text_style)
|
7
|
+
begin_text_style + text + END_TEXT_STYLE
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :haml do
|
11
|
+
desc "Perform bulk conversion of all html.erb files to Haml in views folder."
|
12
|
+
task :convert_erbs do
|
13
|
+
|
14
|
+
if `which html2haml`.empty?
|
15
|
+
puts "#{color "ERROR: ", RED_FG} Could not find " +
|
16
|
+
"#{color "html2haml", GREEN_FG} in your PATH. Aborting."
|
17
|
+
exit(false)
|
18
|
+
end
|
19
|
+
|
20
|
+
puts "Looking for #{color "ERB", GREEN_FG} files to convert to " +
|
21
|
+
"#{color("Haml", RED_FG)}..."
|
22
|
+
|
23
|
+
Find.find("app/views/") do |path|
|
24
|
+
if FileTest.file?(path) and path.downcase.match(/\.html\.erb$/i)
|
25
|
+
haml_path = path.slice(0...-3)+"haml"
|
26
|
+
|
27
|
+
unless FileTest.exists?(haml_path)
|
28
|
+
print "Converting: #{path}... "
|
29
|
+
|
30
|
+
if system("html2haml", path, haml_path)
|
31
|
+
puts color("Done!", GREEN_FG)
|
32
|
+
else
|
33
|
+
puts color("Failed!", RED_FG)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end #End rake task
|
41
|
+
end # End of :haml namespace
|
42
|
+
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: erb2haml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- David Leung
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-02-12 00:00:00 +08:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: haml
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: hpricot
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: ruby_parser
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
type: :runtime
|
58
|
+
version_requirements: *id003
|
59
|
+
description: Simple rake task to bulk covert ERB HAML files in a Rails app to Haml.
|
60
|
+
email: david@davidslab.com
|
61
|
+
executables: []
|
62
|
+
|
63
|
+
extensions: []
|
64
|
+
|
65
|
+
extra_rdoc_files:
|
66
|
+
- LICENSE
|
67
|
+
- README.md
|
68
|
+
files:
|
69
|
+
- Gemfile
|
70
|
+
- Rakefile
|
71
|
+
- lib/erb2haml/railtie.rb
|
72
|
+
- lib/erb2haml/railties/erb2haml.rake
|
73
|
+
- lib/erb2haml.rb
|
74
|
+
- LICENSE
|
75
|
+
- README.md
|
76
|
+
has_rdoc: true
|
77
|
+
homepage: http://github.com/dhl/erb2haml
|
78
|
+
licenses: []
|
79
|
+
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
segments:
|
99
|
+
- 0
|
100
|
+
version: "0"
|
101
|
+
requirements: []
|
102
|
+
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 1.3.7
|
105
|
+
signing_key:
|
106
|
+
specification_version: 3
|
107
|
+
summary: Bulk ERB HTML to Haml conversion for Rails.
|
108
|
+
test_files: []
|
109
|
+
|