File tree 5 files changed +29
-10
lines changed 5 files changed +29
-10
lines changed Original file line number Diff line number Diff line change 36
36
37
37
GIT
38
38
remote: git://github.com/travis-ci/travis-core.git
39
- revision: b4c4ae9beb6ba8d813491273dc75fa582ee719b0
39
+ revision: a5277a1f47a8615672607026239af49a217e2830
40
40
specs:
41
41
travis-core (0.0.1 )
42
42
actionmailer (~> 3.2.19 )
84
84
travis-api (0.0.1 )
85
85
backports (~> 2.5 )
86
86
memcachier
87
+ mustermann (~> 0.4 )
87
88
pg (~> 0.13.2 )
88
89
rack-contrib (~> 1.1 )
89
90
rack-ssl (~> 1.3 , >= 1.3.3 )
214
215
metaclass (~> 0.0.1 )
215
216
multi_json (1.10.1 )
216
217
multipart-post (2.0.0 )
218
+ mustermann (0.4.0 )
219
+ tool (~> 0.2 )
217
220
net-http-persistent (2.9.4 )
218
221
net-http-pipeline (1.0.1 )
219
222
pg (0.13.2 )
312
315
tilt (1.4.1 )
313
316
timers (4.0.1 )
314
317
hitimes
318
+ tool (0.2.3 )
315
319
travis-config (0.1.0 )
316
320
hashr (~> 0.0 )
317
321
treetop (1.4.15 )
Original file line number Diff line number Diff line change 1
1
require 'travis/api/app'
2
2
require 'sinatra/base'
3
+ require 'mustermann'
3
4
4
5
class Travis ::Api ::App
5
6
# Superclass for any endpoint and middleware.
6
7
# Pulls in relevant helpers and extensions.
7
8
class Base < Sinatra ::Base
8
9
register Extensions ::SmartConstants
10
+ register Mustermann
9
11
10
12
error NotImplementedError do
11
13
content_type :txt
Original file line number Diff line number Diff line change 3
3
class Travis ::Api ::App
4
4
class Endpoint
5
5
class Repos < Endpoint
6
+ set :pattern , capture : { id : /\d +/ }
7
+
6
8
# Endpoint for getting all repositories.
7
9
#
8
10
# 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
18
20
end
19
21
end
20
22
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
-
29
23
# Gets the repository with the given id.
30
24
#
31
25
# ### Response
@@ -37,6 +31,13 @@ class Repos < Endpoint
37
31
end
38
32
end
39
33
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
+
40
41
get '/:id/cc' do
41
42
respond_with service ( :find_repo , params . merge ( schema : 'cc' ) )
42
43
end
Original file line number Diff line number Diff line change 1
1
require 'spec_helper'
2
2
3
3
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
5
16
end
Original file line number Diff line number Diff line change @@ -259,6 +259,7 @@ Gem::Specification.new do |s|
259
259
s . add_dependency 'thin' , '~> 1.4'
260
260
s . add_dependency 'sinatra' , '~> 1.3'
261
261
s . add_dependency 'sinatra-contrib' , '~> 1.3'
262
+ s . add_dependency 'mustermann' , '~> 0.4'
262
263
s . add_dependency 'redcarpet' , '~> 2.1'
263
264
s . add_dependency 'rack-ssl' , '~> 1.3' , '>= 1.3.3'
264
265
s . add_dependency 'rack-contrib' , '~> 1.1'
You can’t perform that action at this time.
0 commit comments