class Bookmarkeron::Merger
Attributes
target[R]
Public Class Methods
new(opts = {})
click to toggle source
# File lib/bookmarkeron/merger.rb, line 10 def initialize(opts = {}) @target = opts[:target] || CHROME_BOOKMARKS_PATH @source = opts[:source] end
Public Instance Methods
bookmarks_from_source()
click to toggle source
# File lib/bookmarkeron/merger.rb, line 15 def bookmarks_from_source yaml = YAML.load_file @source yaml["bookmarks"] end
bookmarks_from_target()
click to toggle source
# File lib/bookmarkeron/merger.rb, line 40 def bookmarks_from_target @target_json ||= JSON.parse(File.read(@target)) end
result()
click to toggle source
# File lib/bookmarkeron/merger.rb, line 20 def result bookmarks = bookmarks_from_target["roots"]["bookmark_bar"]["children"] bookmark_next_id = bookmarks_from_source.size bookmarks_from_source.each do |bookmark| next if bookmarks.find {|existing| existing["url"] == bookmark["url"]} bookmarks << bookmark.merge({ "type"=> "url", "date" => "13010285566708500", "id" => bookmark_next_id }) bookmark_next_id = bookmark_next_id + 1 end bookmarks_from_target end
result_json()
click to toggle source
# File lib/bookmarkeron/merger.rb, line 36 def result_json JSON.pretty_generate result end