diff --git a/Gemfile b/Gemfile index f8051f9c..89cee7dd 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ gemspec gem 'travis-core', github: 'travis-ci/travis-core' gem 'travis-support', github: 'travis-ci/travis-support' gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil, ref: 'cde9741' +gem 'travis-yaml', github: 'travis-ci/travis-yaml' gem 'sinatra' gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: nil diff --git a/Gemfile.lock b/Gemfile.lock index 459d041a..6a1be31f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: a4f19caa0ae6847a3a10db2b99ba752a656aad98 + revision: 111ae389e611157d48177ed732c1822d98fe3059 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -80,6 +80,12 @@ GIT specs: travis-support (0.0.1) +GIT + remote: git://github.com/travis-ci/travis-yaml.git + revision: 7e6e31e82240e170ffc20dfd02c0353b3bd5d33b + specs: + travis-yaml (0.1.0) + GIT remote: https://gist.github.com/4269321.git revision: 8e2d21b924a69dd48191df6a18e51769f5a88614 @@ -332,5 +338,6 @@ DEPENDENCIES travis-core! travis-sidekiqs! travis-support! + travis-yaml! unicorn yard-sinatra! diff --git a/lib/travis/api/app/endpoint/branches.rb b/lib/travis/api/app/endpoint/branches.rb deleted file mode 100644 index 5f071bd6..00000000 --- a/lib/travis/api/app/endpoint/branches.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'travis/api/app' - -class Travis::Api::App - class Endpoint - class Branches < Endpoint - get '/' do - respond_with service(:find_branches, params), type: :branches - end - - # get '/:owner_name/:name/branches' do # v1 - # get '/repos/:owner_name/:name/branches' do # v2 - # respond_with service(:branches, :find_all, params), type: :branches - # end - end - end -end diff --git a/lib/travis/api/app/endpoint/lint.rb b/lib/travis/api/app/endpoint/lint.rb new file mode 100644 index 00000000..30437e51 --- /dev/null +++ b/lib/travis/api/app/endpoint/lint.rb @@ -0,0 +1,19 @@ +require 'travis/api/app' +require 'travis/yaml' + +class Travis::Api::App + class Endpoint + class Lint < Endpoint + 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 + + post('/', scope: :public) { lint } + put('/', scope: :public) { lint } + end + end +end diff --git a/spec/integration/v1/branches_spec.rb b/spec/integration/v1/branches_spec.rb deleted file mode 100644 index 6e5c8735..00000000 --- a/spec/integration/v1/branches_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'spec_helper' - -describe 'Branches' do - let(:repo) { Repository.by_slug('svenfuchs/minimal').first } - let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.1+json' } } - - it 'GET /branches?repository_id=:repository_id' do - response = get '/branches', { repository_id: repo.id }, headers - response.should deliver_json_for(repo.last_finished_builds_by_branches, version: 'v1', type: 'branches') - end -end diff --git a/spec/integration/v2/branches_spec.rb b/spec/integration/v2/branches_spec.rb deleted file mode 100644 index 3e54ecc8..00000000 --- a/spec/integration/v2/branches_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'spec_helper' - -describe 'Branches' do - let(:repo) { Repository.by_slug('svenfuchs/minimal').first } - let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } } - - it 'GET /branches?repository_id=:repository_id' do - response = get '/branches', { repository_id: repo.id }, headers - response.should deliver_json_for(repo.last_finished_builds_by_branches, version: 'v2', type: 'branches') - end -end diff --git a/spec/unit/endpoint/branches_spec.rb b/spec/unit/endpoint/branches_spec.rb deleted file mode 100644 index 03923cfd..00000000 --- a/spec/unit/endpoint/branches_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe Travis::Api::App::Endpoint::Branches do - it 'has to be tested' -end diff --git a/spec/unit/endpoint/lint_spec.rb b/spec/unit/endpoint/lint_spec.rb new file mode 100644 index 00000000..025130de --- /dev/null +++ b/spec/unit/endpoint/lint_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +describe Travis::Api::App::Endpoint::Lint do + let(:content) { "foo: bar" } + let(:body) { "{\"lint\":{\"warnings\":[{\"key\":[],\"message\":\"unexpected key \\\"foo\\\", dropping\"},{\"key\":[],\"message\":\"missing key \\\"language\\\", defaulting to \\\"ruby\\\"\"}]}}" } + + it "accepts content in parameter" do + response = post('/lint', content: content) + response.should be_ok + response.body.should be == body + end + + it "accepts content as body" do + response = put('/lint', content) + response.should be_ok + response.body.should be == body + end +end diff --git a/travis-api.gemspec b/travis-api.gemspec index 244aadfa..fc4c5525 100644 --- a/travis-api.gemspec +++ b/travis-api.gemspec @@ -35,8 +35,8 @@ Gem::Specification.new do |s| "konstantin.mailinglists@googlemail.com", "me@svenfuchs.com", "meyer@paperplanes.de", - "asari.ruby@gmail.com", "josh.kalderimis@gmail.com", + "asari.ruby@gmail.com", "me@henrikhodne.com", "henrik@hodne.io", "konstantin.haase@gmail.com",