Browse files

Initial Commit

  • Loading branch information...
0 parents commit 4049d16a15ee654919bf1498a9e9aa99028cbeb4 @rahult committed Nov 17, 2011
Showing with 148 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +1 −0 .rvmrc
  3. +2 −0 Gemfile
  4. +20 −0 MIT-LICENSE
  5. +9 −0 README.markdown
  6. +8 −0 Rakefile
  7. +18 −0 asana.gemspec
  8. +6 −0 bin/ae
  9. +66 −0 lib/asana.rb
  10. +7 −0 spec/asana_spec.rb
  11. +7 −0 spec/spec_helper.rb
4 .gitignore
@@ -0,0 +1,4 @@
+.bundle
+Gemfile.lock
+pkg/*
+*.gem
1 .rvmrc
@@ -0,0 +1 @@
+rvm use ruby-1.9.2-p290@asana --create
2 Gemfile
@@ -0,0 +1,2 @@
+source :gemcutter
+gemspec
20 MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2008 Rahul Trikha
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 README.markdown
@@ -0,0 +1,9 @@
+Asana
+========
+
+Ruby API and command line client for [Asana](http://http://asana.com//).
+
+## Command line usage
+
+ ae task
+
8 Rakefile
@@ -0,0 +1,8 @@
+require "bundler/gem_tasks"
+
+require "rspec/core/rake_task"
+RSpec::Core::RakeTask.new(:spec) do |spec|
+ spec.pattern = "spec/**/*_spec.rb"
+end
+
+task :default => :spec
18 asana.gemspec
@@ -0,0 +1,18 @@
+Gem::Specification.new do |s|
+ s.name = "asana"
+ s.version = "0.0.1"
+ s.platform = Gem::Platform::RUBY
+ s.authors = ["Rahul Trikha"]
+ s.email = ["rahul.trikha@gmail.com"]
+ s.homepage = "http://github.com/rahult/asanar"
+ s.summary = "Asana command line client"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ s.add_runtime_dependency("mail", ["~> 2.3.0"])
+ s.add_runtime_dependency("sendgrid", ["~> 1.0.1"])
+ s.add_development_dependency("rspec", ["~> 2.5"])
+end
6 bin/ae
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+
+$:.unshift(File.join(File.dirname(File.dirname(__FILE__)),'lib'))
+require 'asana'
+
+Asana.run(ARGV)
66 lib/asana.rb
@@ -0,0 +1,66 @@
+require 'mail'
+Mail.defaults do
+ delivery_method :smtp, {
+ :address => "smtp.sendgrid.net",
+ :port => '25',
+ :domain => "katalyst.com.au",
+ :authentication => :plain,
+ :user_name => "jason@katalyst.com.au",
+ :password => "i9XypcTh2GOptAvK"
+ }
+end
+
+class Asana
+ class Error < RuntimeError
+ end
+
+ def self.run(argv)
+ if argv.empty?
+ puts "Please add your task"
+ else
+ argv.join(' ')
+ end
+ rescue Error
+ $stderr.puts "#$!"
+ exit 1
+ rescue Interrupt
+ $stderr.puts "Interrupted!"
+ exit 130
+ end
+
+ def initialize(task)
+ add_task(task)
+ end
+
+ def add_task(task=nil)
+ mail = Mail.deliver do
+ to ' x@mail.asana.com'
+ from 'Rahul Trikha <rahul.trikha@gmail.com>'
+ subject 'Test task'
+ text_part do
+ body 'Notes go here'
+ end
+ end
+ end
+
+ def reconfigure
+ token = authenticate['token']
+ File.open(self.class.config_file,'w') do |f|
+ f.puts "auth_token: #{token}"
+ end
+ end
+
+ def self.config_file
+ File.expand_path('~/.asana.yml')
+ end
+
+ def account(auth_token = nil)
+ require 'yaml'
+ @account ||=
+ begin
+ reconfigure unless File.exist?(self.class.config_file)
+ t = YAML.load(File.read(self.class.config_file))['auth_token']
+ account(t)
+ end
+ end
+end
7 spec/asana_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec/spec_helper')
+
+describe Asana do
+ subject do
+ Asana.new('This is a test task')
+ end
+end
7 spec/spec_helper.rb
@@ -0,0 +1,7 @@
+$LOAD_PATH.unshift(File.join(File.dirname(File.dirname(__FILE__)),'lib'))
+require 'asana'
+begin; require 'rubygems'; rescue LoadError; end
+require 'rspec'
+
+RSpec.configure do |config|
+end

0 comments on commit 4049d16

Please sign in to comment.