thor相关
注意,在rails里用thor,thor类名不要和model类名起成一样,thor会优先加载lib/tasks/下面所有的thor类。
erb to haml
lib/tasks/erb.thor
# Add the following to your Gemfile:## gem 'haml'# group :development do# gem 'hpricot'# gem 'ruby_parser'# endrequire 'haml'require 'hpricot'require 'ruby_parser'class Erb < Thor desc "to_haml", "convert erb views to haml" def to_haml files = `find app/views -name *.erb` files.each_line do |file| file.strip! target = file.gsub(/\.erb$/, ".haml") next if File.exist? target puts "#{file}" `bundle exec html2haml #{file} | cat > #{target}` end endend