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

Version Path
format_parser-1.7.0 lib/parsers/fdx_parser.rb
format_parser-1.6.0 lib/parsers/fdx_parser.rb
format_parser-1.5.0 lib/parsers/fdx_parser.rb
format_parser-1.4.2 lib/parsers/fdx_parser.rb
format_parser-1.4.1 lib/parsers/fdx_parser.rb
format_parser-1.4.0 lib/parsers/fdx_parser.rb
format_parser-1.3.0 lib/parsers/fdx_parser.rb
format_parser-1.2.1 lib/parsers/fdx_parser.rb
format_parser-1.2.0 lib/parsers/fdx_parser.rb
format_parser-1.1.0 lib/parsers/fdx_parser.rb
format_parser-1.0.0 lib/parsers/fdx_parser.rb
format_parser-0.29.1 lib/parsers/fdx_parser.rb
format_parser-0.29.0 lib/parsers/fdx_parser.rb
format_parser-0.28.0 lib/parsers/fdx_parser.rb
format_parser-0.27.0 lib/parsers/fdx_parser.rb
format_parser-0.26.0 lib/parsers/fdx_parser.rb
format_parser-0.25.6 lib/parsers/fdx_parser.rb
format_parser-0.25.5 lib/parsers/fdx_parser.rb
format_parser-0.25.4 lib/parsers/fdx_parser.rb
format_parser-0.25.3 lib/parsers/fdx_parser.rb