Sha256: 7935966e025aaef2ee851279b0acc9e43c046aa882800128ef5afe06d78c7887
Contents?: true
Size: 849 Bytes
Versions: 37
Compression:
Stored size: 849 Bytes
Contents
class FormatParser::FDXParser include FormatParser::IOUtils def likely_match?(filename) filename =~ /\.fdx$/i end def call(io) return unless xml_check(io) file_and_document_type = safe_read(io, 100) file_type, document_type = check_for_document_type(file_and_document_type) return if file_type != :fdx FormatParser::Document.new( format: file_type, document_type: document_type ) end def xml_check(io) xml_check = safe_read(io, 5) xml_check == '<?xml' end def check_for_document_type(file_and_document_type) sanitized_data = file_and_document_type.downcase if sanitized_data.include?('finaldraft') && sanitized_data.include?('script') return :fdx, :script else return end end FormatParser.register_parser new, natures: :document, formats: :fdx end
Version data entries
37 entries across 37 versions & 1 rubygems