active_collab 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rvmrc +1 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/active_collab.gemspec +22 -0
- data/lib/active_collab.rb +22 -0
- data/lib/active_collab/api/projects.rb +18 -0
- data/lib/active_collab/api/tasks.rb +25 -0
- data/lib/active_collab/api/time_records.rb +16 -0
- data/lib/active_collab/api/users.rb +17 -0
- data/lib/active_collab/project.rb +20 -0
- data/lib/active_collab/task.rb +43 -0
- data/lib/active_collab/time_record.rb +27 -0
- data/lib/active_collab/user.rb +18 -0
- data/lib/active_collab/version.rb +3 -0
- metadata +80 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3@active_collab --create
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 marcosbeirigo
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# ActiveCollab
|
2
|
+
|
3
|
+
Ruby client for the active collab 3 Api.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'active_collab'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install active_collab
|
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 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
|
6
|
+
require 'active_collab/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |gem|
|
9
|
+
gem.name = "active_collab"
|
10
|
+
gem.version = ActiveCollab::VERSION
|
11
|
+
gem.authors = ["Marcos Beirigo", "Diogo Soares"]
|
12
|
+
gem.email = ["marcosbeirigo@gmail.com", "diogo@jera.com.br"]
|
13
|
+
gem.description = "activecollab ruby"
|
14
|
+
gem.summary = "activecollab ruby"
|
15
|
+
gem.homepage = ""
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($/)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
gem.add_dependency('httparty', '>= 0.9.0')
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require "active_collab/version"
|
3
|
+
require 'active_collab/api/projects'
|
4
|
+
require 'active_collab/api/tasks'
|
5
|
+
require 'active_collab/api/time_records'
|
6
|
+
require 'active_collab/api/users'
|
7
|
+
|
8
|
+
module ActiveCollab
|
9
|
+
class Client
|
10
|
+
|
11
|
+
include ActiveCollab::API::Projects
|
12
|
+
include ActiveCollab::API::Tasks
|
13
|
+
include ActiveCollab::API::TimeRecords
|
14
|
+
include ActiveCollab::API::Users
|
15
|
+
|
16
|
+
def initialize(url, api_key)
|
17
|
+
@api_url = url
|
18
|
+
@api_key = api_key
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'active_collab/project'
|
2
|
+
module ActiveCollab
|
3
|
+
module API
|
4
|
+
module Projects
|
5
|
+
|
6
|
+
def projects
|
7
|
+
url = "#{@api_url}?path_info=/projects&auth_api_token=#{@api_key}"
|
8
|
+
response = HTTParty.get(url)
|
9
|
+
response_projects = response["projects"].first[1]
|
10
|
+
projects = response_projects.collect do |p|
|
11
|
+
ActiveCollab::Project.from_hash(p)
|
12
|
+
end
|
13
|
+
projects
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'active_collab/task'
|
2
|
+
|
3
|
+
module ActiveCollab
|
4
|
+
module API
|
5
|
+
module Tasks
|
6
|
+
|
7
|
+
def tasks(project_id)
|
8
|
+
url = "#{@api_url}?path_info=/projects/#{project_id}/tasks&auth_api_token=#{@api_key}"
|
9
|
+
response = HTTParty.get(url)
|
10
|
+
response_tasks = response["tasks"].first[1]
|
11
|
+
if response_tasks.kind_of?(Hash)
|
12
|
+
tasks = [ActiveCollab::Task.from_hash(response_tasks)]
|
13
|
+
else
|
14
|
+
tasks = response_tasks.collect do |t|
|
15
|
+
ActiveCollab::Task.from_hash(t)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
tasks
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'active_collab/time_record'
|
2
|
+
|
3
|
+
module ActiveCollab
|
4
|
+
module API
|
5
|
+
module TimeRecords
|
6
|
+
|
7
|
+
def create_time_record(args = {})
|
8
|
+
url = "#{@api_url}?auth_api_token=#{@api_key}&path_info=projects/#{args[:project_id]}/tasks/#{args[:task_id]}/tracking/time/add"
|
9
|
+
body = "submitted=submitted&time_record[user_id]=#{args[:user_id]}&time_record[value]=#{args[:time]}&time_record[record_date]=#{args[:record_date]}&time_record[job_type_id]=1"
|
10
|
+
response = HTTParty.post(url, :body => body)
|
11
|
+
ActiveCollab::TimeRecord.from_hash(response)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'active_collab/user'
|
2
|
+
|
3
|
+
module ActiveCollab
|
4
|
+
module API
|
5
|
+
module Users
|
6
|
+
|
7
|
+
def self.user_info
|
8
|
+
url = "#{@api_url}?auth_api_token=#{@api_key}&path_info=info"
|
9
|
+
response = HTTParty.get(url)
|
10
|
+
response_user = response["info"]
|
11
|
+
user = ActiveCollab::User.from_info(response_user)
|
12
|
+
user
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class ActiveCollab::Project
|
2
|
+
attr_accessor :id, :name, :permalink, :state, :is_completed,
|
3
|
+
:category_id, :label_id, :company_id, :is_member
|
4
|
+
|
5
|
+
|
6
|
+
def self.from_hash(hash)
|
7
|
+
project = ActiveCollab::Project.new
|
8
|
+
project.id = hash["id"].to_i
|
9
|
+
project.name = hash["name"]
|
10
|
+
project.permalink = hash["permalink"]
|
11
|
+
project.state = hash["state"].to_i
|
12
|
+
project.is_completed = hash["is_completed"].to_i
|
13
|
+
project.category_id = hash["category_id"].to_i
|
14
|
+
project.label_id = hash["label_id"].to_i
|
15
|
+
project.company_id = hash["company_.to_iid"].to_i
|
16
|
+
project.is_member = hash["is_member"].to_i
|
17
|
+
project
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class ActiveCollab::Task
|
2
|
+
|
3
|
+
attr_accessor :id, :name, :permalink, :state, :visibility, :is_completed,
|
4
|
+
:comments_url, :comments_count, :is_locked, :subtasks_url,
|
5
|
+
:total_subtasks, :open_subtasks, :completed_subtasks, :attachments_url,
|
6
|
+
:attachments_count, :assignee_id, :delegated_by_id, :other_assignee_ids,
|
7
|
+
:category_id, :label_id, :user_is_subscribed, :version, :priority, :due_on,
|
8
|
+
:project_id, :milestone_id, :task_id
|
9
|
+
|
10
|
+
|
11
|
+
def self.from_hash(hash)
|
12
|
+
task = ActiveCollab::Task.new
|
13
|
+
task.id = hash["id"].to_i
|
14
|
+
task.name = hash["name"]
|
15
|
+
task.permalink = hash["permalink"]
|
16
|
+
task.state = hash["state"].to_i
|
17
|
+
task.is_completed = hash["is_completed"].to_i
|
18
|
+
task.comments_url = hash["comments_url"]
|
19
|
+
task.comments_count = hash["comments_count"].to_i
|
20
|
+
task.is_locked = hash["is_locked"].to_i
|
21
|
+
task.subtasks_url = hash["subtasks_url"]
|
22
|
+
task.total_subtasks = hash["total_subtasks"].to_i
|
23
|
+
task.open_subtasks = hash["open_subtasks"].to_i
|
24
|
+
task.completed_subtasks = hash["completed_subtasks"].to_i
|
25
|
+
task.attachments_url = hash["attachments_url"]
|
26
|
+
task.attachments_count = hash["attachments_count"].to_i
|
27
|
+
task.assignee_id = hash["assignee_id"].to_i
|
28
|
+
task.delegated_by_id = hash["delegated_by_id"].to_i
|
29
|
+
task.other_assignee_ids = hash["other_assignee_ids"]
|
30
|
+
task.category_id = hash["category_id"].to_i
|
31
|
+
task.label_id = hash["label_id"].to_i
|
32
|
+
task.user_is_subscribed = hash["user_is_subscribed"].to_i
|
33
|
+
task.version = hash["version"]
|
34
|
+
task.priority = hash["priority"].to_i
|
35
|
+
task.due_on = hash["due_on"].to_i
|
36
|
+
task.project_id = hash["project_id"].to_i
|
37
|
+
task.milestone_id = hash["milestone_id"].to_i
|
38
|
+
task.task_id = hash["task_id"].to_i
|
39
|
+
task
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class ActiveCollab::TimeRecord
|
2
|
+
|
3
|
+
attr_accessor :id, :permalink, :urls, :permissions,
|
4
|
+
:created_on, :created_by, :parent_class, :parent_id, :state,
|
5
|
+
:project_id, :billable_status, :value, :record_date, :summary, :user_id, :job_type_id
|
6
|
+
|
7
|
+
def self.from_hash(hash)
|
8
|
+
time_record = ActiveCollab::TimeRecord.new
|
9
|
+
time_record.id = hash["id"].to_i
|
10
|
+
time_record.permalink = hash["permalink"]
|
11
|
+
time_record.urls = hash["urls"]
|
12
|
+
time_record.permissions = hash["permissions"]
|
13
|
+
time_record.created_on = hash["created_on"]
|
14
|
+
time_record.created_by = hash["created_by"]
|
15
|
+
time_record.parent_class = hash["parent_class"]
|
16
|
+
time_record.parent_id = hash["parent_id"].to_i
|
17
|
+
time_record.state = hash["state"].to_i
|
18
|
+
time_record.project_id = hash["project"]["id"].to_i
|
19
|
+
time_record.billable_status = hash["billable_status"].to_i
|
20
|
+
time_record.value = hash["value"].to_f
|
21
|
+
time_record.record_date = hash["record_date"]
|
22
|
+
time_record.summary = hash["summary"]
|
23
|
+
time_record.user_id = hash["user"]["id"]
|
24
|
+
time_record.job_type_id = hash["job_type"]["id"]
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class ActiveCollab::User
|
2
|
+
|
3
|
+
attr_accessor :id, :name, :permalink, :state, :first_name, :last_name, :display_name, :short_display_name, :email
|
4
|
+
|
5
|
+
def self.from_info(hash)
|
6
|
+
user = ActiveCollab::User.new(api_url, token)
|
7
|
+
user.id = hash["logged_user"]["id"].to_i
|
8
|
+
user.name = hash["logged_user"]["name"]
|
9
|
+
user.permalink = hash["logged_user"]["permalink"]
|
10
|
+
user.state = hash["logged_user"]["state"].to_i
|
11
|
+
user.first_name = hash["logged_user"]["first_name"]
|
12
|
+
user.last_name = hash["logged_user"]["last_name"]
|
13
|
+
user.display_name = hash["logged_user"]["display_name"]
|
14
|
+
user.short_display_name = hash["logged_user"]["short_display_name"]
|
15
|
+
user.email = hash["logged_user"]["email"]
|
16
|
+
user
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_collab
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Marcos Beirigo
|
9
|
+
- Diogo Soares
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-11-28 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: httparty
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.9.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 0.9.0
|
31
|
+
description: activecollab ruby
|
32
|
+
email:
|
33
|
+
- marcosbeirigo@gmail.com
|
34
|
+
- diogo@jera.com.br
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- .gitignore
|
40
|
+
- .rvmrc
|
41
|
+
- Gemfile
|
42
|
+
- LICENSE.txt
|
43
|
+
- README.md
|
44
|
+
- Rakefile
|
45
|
+
- active_collab.gemspec
|
46
|
+
- lib/active_collab.rb
|
47
|
+
- lib/active_collab/api/projects.rb
|
48
|
+
- lib/active_collab/api/tasks.rb
|
49
|
+
- lib/active_collab/api/time_records.rb
|
50
|
+
- lib/active_collab/api/users.rb
|
51
|
+
- lib/active_collab/project.rb
|
52
|
+
- lib/active_collab/task.rb
|
53
|
+
- lib/active_collab/time_record.rb
|
54
|
+
- lib/active_collab/user.rb
|
55
|
+
- lib/active_collab/version.rb
|
56
|
+
homepage: ''
|
57
|
+
licenses: []
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 1.8.24
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: activecollab ruby
|
80
|
+
test_files: []
|