Sha256: 978348429095f7ec4f7e9f88f8a1a7f19d7bef2b5832b65a970bdde3cf0f0ece

Contents?: true

Size: 843 Bytes

Versions: 3

Compression:

Stored size: 843 Bytes

Contents

desc "Create syntax detection definitions"
task 'syntax_list' do
  require 'json'

  File.open 'config/detect.rb', 'w+' do |file|
    file.puts '# Encoding: UTF-8'
    file.puts
    file.puts 'module VER::Syntax::Detector'

    Dir.glob 'config/syntax/*.json' do |syntax|
      basename = File.basename(syntax, '.json')
      plist = JSON.load(File.read(syntax))
      name = plist['name']
      file_types = plist['fileTypes']
      regex = plist['firstLineMatch']

      if file_types && file_types.any?
        # this syntax is next to useless for ruby
        file_types.delete('rb') if name == 'Ruby on Rails'

        file.puts "  exts %p, %p" % [basename, file_types]
      end

      if regex
        regex.gsub!('/', '\\/')
        file.puts "  head %p, /%s/" % [basename, regex.strip]
      end
    end

    file.puts 'end'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ver-2009.12.14 tasks/syntax_list.rake
ver-2009.11.29 tasks/syntax_list.rake
ver-2009.11.28 tasks/syntax_list.rake