rename services, remove service helpers

This commit is contained in:
Sven Fuchs 2012-10-12 01:24:04 +02:00
parent 56d1e0cec7
commit 209dbe2a85
13 changed files with 24 additions and 67 deletions

View File

@ -40,7 +40,7 @@ GIT
GIT
remote: git://github.com/travis-ci/travis-core.git
revision: 1448d4b1505b38014d3083f45500d371c8ec999f
revision: 3154d3fbfa6fe4202ade27f5712927b72dc1673b
branch: sf-travis-api
specs:
travis-core (0.0.1)

View File

@ -9,7 +9,7 @@ class Travis::Api::App
set(:prefix) { "/" << name[/[^:]+$/].underscore }
set disable_root_endpoint: false
register :scoping
helpers :current_user, :flash, :services
helpers :current_user, :flash
# TODO hmmm?
before { flash.clear }

View File

@ -4,7 +4,7 @@ class Travis::Api::App
class Endpoint
class Accounts < Endpoint
get '/', scope: :private do
respond_with all(params), type: :accounts
respond_with service(:accounts, :find_all, params), 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|
respond_with one(params)
respond_with service(:artifacts, :find_one, params)
end
end
end

View File

@ -4,12 +4,12 @@ class Travis::Api::App
class Endpoint
class Branches < Endpoint
get '/' do
respond_with all(params), type: :branches
respond_with service(:branches, :find_all, params), type: :branches
end
# get '/:owner_name/:name/branches' do # v1
# get '/repos/:owner_name/:name/branches' do # v2
# respond_with all(params), type: :branches
# respond_with service(:branches, :find_all, params), type: :branches
# end
end
end

View File

@ -4,30 +4,12 @@ class Travis::Api::App
class Endpoint
class Builds < Endpoint
get '/' do
respond_with all(params)
respond_with service(:builds, :find_all, params)
end
get '/:id' do
respond_with one(params)
respond_with service(:builds, :find_one, params)
end
# get '/repositories/:repository_id/builds' do # v1
# get '/repos/:repository_id/builds' do # v2
# respond_with all(params)
# end
# get '/repositories/:repository_id/builds/1' do # v1
# respond_with all(params)
# end
# get '/:owner_name/:name/builds' do # v1
# get '/repos/:owner_name/:name/builds' do # v2
# respond_with all(params)
# end
# get '/:owner_name/:name/builds/:id' do # v1
# respond_with all(params)
# end
end
end
end

View File

@ -4,11 +4,11 @@ class Travis::Api::App
class Endpoint
class Hooks < Endpoint
get '/', scope: :private do
respond_with all(params), type: :hooks
respond_with service(:hooks, :find_all, params), type: :hooks
end
put '/:id?', scope: :private do
respond_with update(id: params[:id] || params[:hook][:id], active: params[:hook][:active])
respond_with service(:hooks, :update, id: params[:id] || params[:hook][:id], active: params[:hook][:active])
end
end
end

View File

@ -4,11 +4,11 @@ class Travis::Api::App
class Endpoint
class Jobs < Endpoint
get '/' do
respond_with all(params)
respond_with service(:jobs, :find_all, params)
end
get '/:id' do
respond_with one(params).run
respond_with service(:jobs, :find_one, params)
end
end
end

View File

@ -4,27 +4,27 @@ class Travis::Api::App
class Endpoint
class Repos < Endpoint
get '/' do
respond_with service(:repositories, :all, params)
respond_with service(:repositories, :find_all, params)
end
get '/:id' do
respond_with service(:repositories, :one, params)
respond_with service(:repositories, :find_one, params)
end
get '/:id/cc' do
respond_with service(:repositories, :one, params.merge(schema: 'cc'))
respond_with service(:repositories, :find_one, params.merge(schema: 'cc'))
end
get '/:owner_name/:name' do
respond_with service(:repositories, :one, params)
respond_with service(:repositories, :find_one, params)
end
get '/:owner_name/:name/builds' do
respond_with service(:builds, :all, params)
respond_with service(:builds, :find_all, params)
end
get '/:owner_name/:name/builds/:id' do
respond_with service(:builds, :one, params)
respond_with service(:builds, :find_one, params)
end
end
end

View File

@ -4,11 +4,11 @@ class Travis::Api::App
class Endpoint
class Stats < Endpoint
get '/repos' do
{ :stats => service(:daily_repos) }
{ :stats => service(:stats, :daily_repos) }
end
get '/tests' do
{ :stats => service(:daily_tests) }
{ :stats => service(:stats, :daily_tests) }
end
end
end

View File

@ -24,11 +24,11 @@ class Travis::Api::App
end
get '/permissions', scope: :private do
respond_with service(:users, :permissions), type: :permissions
respond_with service(:users, :find_permissions), type: :permissions
end
put '/:id?', scope: :private do
respond_with update(params[:user])
respond_with service(:users, :update, params[:user])
end
post '/sync', scope: :private do

View File

@ -4,11 +4,11 @@ class Travis::Api::App
class Endpoint
class Workers < Endpoint
get '/' do
respond_with all(params)
respond_with service(:workers, :find_all, params)
end
get '/:id' do
respond_with one(params)
respond_with service(:workers, :find_one, params)
end
end
end

View File

@ -1,25 +0,0 @@
require 'travis/api/app'
class Travis::Api::App
module Helpers
module Services
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