lib/syclink/designer.rb in syclink-0.1.2 vs lib/syclink/designer.rb in syclink-0.1.3
- old
+ new
@@ -91,10 +91,11 @@
# one link with the same URL, only the first link is updated
def update_link(url, args)
website.find_links(url).first.update(args)
end
+ # Updates links read from a file
def update_links_from_file(file)
File.foreach(file) do |line|
next if line.chomp.empty?
url, name, description, tag = line.chomp.split(';')
website.find_links(url).first.update({ name: name,
@@ -112,9 +113,16 @@
# Expects the links provided in an array
def remove_links(urls)
urls.map { |url| list_links({ url: url }) }.flatten.compact.each do |link|
website.remove_link(link)
end
+ end
+
+ # Deletes links based on URLs that are provided in a file. Each URL has to
+ # be in one line
+ def remove_links_from_file(file)
+ urls = File.foreach(file).map { |url| url.chomp unless url.empty? }
+ remove_links(urls)
end
# Saves the website to the specified directory with the downcased name of
# the website and the extension 'website'. The website is save as YAML
def save_website(directory)