Sha256: 95b27bde8e56fee46d74fce5d3177fcebc77141657537513eb01492898ce0fe6

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 KB

Contents

require 'fileutils'
JQ_TOOLS_SRC = File.join(RAILS_ROOT, 'tmp', 'jquerytools')

def convert2haml(src, dest)
  system "html2haml -x #{src} #{dest}"
  puts "Converted: #{src}"
end

def cleanup(pattern)
  puts "Cleanup started for: #{pattern}"
  Dir["#{pattern}"].each do |file|
    FileUtils.remove_file file if File.exists? file
    puts "Removed: #{file}"
  end
  puts "Cleanup finished for: #{pattern}"
end

namespace :jquery do
  namespace :tools do

    namespace :haml do
      desc 'Cleanup directory'
      task :cleanup, :dir do |t, args|
        cleanup(args[:dir])
      end
    end

    namespace :convert do
      desc 'Convert /test files to haml'
      task :test do
        puts "Haml conversion started for /test files:"

        path = File.join(JQ_TOOLS_SRC, 'test')
        cleanup("#{path}/**/*.html.haml")
        Dir["#{path}/**/*.htm"].each do |src|
          dest = src.gsub(/\.htm$/, '.html.haml')
          convert2haml(src, dest)
        end
        puts "Haml conversion finished for /test files."
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
compass-jquery-plugin-0.3.3.1 templates/tools/lib/tasks/jquery.tools.rake
compass-jquery-plugin-0.3.3.0 templates/tools/lib/tasks/jquery.tools.rake
compass-jquery-plugin-0.3.2.8 templates/tools/lib/tasks/jquery.tools.rake
compass-jquery-plugin-0.3.2.7 templates/tools/lib/tasks/jquery.tools.rake
compass-jquery-plugin-0.3.2.7.nil templates/tools/lib/tasks/jquery.tools.rake
compass-jquery-plugin-0.3.2.6 templates/tools/lib/tasks/jquery.tools.rake
compass-jquery-plugin-0.3.2.5 templates/tools/lib/tasks/jquery.tools.rake
compass-jquery-plugin-0.3.2.4 templates/tools/lib/tasks/jquery.tools.rake