logan 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/logan.rb +5 -0
- data/lib/logan/HashConstructed.rb +5 -0
- data/lib/logan/client.rb +32 -0
- data/lib/logan/person.rb +18 -0
- data/lib/logan/project.rb +44 -0
- data/lib/logan/todo.rb +35 -0
- data/lib/logan/todolist.rb +61 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2789afc7c6d4908c48d1bf873f9c6aac1323cf78
|
4
|
+
data.tar.gz: 3172a2e197722f165650110b828f80fc9ecdeca8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 38d7a50df1e90da2f7eaa55d57e977e72c66b51b89641164614eb146c3083385968a63c682b52a9ee2bb44c0de1bd0d82e915ea14276a6f751b3df4124a2aa4f
|
7
|
+
data.tar.gz: 4ee8585357bccae264b7075077dbbb2baab91bab96b5230368308e7e5338d5306b729a18bde04932e57cf569edc8490833226bc0738b130c2a1ef95629accec7
|
data/lib/logan.rb
ADDED
data/lib/logan/client.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'logan/project'
|
2
|
+
|
3
|
+
module Logan
|
4
|
+
class Client
|
5
|
+
include HTTParty
|
6
|
+
|
7
|
+
def initialize(basecamp_id, username, password, user_agent)
|
8
|
+
self.class.base_uri "https://basecamp.com/#{basecamp_id}/api/v1"
|
9
|
+
self.class.basic_auth username, password
|
10
|
+
self.class.headers 'User-Agent' => user_agent
|
11
|
+
end
|
12
|
+
|
13
|
+
def projects
|
14
|
+
response = self.class.get '/projects.json'
|
15
|
+
response.parsed_response.map { |h| p = Logan::Project.new(h) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def todolists
|
19
|
+
response = self.class.get '/todolists.json'
|
20
|
+
|
21
|
+
response.parsed_response.map do |h|
|
22
|
+
list = Logan::TodoList.new(h)
|
23
|
+
|
24
|
+
# grab the project ID for this list from the url
|
25
|
+
list.project_id = list.url.scan( /projects\/(\d+)/).last.first
|
26
|
+
|
27
|
+
# return the list so this method returns an array of lists
|
28
|
+
list
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/logan/person.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'logan/HashConstructed'
|
2
|
+
|
3
|
+
module Logan
|
4
|
+
class Person
|
5
|
+
include HashConstructed
|
6
|
+
|
7
|
+
attr_accessor :id
|
8
|
+
attr_accessor :name
|
9
|
+
|
10
|
+
def to_hash
|
11
|
+
{ :id => @id, :type => "Person" }
|
12
|
+
end
|
13
|
+
|
14
|
+
def post_json
|
15
|
+
self.to_hash.to_json
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'logan/HashConstructed'
|
2
|
+
require 'logan/todolist'
|
3
|
+
|
4
|
+
module Logan
|
5
|
+
class Project
|
6
|
+
include HashConstructed
|
7
|
+
|
8
|
+
attr_accessor :id
|
9
|
+
attr_accessor :name
|
10
|
+
|
11
|
+
def todolists
|
12
|
+
active_response = Logan::Client.get "/projects/#{@id}/todolists.json"
|
13
|
+
lists_array = active_response.parsed_response.map do |h|
|
14
|
+
Logan::TodoList.new h.merge({ :project_id => @id })
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def completed_todolists
|
19
|
+
completed_response = Logan::Client.get "/projects/#{@id}/todolists/completed.json"
|
20
|
+
lists_array = completed_response.parsed_response.map do |h|
|
21
|
+
Logan::TodoList.new h.merge({ :project_id => @id })
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def all_todolists
|
26
|
+
todolists + completed_todolists
|
27
|
+
end
|
28
|
+
|
29
|
+
def todolist(list_id)
|
30
|
+
response = Logan::Client.get "/projects/#{@id}/todolists/#{list_id}.json"
|
31
|
+
Logan::TodoList.new response.parsed_response.merge({ :project_id => @id })
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_todolist(todolist)
|
35
|
+
post_params = {
|
36
|
+
:body => todolist.post_json,
|
37
|
+
:headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'})
|
38
|
+
}
|
39
|
+
|
40
|
+
response = Logan::Client.post "/projects/#{@id}/todolists.json", post_params
|
41
|
+
Logan::TodoList.new response.merge({ :project_id => @id })
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/logan/todo.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'logan/HashConstructed'
|
2
|
+
require 'logan/person'
|
3
|
+
|
4
|
+
module Logan
|
5
|
+
class Todo
|
6
|
+
include HashConstructed
|
7
|
+
|
8
|
+
attr_accessor :id
|
9
|
+
attr_accessor :content
|
10
|
+
attr_accessor :completed
|
11
|
+
attr_accessor :assignee
|
12
|
+
attr_accessor :due_at
|
13
|
+
|
14
|
+
def post_json
|
15
|
+
{
|
16
|
+
:content => @content,
|
17
|
+
:due_at => @due_at,
|
18
|
+
:assignee => @assignee.to_hash
|
19
|
+
}.to_json
|
20
|
+
end
|
21
|
+
|
22
|
+
def put_json
|
23
|
+
{
|
24
|
+
:content => @content,
|
25
|
+
:assignee => @assignee.to_hash,
|
26
|
+
:due_at => @due_at,
|
27
|
+
:completed => @completed
|
28
|
+
}.to_json
|
29
|
+
end
|
30
|
+
|
31
|
+
def assignee=(assignee)
|
32
|
+
@assignee = assignee.is_a?(Hash) ? Logan::Person.new(assignee) : assignee
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'logan/HashConstructed'
|
2
|
+
require 'logan/todo'
|
3
|
+
|
4
|
+
module Logan
|
5
|
+
class TodoList
|
6
|
+
include HashConstructed
|
7
|
+
|
8
|
+
attr_accessor :id
|
9
|
+
attr_accessor :project_id
|
10
|
+
attr_accessor :name
|
11
|
+
attr_accessor :description
|
12
|
+
attr_accessor :completed
|
13
|
+
attr_accessor :remaining_todos
|
14
|
+
attr_accessor :completed_todos
|
15
|
+
attr_accessor :url
|
16
|
+
|
17
|
+
def initialize(h)
|
18
|
+
@remaining_todos = []
|
19
|
+
@completed_todos = []
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def post_json
|
24
|
+
{ :name => @name, :description => @description }.to_json
|
25
|
+
end
|
26
|
+
|
27
|
+
def todos=(todo_hash)
|
28
|
+
@remaining_todos = todo_hash['remaining'].map { |h| Logan::Todo.new h }
|
29
|
+
@completed_todos = todo_hash['completed'].map { |h| Logan::Todo.new h }
|
30
|
+
end
|
31
|
+
|
32
|
+
def todo_with_substring(substring)
|
33
|
+
issue_todo = @remaining_todos.detect{ |t| !t.content.index(substring).nil? }
|
34
|
+
issue_todo ||= @completed_todos.detect { |t| !t.content.index(substring).nil? }
|
35
|
+
end
|
36
|
+
|
37
|
+
def create_todo(todo)
|
38
|
+
post_params = {
|
39
|
+
:body => todo.post_json,
|
40
|
+
:headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'})
|
41
|
+
}
|
42
|
+
|
43
|
+
response = Logan::Client.post "/projects/#{@project_id}/todolists/#{@id}/todos.json", post_params
|
44
|
+
Logan::Todo.new response
|
45
|
+
end
|
46
|
+
|
47
|
+
def update_todo(todo)
|
48
|
+
put_params = {
|
49
|
+
:body => todo.put_json,
|
50
|
+
:headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'})
|
51
|
+
}
|
52
|
+
|
53
|
+
response = Logan::Client.put "/projects/#{@project_id}/todos/#{todo.id}.json", put_params
|
54
|
+
Logan::Todo.new response
|
55
|
+
end
|
56
|
+
|
57
|
+
def delete_todo(todo)
|
58
|
+
response = Logan::Client.delete "/projects/#{@project_id}/todos/#{todo.id}.json"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logan
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stephen Birarda
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: logan@birarda.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/logan.rb
|
20
|
+
- lib/logan/client.rb
|
21
|
+
- lib/logan/HashConstructed.rb
|
22
|
+
- lib/logan/person.rb
|
23
|
+
- lib/logan/project.rb
|
24
|
+
- lib/logan/todo.rb
|
25
|
+
- lib/logan/todolist.rb
|
26
|
+
homepage: http://rubygems.org/gems/logan
|
27
|
+
licenses: []
|
28
|
+
metadata: {}
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 2.0.3
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: Ruby wrapper for new Basecamp API
|
49
|
+
test_files: []
|