Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ContactsManager
- def initialize(debug)
- @debug = debug
- @load = false
- @contacts = []
- @personalcontacts = []
- end
- attr_reader :contacts
- attr_reader :personalcontacts
- def loaded?
- !@load
- end
- def run_queue
- load_contacts
- end
- def load_contactsmanager_contacts
- @load = true
- end
- private
- def load_contacts
- return unless @load
- @contacts = safe_load_yaml('./scripts/data/base-contacts.yaml')
- @contacts = contacts['contacts']
- @personalcontacts = safe_load_yaml('./scripts/profiles/Syntych-contacts.yaml')
- @personalcontacts = personalcontacts['contacts']
- @contacts = contacts.merge!(personalcontacts)
- @load = false
- end
- def safe_load_yaml(path)
- YAML.load_file(path)
- rescue => e
- echo('*** ERROR PARSING YAML FILE ***')
- echo(e.message)
- return []
- end
- end
- ----------------------------------------
- $contactsmanager = ContactsManager.new(debug)
- ------------------------------------------
- def load_contactsmanager_contacts
- $contactsmanager.load_contactsmanager_contacts
- pause 0.1 until $contactsmanager.loaded?
- $contactsmanager.contacts
- end
- ------------------------------------------------
- $contactsmanager.run_queue
- ===========================================================
- contacts = load_contactsmanager_contacts
- echo contacts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement