<commit_before>require 'sinatra/base'
require 'json'

module Pushpop
  class Web

    def app
      Sinatra::Application
    end

    def routes
      @routes ||= []
    end

    def add_route(url, job)

      if url[0] != '/'
        url = "/#{url}"
      end

      raise "Route #{url} is already set up as a webhook" if routes.include?(url)

      runner = lambda do
        response = self.instance_eval(&job.webhook_proc)

        if response
          {
            status: 'success',
            job: job.name
          }.to_json
        else
          {
            status: 'failed',
            job: job.name,
            message: 'webhook step did not pass'
          }.to_json
        end
      end
      
      Sinatra::Application.get  url, &runner
      Sinatra::Application.post url, &runner
      Sinatra::Application.put  url, &runner

      routes.push(url)
    
    end
  end<commit_msg>run the rest of the job after a webhook<commit_after>require 'sinatra/base'
require 'json'

module Pushpop
  class Web

    def app
      Sinatra::Application
    end

    def routes
      @routes ||= []
    end

    def add_route(url, job)

      if url[0] != '/'
        url = "/#{url}"
      end

      raise "Route #{url} is already set up as a webhook" if routes.include?(url)

      runner = lambda do
        response = self.instance_eval(&job.webhook_proc)

        if response
          job.run(response, {'webhook' => response}) 

          {
            status: 'success',
            job: job.name
          }.to_json
        else
          {
            status: 'failed',
            job: job.name,
            message: 'webhook step did not pass'
          }.to_json
        end
      end
      
      Sinatra::Application.get  url, &runner
      Sinatra::Application.post url, &runner
      Sinatra::Application.put  url, &runner

      routes.push(url)
    
    end
  end
{'fraction_non_alphanumeric': 0.09931325937665082, 'fraction_numerical': 0.0010565240359218173, 'mean_word_length': 1.5874316939890711, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5729569', 'n_tokens_mistral': 575, 'n_tokens_neox': 558, 'n_words': 158}