Sha256: 19afbc0ee5b354026bdbc2e6ce7cbe18d4a3d42ae5f3758d38960a5a2e6352af

Contents?: true

Size: 787 Bytes

Versions: 32

Compression:

Stored size: 787 Bytes

Contents

class FormatParser::FDXParser
  include FormatParser::IOUtils

  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

32 entries across 32 versions & 1 rubygems

Version Path
format_parser-0.15.1 lib/parsers/fdx_parser.rb
format_parser-0.15.0 lib/parsers/fdx_parser.rb
format_parser-0.14.1 lib/parsers/fdx_parser.rb
format_parser-0.14.0 lib/parsers/fdx_parser.rb
format_parser-0.13.6 lib/parsers/fdx_parser.rb
format_parser-0.13.5 lib/parsers/fdx_parser.rb
format_parser-0.13.4 lib/parsers/fdx_parser.rb
format_parser-0.13.3 lib/parsers/fdx_parser.rb
format_parser-0.13.2 lib/parsers/fdx_parser.rb
format_parser-0.13.1 lib/parsers/fdx_parser.rb
format_parser-0.13.0 lib/parsers/fdx_parser.rb
format_parser-0.12.4 lib/parsers/fdx_parser.rb
format_parser-0.12.2 lib/parsers/fdx_parser.rb
format_parser-0.12.1 lib/parsers/fdx_parser.rb
format_parser-0.12.0 lib/parsers/fdx_parser.rb
format_parser-0.11.0 lib/parsers/fdx_parser.rb
format_parser-0.10.0 lib/parsers/fdx_parser.rb
format_parser-0.9.4 lib/parsers/fdx_parser.rb
format_parser-0.9.3 lib/parsers/fdx_parser.rb
format_parser-0.9.0 lib/parsers/fdx_parser.rb