Class: Booker::Parsers::Safari

Inherits:
Base
  • Object
show all
Defined in:
lib/booker/parsers.rb

Overview

Safari bookmark parser (binary plist format)

Instance Attribute Summary

Attributes inherited from Base

#allurls

Instance Method Summary collapse

Methods inherited from Base

#initialize, #results

Constructor Details

This class inherits a constructor from Booker::Parsers::Base

Instance Method Details

#parseObject



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/booker/parsers.rb', line 196

def parse
  xml = convert_plist_to_xml(@file_path)
  return if xml.nil?

  begin
    require "rexml/document"
    doc = REXML::Document.new(xml)
    plist_el = doc.root
    root_node = plist_el.elements.to_a.first
    root = parse_node(root_node)
  rescue => e
    warn "Warning: ".yel + "Could not parse Safari bookmarks: #{e.message}"
    return
  end

  walk(root, "|")
end