Sha256: 1e865df0c8136e3babf262fe60d968c27650fed824785bd36f4c623ab8e1408d
Contents?: true
Size: 855 Bytes
Versions: 2
Compression:
Stored size: 855 Bytes
Contents
class FormatParser::FDXParser include FormatParser::IOUtils def self.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 self, natures: :document, formats: :fdx end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
format_parser-0.16.1 | lib/parsers/fdx_parser.rb |
format_parser-0.16.0 | lib/parsers/fdx_parser.rb |