Sha256: 1cee232f080ca9de80d83db85de8a3c9947721a0868514b55fdd1f00db59d19d
Contents?: true
Size: 1.09 KB
Versions: 21
Compression:
Stored size: 1.09 KB
Contents
# -*- coding: utf-8 -*- require 'bundler' Bundler.require require 'asana' access_token = ENV['ASANA_ACCESS_TOKEN'] unless access_token abort "Run this program with the env var ASANA_ACCESS_TOKEN.\n" \ "Go to http://app.asana.com/-/account_api to create a personal access token." end client = Asana::Client.new do |c| c.authentication :access_token, access_token end workspace = client.workspaces.find_all.first task = client.tasks.find_all(assignee: "me", workspace: workspace.id).first unless task task = client.tasks.create(workspace: workspace.id, name: "Hello world!", assignee: "me") end Thread.abort_on_exception = true Thread.new do puts "Listening for 'changed' events on #{task} in one thread..." task.events(wait: 2).lazy.select { |event| event.action == 'changed' }.each do |event| puts "#{event.user.name} changed #{event.resource}" end end Thread.new do puts "Listening for non-'changed' events on #{task} in another thread..." task.events(wait: 1).lazy.reject { |event| event.action == 'changed' }.each do |event| puts "'#{event.action}' event: #{event}" end end sleep
Version data entries
21 entries across 21 versions & 1 rubygems