Skip to content

Commit fd10436

Browse files
committed
Merge pull request travis-ci#132 from travis-ci/rkh-mustermann
Pull in Mustermann
2 parents e58e4b4 + 219f65f commit fd10436

File tree

5 files changed

+29
-10
lines changed

5 files changed

+29
-10
lines changed

Gemfile.lock

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ GIT
3636

3737
GIT
3838
remote: git://github.com/travis-ci/travis-core.git
39-
revision: b4c4ae9beb6ba8d813491273dc75fa582ee719b0
39+
revision: a5277a1f47a8615672607026239af49a217e2830
4040
specs:
4141
travis-core (0.0.1)
4242
actionmailer (~> 3.2.19)
@@ -84,6 +84,7 @@ PATH
8484
travis-api (0.0.1)
8585
backports (~> 2.5)
8686
memcachier
87+
mustermann (~> 0.4)
8788
pg (~> 0.13.2)
8889
rack-contrib (~> 1.1)
8990
rack-ssl (~> 1.3, >= 1.3.3)
@@ -214,6 +215,8 @@ GEM
214215
metaclass (~> 0.0.1)
215216
multi_json (1.10.1)
216217
multipart-post (2.0.0)
218+
mustermann (0.4.0)
219+
tool (~> 0.2)
217220
net-http-persistent (2.9.4)
218221
net-http-pipeline (1.0.1)
219222
pg (0.13.2)
@@ -312,6 +315,7 @@ GEM
312315
tilt (1.4.1)
313316
timers (4.0.1)
314317
hitimes
318+
tool (0.2.3)
315319
travis-config (0.1.0)
316320
hashr (~> 0.0)
317321
treetop (1.4.15)

lib/travis/api/app/base.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
require 'travis/api/app'
22
require 'sinatra/base'
3+
require 'mustermann'
34

45
class Travis::Api::App
56
# Superclass for any endpoint and middleware.
67
# Pulls in relevant helpers and extensions.
78
class Base < Sinatra::Base
89
register Extensions::SmartConstants
10+
register Mustermann
911

1012
error NotImplementedError do
1113
content_type :txt

lib/travis/api/app/endpoint/repos.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
class Travis::Api::App
44
class Endpoint
55
class Repos < Endpoint
6+
set :pattern, capture: { id: /\d+/ }
7+
68
# Endpoint for getting all repositories.
79
#
810
# You can filter the repositories by adding parameters to the request. For example, you can get all repositories
@@ -18,14 +20,6 @@ class Repos < Endpoint
1820
end
1921
end
2022

21-
# Retrieves repositories for a given owner.
22-
get '/:owner_name' do
23-
pass if params[:owner_name] =~ /^\d+$/ # so we don't capture '/:id'
24-
prefer_follower do
25-
respond_with service(:find_repos, params)
26-
end
27-
end
28-
2923
# Gets the repository with the given id.
3024
#
3125
# ### Response
@@ -37,6 +31,13 @@ class Repos < Endpoint
3731
end
3832
end
3933

34+
# Retrieves repositories for a given owner.
35+
get '/:owner_name' do
36+
prefer_follower do
37+
respond_with service(:find_repos, params)
38+
end
39+
end
40+
4041
get '/:id/cc' do
4142
respond_with service(:find_repo, params.merge(schema: 'cc'))
4243
end

spec/unit/endpoint/repos_spec.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
require 'spec_helper'
22

33
describe Travis::Api::App::Endpoint::Repos do
4-
it 'has to be tested'
4+
before do
5+
described_class.get('/spec/match/:id') { "id" }
6+
described_class.get('/spec/match/:name') { "name" }
7+
end
8+
9+
it 'matches id with digits' do
10+
get('/repos/spec/match/123').body.should be == "id"
11+
end
12+
13+
it 'does not match id with non-digits' do
14+
get('/repos/spec/match/f123').body.should be == "name"
15+
end
516
end

travis-api.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ Gem::Specification.new do |s|
259259
s.add_dependency 'thin', '~> 1.4'
260260
s.add_dependency 'sinatra', '~> 1.3'
261261
s.add_dependency 'sinatra-contrib', '~> 1.3'
262+
s.add_dependency 'mustermann', '~> 0.4'
262263
s.add_dependency 'redcarpet', '~> 2.1'
263264
s.add_dependency 'rack-ssl', '~> 1.3', '>= 1.3.3'
264265
s.add_dependency 'rack-contrib', '~> 1.1'

0 commit comments

Comments
 (0)