Class: TeamboxThingsSync::Base
- Inherits:
-
Object
- Object
- TeamboxThingsSync::Base
- Defined in:
- lib/teambox-things-sync/base.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
- .find_or_create_project_in_things(project_name) ⇒ Object
- .find_or_create_todo_in_things(todo_name) ⇒ Object
Instance Method Summary collapse
- #api_url(url) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #is_task_open?(status) ⇒ Boolean
- #synchronise ⇒ Object
- #task_url(project_permalink, task_list_id, task_id) ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 |
# File 'lib/teambox-things-sync/base.rb', line 6 def initialize parse_config_file httpauth = Teambox::HTTPAuth.new(@config['username'], @config['password'], :api_endpoint => api_url(@config['teambox_url'])) @client = Teambox::Base.new(httpauth) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/teambox-things-sync/base.rb', line 4 def config @config end |
Class Method Details
Instance Method Details
#api_url(url) ⇒ Object
49 50 51 |
# File 'lib/teambox-things-sync/base.rb', line 49 def api_url(url) url.gsub("http://", "") end |
#is_task_open?(status) ⇒ Boolean
53 54 55 |
# File 'lib/teambox-things-sync/base.rb', line 53 def is_task_open?(status) [0,1].include? status end |
#synchronise ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/teambox-things-sync/base.rb', line 13 def synchronise Timeout::timeout(@config['timeout_limit']) { begin projects = @client.projects rescue abort "Cannot fetch project list, check your internet connection." end projects.each do |project| log "Started working with #{project.name}" begin mark_as_done_at_remote(project) person_id = find_person_id(project.permalink) fetch_tasks_from_remote(project, person_id) rescue abort "Something went wrong while updating.\n" + $! end end } end |
#task_url(project_permalink, task_list_id, task_id) ⇒ Object
44 45 46 47 |
# File 'lib/teambox-things-sync/base.rb', line 44 def task_url(project_permalink, task_list_id, task_id) "#{@config['teambox_url']}/projects/#{project_permalink}/"+ "task_lists/#{task_list_id}/tasks/#{task_id}" end |