Sha256: c6d84b0bc68f6cf039de48bcf4d590b69fdf01fc0a14e1a05232dbdeee363dd3

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require 'sinatra'
require 'haml'
require 'json'
require 'bait/build'

module Bait
  class Api < Sinatra::Base
    set :port, 8417

    get '/' do
      redirect '/build'
    end

    post '/' do
      if params && params["payload"]
        push = JSON.parse(params["payload"])
        Build.create({
          name: push["repository"]["name"],
          clone_url: push["repository"]["url"],
          owner_name: push["repository"]["owner"]["name"],
          owner_email: push["repository"]["owner"]["email"],
          ref: push["ref"]
        }).test_later
      end
    end

    get '/build' do
      @builds = Bait::Build.all
      haml :builds
    end

    post '/build/create' do
      build = Build.create(clone_url:params["clone_url"], name:'test')
      build.test_later
      redirect '/build'
    end

    get '/build/remove/:id' do
      Build.destroy params["id"]
      redirect '/build'
    end

    get '/build/retest/:id' do
      build = Build.find params['id']
      build.tested = false
      build.test_later
      build.save
      redirect '/build'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bait-0.3.2 lib/bait/api.rb
bait-0.3.1 lib/bait/api.rb