Class: Delicious2Yaml
- Inherits:
-
Object
- Object
- Delicious2Yaml
- Defined in:
- lib/graphiclious/delicious2yaml.rb
Constant Summary collapse
- MODES =
{:a_recent => 'update recent', :b_all => 'fetch all' }
Instance Method Summary collapse
- #create_interface ⇒ Object
-
#initialize(user_string, password_string) ⇒ Delicious2Yaml
constructor
A new instance of Delicious2Yaml.
-
#run ⇒ Object
this is the main doit, just like update but with basic exception handling returns true if update was necessary and successful.
- #set_mode(new_mode) ⇒ Object
- #set_protocol_block(aProc) ⇒ Object
- #set_working_dir(new_working_dir) ⇒ Object
-
#update ⇒ Object
get links from del.icio.us and add them to the locally stored links you’ll have to edit the delicious*.yaml file to delete a link (or delete the file to get a clean copy next time).
- #writeLineOnProtokoll(lineString) ⇒ Object
Constructor Details
#initialize(user_string, password_string) ⇒ Delicious2Yaml
Returns a new instance of Delicious2Yaml.
85 86 87 88 89 90 91 |
# File 'lib/graphiclious/delicious2yaml.rb', line 85 def initialize(user_string, password_string) @working_dir = Dir.getwd @user = user_string @password = password_string @interface = create_interface @mode = :b_all end |
Instance Method Details
#create_interface ⇒ Object
93 94 95 96 97 |
# File 'lib/graphiclious/delicious2yaml.rb', line 93 def create_interface @interface = Rubilicious.new(@user, @password) @interface.base_uri = 'https://api.del.icio.us/v1' @interface end |
#run ⇒ Object
this is the main doit, just like update but with basic exception handling returns true if update was necessary and successful
126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/graphiclious/delicious2yaml.rb', line 126 def run begin update true rescue StandardError => bang writeLineOnProtokoll "Error: #{bang}" false rescue writeLineOnProtokoll "Error, maybe try again later?" false end end |
#set_mode(new_mode) ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/graphiclious/delicious2yaml.rb', line 103 def set_mode(new_mode) unless MODES.has_key?(new_mode) raise("Sorry, this mode is not possible") return end @mode = new_mode end |
#set_protocol_block(aProc) ⇒ Object
111 112 113 |
# File 'lib/graphiclious/delicious2yaml.rb', line 111 def set_protocol_block(aProc) @protocol_block = aProc end |
#set_working_dir(new_working_dir) ⇒ Object
99 100 101 |
# File 'lib/graphiclious/delicious2yaml.rb', line 99 def set_working_dir(new_working_dir) @working_dir = new_working_dir end |
#update ⇒ Object
get links from del.icio.us and add them to the locally stored links you’ll have to edit the delicious*.yaml file to delete a link (or delete the file to get a clean copy next time)
143 144 145 146 |
# File 'lib/graphiclious/delicious2yaml.rb', line 143 def update fetch_and_store_links fetch_and_store_bundles end |
#writeLineOnProtokoll(lineString) ⇒ Object
115 116 117 118 119 120 121 |
# File 'lib/graphiclious/delicious2yaml.rb', line 115 def writeLineOnProtokoll(lineString) if @protocol_block.nil? puts(lineString) else @protocol_block.call(lineString) end end |