teamwork-pm 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ba5d5523cd0d13641b62034827d12b729a410b86
4
+ data.tar.gz: 99b523dde4bc3b9907ba4254cc5d3f16e646114a
5
+ SHA512:
6
+ metadata.gz: daa7d5ac14780270c956dedf1c8a7d3daa6117bf25eaa5cfcde926c1cf358ea7a1fb60d67091fd5fadc51dddc723ce97be16e142b07096d2b5ef09d4459cffa7
7
+ data.tar.gz: c194cf4e4609a0103bc049b07188ad72a16626027b2e53cb66ebee3785a86786aa956604a5c2d1122a3f7dbd722a38626a469e3b3ce5c616a25d18e2d7a2e05e
@@ -0,0 +1,25 @@
1
+ # -*- ruby -*-
2
+
3
+ require "autotest/restart"
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.testlib = "minitest/unit"
7
+ #
8
+ # at.extra_files << "../some/external/dependency.rb"
9
+ #
10
+ # at.libs << ":../some/external"
11
+ #
12
+ # at.add_exception "vendor"
13
+ #
14
+ # at.add_mapping(/dependency.rb/) do |f, _|
15
+ # at.files_matching(/test_.*rb$/)
16
+ # end
17
+ #
18
+ # %w(TestA TestB).each do |klass|
19
+ # at.extra_class_map[klass] = "test/test_misc.rb"
20
+ # end
21
+ # end
22
+
23
+ # Autotest.add_hook :run_command do |at|
24
+ # system "rake build"
25
+ # end
File without changes
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2013-10-04
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
@@ -0,0 +1,8 @@
1
+ .autotest
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ bin/teamwork
7
+ lib/teamwork.rb
8
+ test/test_teamwork.rb
@@ -0,0 +1,36 @@
1
+ = teamwork
2
+
3
+ == DESCRIPTION:
4
+
5
+ A gem wrapper for the TeamworkPM API
6
+
7
+ TeamworkPM: http://www.teamworkpm.net/
8
+ API: http://developer.teamworkpm.net/api
9
+
10
+ == REQUIREMENTS:
11
+
12
+ ruby 2.x
13
+
14
+ == INSTALL:
15
+
16
+ gem install teamwork
17
+
18
+ == API EXAMPLES:
19
+
20
+ require 'teamwork'
21
+
22
+ api = Teamwork::API.new project_name: 'your-site-name', api_key: 'your-api-key'
23
+
24
+ api.people pageSize: 100
25
+ api.people pageSize: 100, page: 2
26
+
27
+ == DEVELOPERS:
28
+
29
+ After checking out the source, run:
30
+
31
+ $ rake newb
32
+
33
+ This task will install any missing dependencies, run the tests/specs,
34
+ and generate the RDoc.
35
+
36
+
@@ -0,0 +1,23 @@
1
+ # -*- ruby -*-
2
+
3
+ require "rubygems"
4
+ require "hoe"
5
+
6
+ # Hoe.plugin :compiler
7
+ # Hoe.plugin :gem_prelude_sucks
8
+ # Hoe.plugin :inline
9
+ # Hoe.plugin :racc
10
+ # Hoe.plugin :rcov
11
+ # Hoe.plugin :rubyforge
12
+ Hoe.plugin :bundler
13
+
14
+ Hoe.spec "teamwork-pm" do
15
+ developer("Nathan Clark", "nathanclark80@gmail.com")
16
+ extra_deps << ['faraday']
17
+ extra_deps << ['faraday_middleware']
18
+ extra_deps << ['multi_json']
19
+ extra_deps << ['multipart-post']
20
+
21
+ license "MIT" # this should match the license in the README
22
+ end
23
+
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ abort "you need to write me"
@@ -0,0 +1,94 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+ require 'json'
4
+
5
+ module Teamwork
6
+
7
+ VERSION = "0.0.1"
8
+
9
+ class API
10
+
11
+ def initialize(project_name: nil, api_key: nil)
12
+ @project_name = project_name
13
+ @api_key = api_key
14
+ @api_conn = Faraday.new(url: "http://#{project_name}.teamworkpm.net/") do |c|
15
+ c.request :multipart
16
+ c.request :json
17
+ c.request :url_encoded
18
+ c.response :json, content_type: /\bjson$/
19
+ c.adapter :net_http
20
+ end
21
+
22
+ @api_conn.headers[:cache_control] = 'no-cache'
23
+ @api_conn.basic_auth(api_key, '')
24
+ end
25
+
26
+ def account(request_params)
27
+ response = @api_conn.get "account.json", request_params
28
+ response.body
29
+ end
30
+
31
+ def people(request_params)
32
+ response = @api_conn.get "people.json", request_params
33
+ response.body
34
+ end
35
+
36
+ def latestActivity(maxItems: 60, onlyStarred: false)
37
+ request_params = {
38
+ maxItems: maxItems,
39
+ onlyStarred: onlyStarred
40
+ }
41
+ response = @api_conn.get "latestActivity.json", request_params
42
+ response.body
43
+ end
44
+
45
+ def get_comment(id)
46
+ response = @api_conn.get "comments/#{id}.json"
47
+ response.body["comment"]
48
+ end
49
+
50
+ def get_company_id(name)
51
+ Hash[@api_conn.get('companies.json').body["companies"].map { |c| [c['name'], c['id']] }][name]
52
+ end
53
+
54
+ def create_company(name)
55
+ @api_conn.post 'companies.json', { company: { name: name } }
56
+ end
57
+
58
+ def get_or_create_company(name)
59
+ create_company(name) if !get_company_id(name)
60
+ get_company_id(name)
61
+ end
62
+
63
+ def create_project(name, client_name)
64
+ company_id = get_or_create_company(client_name)
65
+ @api_conn.post('projects.json', {
66
+ project: {
67
+ name: name,
68
+ companyId: company_id,
69
+ "category-id" => '0'
70
+ }
71
+ }).headers['id']
72
+ end
73
+
74
+ def update_project(id, name, client_name)
75
+ company_id = get_or_create_company(client_name)
76
+ @api_conn.put("projects/#{id}.json", {
77
+ project: {
78
+ name: name,
79
+ companyId: company_id
80
+ }
81
+ }).status
82
+ end
83
+
84
+ def delete_project(id)
85
+ @api_conn.delete "projects/#{id}.json"
86
+ end
87
+
88
+ def attach_post_to_project(title, body, project_id)
89
+ @api_conn.post "projects/#{project_id}/messsages.json", { post: { title: title, body: body } }
90
+ end
91
+ end
92
+ end
93
+
94
+
@@ -0,0 +1,8 @@
1
+ require "minitest/autorun"
2
+ require "teamwork"
3
+
4
+ class TestTeamwork < MiniTest::Unit::TestCase
5
+ def test_sanity
6
+ flunk "write tests or I will kneecap you"
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: teamwork-pm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Clark
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: multi_json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: multipart-post
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rdoc
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: hoe
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.13'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.13'
97
+ description: |-
98
+ A gem wrapper for the TeamworkPM API
99
+
100
+ TeamworkPM: http://www.teamworkpm.net/
101
+ API: http://developer.teamworkpm.net/api
102
+ email:
103
+ - nathanclark80@gmail.com
104
+ executables:
105
+ - teamwork
106
+ extensions: []
107
+ extra_rdoc_files:
108
+ - History.txt
109
+ - Manifest.txt
110
+ - README.txt
111
+ files:
112
+ - ".autotest"
113
+ - ".gemtest"
114
+ - History.txt
115
+ - Manifest.txt
116
+ - README.txt
117
+ - Rakefile
118
+ - bin/teamwork
119
+ - lib/teamwork.rb
120
+ - test/test_teamwork.rb
121
+ homepage:
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options:
127
+ - "--main"
128
+ - README.txt
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.2.2
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: 'A gem wrapper for the TeamworkPM API TeamworkPM: http://www.teamworkpm.net/
147
+ API: http://developer.teamworkpm.net/api'
148
+ test_files:
149
+ - test/test_teamwork.rb