require 'open-uri' require 'yaml' require 'noty/storage' require 'noty/helpers' module Noty class Bookmark attr_accessor :path, :url, :title def initialize(path) content = File.exist?(path) ? YAML.load_file(path) : '' @path = path @url = content['url'] @title = content['title'] end def self.from_url(url) file_path = File.join(STORAGE_PATH, Time.now.to_i.to_s + '.bookmark') content = begin open(url).read rescue '' end bookmark = new(file_path) bookmark.url = url bookmark.title = content.match(%r{