adapt services changes from travis-core
This commit is contained in:
parent
c9c9dc61d8
commit
4328ba8649
10
Gemfile.lock
10
Gemfile.lock
|
@ -40,7 +40,7 @@ GIT
|
|||
|
||||
GIT
|
||||
remote: git://github.com/travis-ci/travis-core.git
|
||||
revision: c40cee1a6d66d0cc18034e6e5e90c335349ead97
|
||||
revision: 6be27b79c655f49eaa1468f9156bebdafdb85e52
|
||||
branch: sf-travis-api
|
||||
specs:
|
||||
travis-core (0.0.1)
|
||||
|
@ -62,7 +62,7 @@ GIT
|
|||
|
||||
GIT
|
||||
remote: git://github.com/travis-ci/travis-support.git
|
||||
revision: 06844d2db558d88be775ca1cf9cfff8ec36120fb
|
||||
revision: c51ef116f38e5192171112f347f9a2ba050fe636
|
||||
specs:
|
||||
travis-support (0.0.1)
|
||||
|
||||
|
@ -137,7 +137,7 @@ GEM
|
|||
i18n (0.6.1)
|
||||
journey (1.0.4)
|
||||
json (1.7.5)
|
||||
listen (0.5.2)
|
||||
listen (0.5.3)
|
||||
mail (2.4.4)
|
||||
i18n (>= 0.4.0)
|
||||
mime-types (~> 1.16)
|
||||
|
@ -148,7 +148,7 @@ GEM
|
|||
avl_tree (~> 1.1.2)
|
||||
hitimes (~> 1.1)
|
||||
mime-types (1.19)
|
||||
mocha (0.12.5)
|
||||
mocha (0.12.6)
|
||||
metaclass (~> 0.0.1)
|
||||
multi_json (1.3.6)
|
||||
multipart-post (1.1.5)
|
||||
|
@ -157,7 +157,7 @@ GEM
|
|||
newrelic_rpm (3.3.5)
|
||||
pg (0.13.2)
|
||||
polyglot (0.3.3)
|
||||
postmark (0.9.12)
|
||||
postmark (0.9.13)
|
||||
json
|
||||
rake
|
||||
postmark-rails (0.4.1)
|
||||
|
|
|
@ -83,7 +83,7 @@ class Travis::Api::App
|
|||
def self.setup_travis
|
||||
Travis::Amqp.config = Travis.config.amqp
|
||||
Travis::Database.connect
|
||||
# Travis::Services.namespace = Travis::Services
|
||||
Travis.services = Travis::Services
|
||||
end
|
||||
|
||||
def self.load_endpoints
|
||||
|
|
|
@ -9,7 +9,7 @@ class Travis::Api::App
|
|||
set(:prefix) { "/" << name[/[^:]+$/].underscore }
|
||||
set disable_root_endpoint: false
|
||||
register :scoping
|
||||
helpers :current_user
|
||||
helpers :current_user, :services
|
||||
|
||||
# TODO hmmm?
|
||||
before { content_type :json }
|
||||
|
|
|
@ -7,7 +7,7 @@ class Travis::Api::App
|
|||
class Artifacts < Endpoint
|
||||
# Fetches an artifact by it's *id*.
|
||||
get '/:id' do |id|
|
||||
respond_with one(params).run
|
||||
respond_with one(params).run || not_found
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,14 +7,27 @@ class Travis::Api::App
|
|||
respond_with all(params).run
|
||||
end
|
||||
|
||||
# get '/:owner_name/:name/builds' do # v1
|
||||
# get '/repos/:owner_name/:name/builds' do # v2
|
||||
get '/:id' do
|
||||
respond_with one(params).run || not_found
|
||||
end
|
||||
|
||||
# get '/repositories/:repository_id/builds' do # v1
|
||||
# get '/repos/:repository_id/builds' do # v2
|
||||
# respond_with all(params).run
|
||||
# end
|
||||
|
||||
get '/:id' do
|
||||
respond_with one(params).run
|
||||
end
|
||||
# get '/repositories/:repository_id/builds/1' do # v1
|
||||
# respond_with all(params).run
|
||||
# end
|
||||
|
||||
# get '/:owner_name/:name/builds' do # v1
|
||||
# get '/repos/:owner_name/:name/builds' do # v2
|
||||
# respond_with all(params).run
|
||||
# end
|
||||
|
||||
# get '/:owner_name/:name/builds/:id' do # v1
|
||||
# respond_with all(params).run
|
||||
# end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ class Travis::Api::App
|
|||
end
|
||||
|
||||
get '/:id' do
|
||||
respond_with one(params).run
|
||||
respond_with one(params).run || not_found
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,12 +8,12 @@ class Travis::Api::App
|
|||
end
|
||||
|
||||
get '/:id' do
|
||||
respond_with one(params).run
|
||||
respond_with one(params).run || not_found
|
||||
end
|
||||
|
||||
# TODO the format constraint neither seems to work nor fail?
|
||||
get '/:id/cc.:format', format: 'xml' do # v1
|
||||
respond_with one(params).run
|
||||
respond_with one(params).run || not_found
|
||||
end
|
||||
|
||||
# get '/:owner_name/:name.?:format?' do # v1
|
||||
|
|
|
@ -6,6 +6,10 @@ class Travis::Api::App
|
|||
get '/' do
|
||||
respond_with all(params).run
|
||||
end
|
||||
|
||||
get '/:id' do
|
||||
respond_with one(params).run || not_found
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,10 +3,23 @@ require 'travis/api/app'
|
|||
class Travis::Api::App
|
||||
module Helpers
|
||||
module Services
|
||||
def service(key, user = current_user)
|
||||
const = Travis.services[key] || raise("no service registered for #{key}")
|
||||
const.new(user)
|
||||
def all(params)
|
||||
service(services_namespace, :all, params)
|
||||
end
|
||||
|
||||
def one(params)
|
||||
service(services_namespace, :one, params)
|
||||
end
|
||||
|
||||
def update(params)
|
||||
service(services_namespace, :update, params)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def services_namespace
|
||||
self.class.name.split('::').last
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# api = lambda do
|
||||
# constraints :format => 'json' do
|
||||
# resources :repositories, :only => [:index, :show]
|
||||
# resources :repositories, :only => [:index, :show] do
|
||||
# resources :builds, :only => [:index, :show]
|
||||
# end
|
||||
# resources :builds, :only => [:index, :show]
|
||||
# resources :branches, :only => :index
|
||||
# resources :jobs, :only => [:index, :show]
|
||||
|
|
Loading…
Reference in New Issue
Block a user