class SycLink::Importer
To be subclassed for link importers.
To be subclassed for link importers.
Constants
- CLEANER
REGEX to clean tags and url names
Attributes
opts[RW]
Options for importing
path[RW]
Path to bookmarks file
Public Class Methods
new(path_to_bookmarks, opts = {})
click to toggle source
Creates a new Importer and sets the path to the bookmarks file. Opts may be :level which indicates to which levels tags should be imported and :tags to set tags during import.
# File lib/syclink/importer.rb, line 19 def initialize(path_to_bookmarks, opts = {}) @path = path_to_bookmarks @opts = opts end
Public Instance Methods
links()
click to toggle source
Links returned as Link objects
# File lib/syclink/importer.rb, line 38 def links rows.map do |row| attributes = Link::ATTRS.dup - [:url] Link.new(row.shift, Hash[row.map { |v| [attributes.shift, v] }]) end end
read()
click to toggle source
To be overridden! Read the raw data from the bookmarks file. The bookmarks file has to be provided during initialization with initialize
# File lib/syclink/importer.rb, line 27 def read raise NotImplementedError end
rows()
click to toggle source
Links values returned in an Array. Default implementation returns values from read.
# File lib/syclink/importer.rb, line 33 def rows read end
Protected Instance Methods
url_name(name_source)
click to toggle source
Create a name from the url if no name is given.
# File lib/syclink/importer.rb, line 69 def url_name(name_source) name_source.gsub(CLEANER, " ").squeeze(" ") end