intial work on adding /lint endpoint

This commit is contained in:
carlad 2016-01-07 12:34:10 +01:00
parent bddd9952a7
commit 43480752fa
5 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,9 @@
require 'travis/api/v3/permissions/generic'
module Travis::API::V3
class Permissions::Lint < Permissions::Generic
def lint?
write?
end
end
end

View File

@ -0,0 +1,13 @@
require 'travis/yaml'
module Travis::API::V3
class Queries::Lint < Query
def lint
request.body.rewind
content = params[:content] || request.body.read
parsed = Travis::Yaml.parse(content)
warnings = parsed.nested_warnings.map { |k, m| { key: k, message: m } }
{ lint: { warnings: warnings } }.to_json
end
end
end

View File

@ -36,6 +36,12 @@ module Travis::API::V3
post :restart, '/restart'
end
resource :lint do
route '/lint'
post :lint
put :lint
end
resource :organization do
capture id: :digit
route '/org/{organization.id}'

View File

@ -11,6 +11,7 @@ module Travis::API::V3
Builds = Module.new { extend Services }
Job = Module.new { extend Services }
Jobs = Module.new { extend Services }
Lint = Module.new { extend Services }
Organization = Module.new { extend Services }
Organizations = Module.new { extend Services }
Owner = Module.new { extend Services }

View File

@ -0,0 +1,7 @@
module Travis::API::V3
class Services::Lint::Lint < Service
def run!
lint
end
end
end