public
Description: Go plugins used by sbraford. Feel free to clone individually or as a whole.
Homepage:
Clone URL: git://github.com/sbraford/go-plugins.git
go-plugins / html2haml_recursive.rb
100644 20 lines (18 sloc) 0.603 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Html2hamlRecursive < Go::Plugin
  call_with 'convert html2haml'
  usage 'convert html2haml /path/to/app/views/'
  
  def run
    if @options.params.size < 2
      puts "Please provide a target directory."
    else
      @target_dir = @options.params[1]
      res = `which html2haml`
      if res.nil? || res.empty?
        puts "Could not find html2haml. Please ensure the haml gem is installed"; return
      end
      res.chop!
      @cmd = "for x in `find #{@target_dir} | grep erb`; do #{res} $x > `dirname $x`\"/\"`basename $x \".erb\"`\".haml\"; done"
      system(@cmd)
    end
  end
end