codebase_api 0.1.0

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.
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in codebase_api.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Dean Perry
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,300 @@
1
+ # CodebaseApi
2
+
3
+ A gem to interact with the [Codebase](http://www.codebasehq.com) API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'codebase_api'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install codebase_api
18
+
19
+ ## Usage
20
+
21
+ The Codebase API requires authentication using your account name & username along with your API Key.
22
+
23
+ In a Rails app, create a file called `config/initializers/codebase.rb` and fill it with this info (changing it for your account, etc)
24
+
25
+ ```ruby
26
+ CodebaseApi.account_user = "account/user"
27
+ CodebaseApi.api_key = "apikey"
28
+ ```
29
+
30
+ ## Commands
31
+
32
+ The CodebaseApi gem is built to access all the Codebase API functions. Below are a list of commands currently supported.
33
+
34
+
35
+ ### Projects
36
+ #### All projects
37
+ ```ruby
38
+ CodebaseApi::Project.all
39
+ ```
40
+
41
+ #### Shows a specific project
42
+ ```ruby
43
+ CodebaseApi::Project.view("my-cool-project")
44
+ ```
45
+
46
+ #### Create a new project
47
+ ```ruby
48
+ CodebaseApi::Project.create("a new project")
49
+ ```
50
+
51
+
52
+ ### Project Groups
53
+ #### All project groups
54
+ ```ruby
55
+ CodebaseApi::ProjectGroup.all
56
+ ```
57
+
58
+
59
+ ### Project Users
60
+ #### All users assigned to a project
61
+ ```ruby
62
+ CodebaseApi::ProjectUser.all("my-cool-project")
63
+ ```
64
+
65
+ #### Assign users to a project
66
+ ```ruby
67
+ CodebaseApi::ProjectUser.assign("my-cool-project", [{:id => 123}, {:id => 321}])
68
+ ```
69
+
70
+
71
+ ### Repositories
72
+ #### All repositories for a project
73
+ ```ruby
74
+ CodebaseApi::Repository.all("my-cool-project")
75
+ ```
76
+
77
+ #### View a specified repository
78
+ ```ruby
79
+ CodebaseApi::Repository.show("my-cool-project", "test-repo")
80
+ ```
81
+
82
+ #### Create a repository for a project
83
+ The types of repository are Git (git), Subversion (svn), Mercurial (hg) and Bazaar (bzr).
84
+ ```ruby
85
+ CodebaseApi::Repository.create("my-cool-project", "new-repo-name", "git")
86
+ ```
87
+
88
+
89
+ ### Commits
90
+ #### Show a list of commits for a specific ref (short or long)
91
+ ```ruby
92
+ CodebaseApi::Commit.show("my-cool-project", "test-repo", "abc123abc")
93
+ ```
94
+
95
+ #### Show a list of commits for a specific ref (short or long) for a path
96
+ ```ruby
97
+ CodebaseApi::Commit.show_path("my-cool-project", "test-repo", "abc123abc", "spec/features/admin_spec.rb")
98
+ ```
99
+
100
+
101
+ ### Deployments
102
+ #### Create a deployment for a project & repository
103
+ ```ruby
104
+ CodebaseApi::Deployment.create("my-cool-project", "test-repo", "branch", "revision", "environment", "servers")
105
+ ```
106
+
107
+
108
+ ### Hooks
109
+ #### Show the hooks for a project & repository
110
+ ```ruby
111
+ CodebaseApi::Hook.all("my-cool-project", "test-repo")
112
+ ```
113
+
114
+ #### Create a hook for a project & repository
115
+ By default the username and password are nil
116
+ ```ruby
117
+ CodebaseApi::Hook.create("my-cool-project", "test-repo", "url", "username", "password")
118
+ ```
119
+
120
+
121
+ ### Tickets
122
+ #### All tickets for a project
123
+ ```ruby
124
+ CodebaseApi::Ticket.all("my-cool-project")
125
+ ```
126
+
127
+ #### Search all tickets in a project
128
+ ```ruby
129
+ CodebaseApi::Ticket.search("my-cool-project", "query")
130
+ ```
131
+
132
+ #### Create a new ticket for a project
133
+ ```ruby
134
+ CodebaseApi::Ticket.create("my-cool-project", "ticket title", "ticket description")
135
+ ```
136
+
137
+ #### Show all the notes for a ticket
138
+ ```ruby
139
+ CodebaseApi::Ticket.show("my-cool-project", ticket_id)
140
+ ```
141
+
142
+ #### Show a specific ticket note
143
+ ```ruby
144
+ CodebaseApi::Ticket.show_note("my-cool-project", ticket_id, note_id)
145
+ ```
146
+
147
+ #### Update a ticket
148
+ Unfortunately these are required otherwise it will set them to nil time_added, status_id, priority_id, category_id, assignee_id. To change the name of the ticket, change the summary.
149
+ ```ruby
150
+ CodebaseApi::Ticket.update("my-cool-project", ticket_id, "content", time_added=nil, status_id=nil, priority_id=nil, category_id=nil, assignee_id=nil, summary=nil)
151
+ ```
152
+
153
+ #### Show all ticket statuses for a project
154
+ ```ruby
155
+ CodebaseApi::Ticket.statuses("my-cool-project")
156
+ ```
157
+
158
+ #### Show all ticket priorities for a project
159
+ ```ruby
160
+ CodebaseApi::Ticket.priorities("my-cool-project")
161
+ ```
162
+
163
+ #### Show all ticket categories for a project
164
+ ```ruby
165
+ CodebaseApi::Ticket.categories("my-cool-project")
166
+ ```
167
+
168
+ #### Show all ticket milestones for a project
169
+ ```ruby
170
+ CodebaseApi::Ticket.milestones("my-cool-project")
171
+ ```
172
+
173
+ #### Show all watchers of a ticket for a project
174
+ ```ruby
175
+ CodebaseApi::Ticket.watchers("my-cool-project", ticket_id)
176
+ ```
177
+
178
+ ### Wiki
179
+ #### All the pages in the wiki for a project
180
+ ```ruby
181
+ CodebaseApi::Wiki.all("my-cool-project")
182
+ ```
183
+
184
+ #### Show a specific page in the wiki for a project
185
+ ```ruby
186
+ CodebaseApi::Wiki.show("my-cool-project", "page-name")
187
+ ```
188
+
189
+
190
+ ### Public Keys
191
+ #### All public keys for a user
192
+ ```ruby
193
+ CodebaseApi::PublicKey.all("username")
194
+ ```
195
+
196
+ #### All deployment keys for a project
197
+ ```ruby
198
+ CodebaseApi::PublicKey.deploy_keys("my-cool-project")
199
+ ```
200
+
201
+ #### Create a new public key for a user
202
+ ```ruby
203
+ CodebaseApi::PublicKey.create("username", "description", "key")
204
+ ```
205
+
206
+ #### Create a deployment key for a project
207
+ ```ruby
208
+ CodebaseApi::PublicKey.create_deployment("project", "description", "key")
209
+ ```
210
+
211
+
212
+ ### Users
213
+ #### All users
214
+ ```ruby
215
+ CodebaseApi::User.all
216
+ ```
217
+
218
+ #### All user roles
219
+ ```ruby
220
+ CodebaseApi::User.roles
221
+ ```
222
+
223
+ #### Create a new user
224
+ ```ruby
225
+ CodebaseApi::User.create("first name", "last name", "email address", role_id)
226
+ ```
227
+
228
+
229
+ ### Discussions
230
+ #### All discussions for a project
231
+ ```ruby
232
+ CodebaseApi::Discussion.all("my-cool-project")
233
+ ```
234
+
235
+ #### Show all the categories for discussions in a project
236
+ ```ruby
237
+ CodebaseApi::Discussion.categories("my-cool-project")
238
+ ```
239
+
240
+ #### Show a specific discussion for a project
241
+ ```ruby
242
+ CodebaseApi::Discussion.show("my-cool-project", "test-discussion")
243
+ ```
244
+
245
+ #### Create a new discussion for a project
246
+ ```ruby
247
+ CodebaseApi::Discussion.create("my-cool-project", "discussion title", "discussion content")
248
+ ```
249
+
250
+ #### Update a discussion for a project
251
+ ```ruby
252
+ CodebaseApi::Discussion.update("my-cool-project", "test-discussion", "discussion content")
253
+ ```
254
+
255
+
256
+ ### Time Sessions
257
+ #### All time sessions for a project
258
+ ```ruby
259
+ CodebaseApi::TimeSession.all("my-cool-project")
260
+ ```
261
+
262
+ #### Show time sessions added today for a project
263
+ ```ruby
264
+ CodebaseApi::TimeSession.today("my-cool-project")
265
+ ```
266
+
267
+ #### Show time sessions added this week for a project
268
+ ```ruby
269
+ CodebaseApi::TimeSession.this_week("my-cool-project")
270
+ ```
271
+
272
+ #### Show time sessions added this month for a project
273
+ ```ruby
274
+ CodebaseApi::TimeSession.this_month("my-cool-project")
275
+ ```
276
+
277
+ #### Create a new time session for a project
278
+ ```ruby
279
+ CodebaseApi::TimeSession.create("my-cool-project", "message", time)
280
+ ```
281
+
282
+ #### Show an existing time session for a project
283
+ ```ruby
284
+ CodebaseApi::TimeSession.show("my-cool-project", 123)
285
+ ```
286
+
287
+ #### Update an existing time session for a project
288
+ ```ruby
289
+ CodebaseApi::TimeSession.update("my-cool-project", 123, "message", time)
290
+ ```
291
+
292
+ #### Delete a time session for a project
293
+ ```ruby
294
+ CodebaseApi::TimeSession.delete("my-cool-project", 1234)
295
+ ```
296
+
297
+
298
+ ## Contributing
299
+
300
+ Fork this project, make any changes and create a pull request :)
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'codebase_api/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "codebase_api"
8
+ gem.version = CodebaseApi::VERSION
9
+ gem.authors = ["Dean Perry"]
10
+ gem.email = ["dean@deanperry.net"]
11
+ gem.description = %q{Ruby gem for accessing the Codebase API}
12
+ gem.summary = %q{Codebase API Ruby Gem}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_runtime_dependency "colorize"
21
+ end
@@ -0,0 +1,41 @@
1
+ require 'time'
2
+ require 'uri'
3
+ require 'net/https'
4
+ require 'json'
5
+ require 'colorize'
6
+
7
+ require "codebase_api/request"
8
+ require "codebase_api/project"
9
+ require "codebase_api/project_group"
10
+ require "codebase_api/project_user"
11
+ require "codebase_api/repository"
12
+ require "codebase_api/commit"
13
+ require "codebase_api/deployment"
14
+ require "codebase_api/hook"
15
+ require "codebase_api/ticket"
16
+ require "codebase_api/wiki"
17
+ require "codebase_api/public_key"
18
+ require "codebase_api/user"
19
+ require "codebase_api/discussion"
20
+ require "codebase_api/time_session"
21
+ require "codebase_api/version"
22
+
23
+ module CodebaseApi
24
+
25
+ class << self
26
+
27
+ # API Authentication
28
+ attr_accessor :account_user, :api_key
29
+
30
+ end
31
+
32
+ class Error < StandardError; end
33
+ module Errors
34
+ class ServiceUnavailable < Error; end
35
+ class AccessDenied < Error; end
36
+ class NotFound < Error; end
37
+ class CommunicationError < Error; end
38
+ class ValidationError < Error; end
39
+ end
40
+
41
+ end
@@ -0,0 +1,18 @@
1
+ module CodebaseApi
2
+ class Commit
3
+
4
+ class << self
5
+
6
+ # show all commits on a specified ref
7
+ def show(project, repo_name, ref)
8
+ CodebaseApi::Request.request("#{project}/#{repo_name}/commits/#{ref}")
9
+ end
10
+
11
+ # show all commits on a specified ref for a path
12
+ def show_path(project, repo_name, ref, path)
13
+ CodebaseApi::Request.request("#{project}/#{repo_name}/commits/#{ref}/#{path}")
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ module CodebaseApi
2
+ class Deployment
3
+
4
+ class << self
5
+
6
+ # create a deployment for a project & repo
7
+ def create(project, repo_name, branch, revision, environment, servers)
8
+ CodebaseApi::Request.request("#{project}/#{repo_name}/deployments", :post, {:deployment => {:branch => branch, :revision => revision, :environment => environment, :servers => servers}} )
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,33 @@
1
+ module CodebaseApi
2
+ class Discussion
3
+
4
+ class << self
5
+
6
+ # show all discussions for a project
7
+ def all(project)
8
+ CodebaseApi::Request.request("#{project}/discussions")
9
+ end
10
+
11
+ # show all discussion categories for a project
12
+ def categories(project)
13
+ CodebaseApi::Request.request("#{project}/discussions/categories")
14
+ end
15
+
16
+ # show all the posts in a discussion for a project
17
+ def show(project, discussion_permalink)
18
+ CodebaseApi::Request.request("#{project}/discussions/#{discussion_permalink}/posts")
19
+ end
20
+
21
+ # create a new discussion for a project
22
+ def create(project, subject, content, category_id=nil)
23
+ CodebaseApi::Request.request("#{project}/discussions", :post, {:discussion => {:subject => subject, :content => content, :category_id => category_id}} )
24
+ end
25
+
26
+ # update a discussion for a project
27
+ def update(project, discussion_permalink, content)
28
+ CodebaseApi::Request.request("#{project}/discussions/#{discussion_permalink}/posts", :post, {:discussion_post => {:content => content}} )
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,18 @@
1
+ module CodebaseApi
2
+ class Hook
3
+
4
+ class << self
5
+
6
+ # list the hooks for a repository
7
+ def all(project, repo_name)
8
+ CodebaseApi::Request.request("#{project}/#{repo_name}/hooks")
9
+ end
10
+
11
+ # create a hook for a project & repo
12
+ def create(project, repo_name, url, username=nil, password=nil)
13
+ CodebaseApi::Request.request("#{project}/#{repo_name}/hooks", :post, {:repository_hook => {:url => url, :username => username, :password => password}} )
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,30 @@
1
+ module CodebaseApi
2
+ class Project
3
+
4
+ class << self
5
+
6
+ # display all projects
7
+ def all
8
+ CodebaseApi::Request.request("projects")
9
+ end
10
+
11
+ # create project - name is required
12
+ def create(name)
13
+ CodebaseApi::Request.request("create_project", :post, {:project => {:name => name}})
14
+ end
15
+
16
+ # view a specific project
17
+ def view(project)
18
+ CodebaseApi::Request.request(project)
19
+ end
20
+
21
+ # delete a project
22
+ def delete(project)
23
+ CodebaseApi::Request.request(project, :delete)
24
+ return true
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,10 @@
1
+ module CodebaseApi
2
+ class ProjectGroup
3
+
4
+ # displays a list of all project groups
5
+ def self.all
6
+ CodebaseApi::Request.request("project_groups")
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ module CodebaseApi
2
+ class ProjectUser
3
+
4
+ # list of all users assigned to a project
5
+ def self.all(project)
6
+ CodebaseApi::Request.request("#{project}/assignments")
7
+ end
8
+
9
+ # assign users to a project
10
+ def self.assign(project, users)
11
+ CodebaseApi::Request.request("#{project}/assignments", :post, {:users => {:user => users } })
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,28 @@
1
+ module CodebaseApi
2
+ class PublicKey
3
+
4
+ class << self
5
+
6
+ # lists all the public keys for a user
7
+ def all(username)
8
+ CodebaseApi::Request.request("users/#{username}/public_keys")
9
+ end
10
+
11
+ # lists all the deployment keys for a project
12
+ def deploy_keys(project)
13
+ CodebaseApi::Request.request("#{project}/public_keys")
14
+ end
15
+
16
+ # create a new public key for a user
17
+ def create(username, description, key)
18
+ CodebaseApi::Request.request("users/#{username}/public_keys", :post, { :public_key => { :description => description, :key => key } })
19
+ end
20
+
21
+ # create a new deployment key for a project
22
+ def create_deployment(project, description, key)
23
+ CodebaseApi::Request.request("#{project}/public_keys", :post, { :public_key => { :description => description, :key => key } })
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ module CodebaseApi
2
+ class Repository
3
+
4
+ class << self
5
+
6
+ # lists all the repositories for a project
7
+ def all(project)
8
+ CodebaseApi::Request.request("#{project}/repositories")
9
+ end
10
+
11
+ # show a specified repository for a project
12
+ def show(project, repo_name)
13
+ CodebaseApi::Request.request("#{project}/#{repo_name}")
14
+ end
15
+
16
+ # creates a new repository for a project
17
+ def create(project, repo_name, repo_scm)
18
+ CodebaseApi::Request.request("#{project}/repositories", :post, {:repository => {:name => repo_name, :scm => repo_scm}})
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,87 @@
1
+ module CodebaseApi
2
+ class Request
3
+
4
+ def self.request(path, method=:get, data = {})
5
+ req = self.new(path, method)
6
+ req.data = data
7
+ req.make && req.success? ? req.output : false
8
+ end
9
+
10
+ attr_reader :path, :method
11
+ attr_accessor :data
12
+
13
+ def initialize(path, method = :get)
14
+ @path = path
15
+ @method = method
16
+ end
17
+
18
+ def success?
19
+ @success || false
20
+ end
21
+
22
+ def output
23
+ @output || nil
24
+ end
25
+
26
+ def make
27
+ uri = URI.parse(["https://api3.codebasehq.com", @path].join('/'))
28
+ http_request = http_class.new(uri.request_uri)
29
+ http_request.initialize_http_header({"User-Agent" => "CodebaseApiRubyClient/#{CodebaseApi::VERSION}"})
30
+ http_request.initialize_http_header({"Accept" => "application/json"})
31
+ http_request.content_type = "application/json"
32
+ http_request.basic_auth CodebaseApi.account_user, CodebaseApi.api_key
33
+
34
+ http = Net::HTTP.new(uri.host, uri.port)
35
+
36
+ if uri.scheme == 'https'
37
+ http.use_ssl = true
38
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
39
+ end
40
+
41
+ http_result = http.request(http_request, @data.to_json)
42
+ if http_result.body == 'true'
43
+ @output = true
44
+ elsif http_result.body == 'false'
45
+ @output = false
46
+ else
47
+ http_result.body.present? ? @output = JSON.parse(http_result.body) : @output
48
+ end
49
+ @success = case http_result
50
+ when Net::HTTPSuccess
51
+ true
52
+ when Net::HTTPServiceUnavailable
53
+ raise CodebaseApi::Errors::ServiceUnavailable
54
+ when Net::HTTPForbidden, Net::HTTPUnauthorized
55
+ raise CodebaseApi::Errors::AccessDenied, "Access Denied"
56
+ when Net::HTTPNotFound
57
+ json = JSON.parse(http_result.body)
58
+ raise CodebaseApi::Errors::NotFound, json['error']
59
+ when Net::HTTPBadRequest, Net::HTTPUnauthorized, Net::HTTPMethodNotAllowed
60
+ json = JSON.parse(http_result.body)
61
+ raise CodebaseApi::Errors::AccessDenied, "Access Denied for '#{CodebaseApi.application}' #{json['error']}"
62
+ else
63
+ raise CodebaseApi::Errors::CommunicationError, http_result.body
64
+ end
65
+
66
+ # show detailed info about the request
67
+ puts "[Codebase API] Sent: #{data}".yellow
68
+ puts "[Codebase API] Requesting: #{[path].join('/')} on https://api3.codebasehq.com".yellow
69
+ puts "[Codebase API] Response: #{http_result.body}".yellow
70
+
71
+ self
72
+ end
73
+
74
+ private
75
+
76
+ def http_class
77
+ case @method
78
+ when :post then Net::HTTP::Post
79
+ when :put then Net::HTTP::Put
80
+ when :delete then Net::HTTP::Delete
81
+ else
82
+ Net::HTTP::Get
83
+ end
84
+ end
85
+
86
+ end
87
+ end
@@ -0,0 +1,65 @@
1
+ module CodebaseApi
2
+ class Ticket
3
+
4
+ class << self
5
+
6
+ # list the tickets for a project
7
+ def all(project)
8
+ CodebaseApi::Request.request("#{project}/tickets")
9
+ end
10
+
11
+ # search all tickets
12
+ def search(project, query)
13
+ CodebaseApi::Request.request("#{project}/tickets?query=#{query}")
14
+ end
15
+
16
+ # create a new ticket for a project
17
+ def create(project, summary, description)
18
+ CodebaseApi::Request.request("#{project}/tickets", :post, {:ticket => {:summary => summary, :description => description}} )
19
+ end
20
+
21
+ # view the notes for a ticket
22
+ def show(project, ticket_id)
23
+ CodebaseApi::Request.request("#{project}/tickets/#{ticket_id}/notes")
24
+ end
25
+
26
+ # show a specific note for a ticket
27
+ def show_note(project, ticket_id, note_id)
28
+ CodebaseApi::Request.request("#{project}/tickets/#{ticket_id}/notes/#{note_id}")
29
+ end
30
+
31
+ # create a note for a ticket
32
+ def update(project, ticket_id, content, time_added=nil, status_id=nil, priority_id=nil, category_id=nil, assignee_id=nil, summary=nil)
33
+ attributes = {:ticket_note => { :content => content, :time_added => time_added, :changes => { :status_id => status_id, :priority_id => priority_id, :category_id => category_id, :assignee_id => assignee_id, :summary => summary } } }
34
+ CodebaseApi::Request.request("#{project}/tickets/#{ticket_id}/notes", :post, attributes)
35
+ end
36
+
37
+
38
+ # show all ticket statuses
39
+ def statuses(project)
40
+ CodebaseApi::Request.request("#{project}/tickets/statuses")
41
+ end
42
+
43
+ # show all ticket priorities
44
+ def priorities(project)
45
+ CodebaseApi::Request.request("#{project}/tickets/priorities")
46
+ end
47
+
48
+ # show all ticket categories
49
+ def categories(project)
50
+ CodebaseApi::Request.request("#{project}/tickets/categories")
51
+ end
52
+
53
+ # show all milestones
54
+ def milestones(project)
55
+ CodebaseApi::Request.request("#{project}/milestones")
56
+ end
57
+
58
+ # show all watchers for a ticket
59
+ def watchers(project, ticket_id)
60
+ CodebaseApi::Request.request("#{project}/tickets/#{ticket_id}/watchers")
61
+ end
62
+
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,49 @@
1
+ module CodebaseApi
2
+ class TimeSession
3
+
4
+ class << self
5
+
6
+ # show all time sessions for a project
7
+ def all(project)
8
+ CodebaseApi::Request.request("#{project}/time_sessions")
9
+ end
10
+
11
+ # show time sessions added today for a project
12
+ def today(project)
13
+ CodebaseApi::Request.request("#{project}/time_sessions/day")
14
+ end
15
+
16
+ # show time sessions added this week for a project
17
+ def this_week(project)
18
+ CodebaseApi::Request.request("#{project}/time_sessions/week")
19
+ end
20
+
21
+ # show time sessions added this month for a project
22
+ def this_month(project)
23
+ CodebaseApi::Request.request("#{project}/time_sessions/month")
24
+ end
25
+
26
+ # create a new time session for a project
27
+ def create(project, summary, minutes)
28
+ CodebaseApi::Request.request("#{project}/time_sessions", :post, {:time_session => {:summary => summary, :minutes => minutes}} )
29
+ end
30
+
31
+ # show an existing time session for a project
32
+ def show(project, time_session)
33
+ CodebaseApi::Request.request("#{project}/time_sessions/#{time_session}")
34
+ end
35
+
36
+ # update an existing time session for a project
37
+ def update(project, time_session, summary, minutes)
38
+ CodebaseApi::Request.request("#{project}/time_sessions/#{time_session}", :put, {:time_session => {:summary => summary, :minutes => minutes}})
39
+ end
40
+
41
+ # delete an existing time session for a project
42
+ def delete(project, time_session)
43
+ CodebaseApi::Request.request("#{project}/time_sessions/#{time_session}", :delete)
44
+ return true
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,23 @@
1
+ module CodebaseApi
2
+ class User
3
+
4
+ class << self
5
+
6
+ # list all users
7
+ def all
8
+ CodebaseApi::Request.request("users")
9
+ end
10
+
11
+ # list all roles
12
+ def roles
13
+ CodebaseApi::Request.request("roles")
14
+ end
15
+
16
+ # create a user
17
+ def create(first_name, last_name, email_address, role_id=nil)
18
+ CodebaseApi::Request.request("users", :post, { :user => { :first_name => first_name, :last_name => last_name, :email_address => email_address, :role_id => role_id } } )
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module CodebaseApi
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,18 @@
1
+ module CodebaseApi
2
+ class Wiki
3
+
4
+ class << self
5
+
6
+ # lists all the wiki pages for a project
7
+ def all(project)
8
+ CodebaseApi::Request.request("#{project}/wiki/index")
9
+ end
10
+
11
+ # show a specified wiki page for a project
12
+ def show(project, page_name)
13
+ CodebaseApi::Request.request("#{project}/wiki/#{page_name}")
14
+ end
15
+
16
+ end
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: codebase_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dean Perry
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: colorize
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
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: '0'
30
+ description: Ruby gem for accessing the Codebase API
31
+ email:
32
+ - dean@deanperry.net
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - codebase_api.gemspec
43
+ - lib/codebase_api.rb
44
+ - lib/codebase_api/commit.rb
45
+ - lib/codebase_api/deployment.rb
46
+ - lib/codebase_api/discussion.rb
47
+ - lib/codebase_api/hook.rb
48
+ - lib/codebase_api/project.rb
49
+ - lib/codebase_api/project_group.rb
50
+ - lib/codebase_api/project_user.rb
51
+ - lib/codebase_api/public_key.rb
52
+ - lib/codebase_api/repository.rb
53
+ - lib/codebase_api/request.rb
54
+ - lib/codebase_api/ticket.rb
55
+ - lib/codebase_api/time_session.rb
56
+ - lib/codebase_api/user.rb
57
+ - lib/codebase_api/version.rb
58
+ - lib/codebase_api/wiki.rb
59
+ homepage: ''
60
+ licenses: []
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 1.8.24
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: Codebase API Ruby Gem
83
+ test_files: []