adapt changes for split services

This commit is contained in:
Sven Fuchs 2012-09-29 18:12:41 +02:00
parent ff4dd4d61b
commit 5ff58b1d6c
12 changed files with 21 additions and 47 deletions

View File

@ -87,10 +87,7 @@ class Travis::Api::App
def self.setup_travis
Travis::Amqp.config = Travis.config.amqp
Travis::Database.connect
Travis::Services.constants.each do |name|
Travis.services[name.to_s.underscore.to_sym] = Travis::Services.const_get(name) unless name == :Base
end
# Travis::Services.namespace = Travis::Services
end
def self.load_endpoints

View File

@ -4,10 +4,12 @@ require 'addressable/uri'
class Travis::Api::App
# Superclass for HTTP endpoints. Takes care of prefixing.
class Endpoint < Responder
include Travis::Services
set(:prefix) { "/" << name[/[^:]+$/].underscore }
set disable_root_endpoint: false
register :scoping
helpers :services, :current_user
helpers :current_user # :services
before { content_type :json }
error(ActiveRecord::RecordNotFound, Sinatra::NotFound) { not_found }

View File

@ -4,7 +4,7 @@ class Travis::Api::App
class Endpoint
class Accounts < Endpoint
get '/', scope: :private do
body service(:account).find_all, type: :accounts
body all(params).run, type: :accounts
end
end
end

View File

@ -7,7 +7,7 @@ class Travis::Api::App
class Artifacts < Endpoint
# Fetches an artifact by it's *id*.
get('/:id') do |id|
body service(:artifacts).find_one(params)
body one(params).run
end
end
end

View File

@ -2,11 +2,9 @@ require 'travis/api/app'
class Travis::Api::App
class Endpoint
# TODO: Add documentation.
class Branches < Endpoint
# TODO: Add documentation.
get('/') do
body service(:branches).find_all(params), type: :branches
body all(params).run, type: :branches
end
end
end

View File

@ -2,16 +2,13 @@ require 'travis/api/app'
class Travis::Api::App
class Endpoint
# TODO: Add documentation.
class Builds < Endpoint
# TODO: Add documentation.
get '/' do
body service(:builds).find_all(params)
body all(params).run
end
# TODO: Add documentation.
get '/:id' do
body service(:builds).find_one(params)
body one(params).run
end
end
end

View File

@ -2,16 +2,14 @@ require 'travis/api/app'
class Travis::Api::App
class Endpoint
# TODO: Add documentation.
class Hooks < Endpoint
# TODO: Add implementation and documentation.
get('/', scope: :private) do
body service(:hooks).find_all(params), type: :hooks
body all(params).run, type: :hooks
end
# TODO: Add implementation and documentation.
put('/:id', scope: :private) do
body service(:hooks).update(params[:hook])
update(params[:hook]).run
204
end
end
end

View File

@ -2,16 +2,13 @@ require 'travis/api/app'
class Travis::Api::App
class Endpoint
# TODO: Add documentation.
class Jobs < Endpoint
# TODO: Add documentation.
get('/') do
body service(:jobs).find_all(params)
body all(params).run
end
# TODO: Add documentation.
get('/:id') do
body service(:jobs).find_one(params)
body one(params).run
end
end
end

View File

@ -2,16 +2,13 @@ require 'travis/api/app'
class Travis::Api::App
class Endpoint
# TODO: Add documentation.
class Repositories < Endpoint
# TODO: Add documentation.
get '/' do
body service(:repositories).find_all(params)
body all(params).run
end
# TODO: Add documentation.
get('/:id') do
body service(:repositories).find_one(params)
body one(params).run
end
# TODO make sure status images and cc.xml work

View File

@ -2,16 +2,13 @@ require 'travis/api/app'
class Travis::Api::App
class Endpoint
# TODO: Add documentation.
class Stats < Endpoint
# TODO: Add documentation.
get('/repos') do
{ :stats => service(:stats).daily_repository_counts }
{ :stats => service(:daily_repos) }
end
# TODO: Add documentation.
get('/tests') do
{ :stats => service(:stats).daily_tests_counts }
{ :stats => service(:daily_tests) }
end
end
end

View File

@ -23,21 +23,14 @@ class Travis::Api::App
end
put '/:id?', scope: :private do
service(:user).update_locale(locale)
update(params[:user]).run
204
end
# TODO: Add implementation and documentation.
post '/sync', scope: :private do
service(:user).sync
service(:sync).run
204
end
private
def locale
params[:user][:locale]
end
end
end
end

View File

@ -2,11 +2,9 @@ require 'travis/api/app'
class Travis::Api::App
class Endpoint
# TODO: Add documentation.
class Workers < Endpoint
# TODO: Add implementation and documentation.
get('/') do
body service(:workers).find_all(params)
body all(params).run
end
end
end