asana 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
19
+ *.un~
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in asana.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Ryan Bright
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Asana
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'asana'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install asana
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/asana/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Ryan Bright"]
6
+ gem.email = ["ryan@rbright.net"]
7
+ gem.description = %q{Ruby wrapper for the Asana REST API}
8
+ gem.summary = %q{Ruby wrapper for the Asana REST API}
9
+ gem.homepage = "http://github.com/rbright/asana"
10
+
11
+ gem.add_dependency 'activeresource', '~> 3.2.3'
12
+
13
+ gem.files = `git ls-files`.split($\)
14
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.name = "asana"
17
+ gem.require_paths = ["lib"]
18
+ gem.version = Asana::VERSION
19
+ end
@@ -0,0 +1,13 @@
1
+ require 'active_resource'
2
+ require 'asana/config'
3
+ require 'asana/version'
4
+
5
+ require 'asana/resources/project'
6
+ require 'asana/resources/story'
7
+ require 'asana/resources/task'
8
+ require 'asana/resources/user'
9
+ require 'asana/resources/workspace'
10
+
11
+ module Asana
12
+ extend Config
13
+ end
@@ -0,0 +1,23 @@
1
+ require 'asana/resource'
2
+ require 'asana/version'
3
+
4
+ module Asana
5
+ module Config
6
+
7
+ API_VERSION = '1.0'
8
+ DEFAULT_ENDPOINT = "https://app.asana.com/api/#{API_VERSION}/"
9
+ USER_AGENT = "Asana Ruby Gem #{Asana::VERSION}"
10
+
11
+ attr_accessor :api_key
12
+
13
+ def configure
14
+ yield self
15
+ Resource.site = DEFAULT_ENDPOINT
16
+ Resource.user = self.api_key
17
+ Resource.password = ''
18
+ Resource.format = :json
19
+ self
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,39 @@
1
+ module Asana
2
+ class Resource < ActiveResource::Base
3
+ class << self
4
+
5
+ def check_prefix_options(options)
6
+ end
7
+
8
+ def parent_resources(*resources)
9
+ @parent_resources = resources
10
+ end
11
+
12
+ def prefix(options = {})
13
+ if options.any?
14
+ self.site.path + options.map { |k, v| "#{k.to_s.chomp('_id').pluralize}/#{v}" }.join + '/'
15
+ else
16
+ self.site.path
17
+ end
18
+ end
19
+
20
+ def prefix_options
21
+ id ? {} : super
22
+ end
23
+
24
+ def prefix_source
25
+ if @parent_resources
26
+ self.site.path + @parent_resources.map { |r| "#{r.to_s.pluralize}/:#{r}_id" }.join + '/'
27
+ else
28
+ self.site.path
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ def method_not_allowed
35
+ raise ActiveResource::MethodNotAllowed.new(__method__)
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,10 @@
1
+ module Asana
2
+ class Project < Asana::Resource
3
+ alias :create :method_not_allowed
4
+
5
+ def self.all_by_workspace(*args)
6
+ parent_resources :workspace
7
+ all(*args)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Asana
2
+ class Story < Asana::Resource
3
+ alias :update :method_not_allowed
4
+
5
+ def self.all_by_task(*args)
6
+ parent_resources :task
7
+ all(*args)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ module Asana
2
+ class Task < Asana::Resource
3
+ def self.all_by_project(*args)
4
+ parent_resources :project
5
+ all(*args)
6
+ end
7
+
8
+ def self.all_by_workspace(*args)
9
+ parent_resources :workspace
10
+ all(*args)
11
+ end
12
+
13
+ def stories
14
+ Story.all_by_task(:params => { :task_id => self.id })
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ module Asana
2
+ class User < Asana::Resource
3
+ alias :save :method_not_allowed
4
+ alias :destroy :method_not_allowed
5
+
6
+ def self.me
7
+ get(:me)
8
+ end
9
+
10
+ def self.all_by_workspace(*args)
11
+ parent_resources :workspace
12
+ all(*args)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ module Asana
2
+ class Workspace < Asana::Resource
3
+ alias :create :method_not_allowed
4
+ alias :destroy :method_not_allowed
5
+
6
+ def projects
7
+ Project.all_by_workspace(:params => { :workspace_id => self.id })
8
+ end
9
+
10
+ def tasks
11
+ Task.all_by_workspace(:params => { :workspace_id => self.id })
12
+ end
13
+
14
+ def users
15
+ User.all_by_workspace(:params => { :workspace_id => self.id })
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module Asana
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: asana
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ryan Bright
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activeresource
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.3
30
+ description: Ruby wrapper for the Asana REST API
31
+ email:
32
+ - ryan@rbright.net
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE
40
+ - README.md
41
+ - Rakefile
42
+ - asana.gemspec
43
+ - lib/asana.rb
44
+ - lib/asana/config.rb
45
+ - lib/asana/resource.rb
46
+ - lib/asana/resources/project.rb
47
+ - lib/asana/resources/story.rb
48
+ - lib/asana/resources/task.rb
49
+ - lib/asana/resources/user.rb
50
+ - lib/asana/resources/workspace.rb
51
+ - lib/asana/version.rb
52
+ homepage: http://github.com/rbright/asana
53
+ licenses: []
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 1.8.21
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: Ruby wrapper for the Asana REST API
76
+ test_files: []
77
+ has_rdoc: