<commit_before>require 'sinatra/base'

require 'scarecrow/version'

module Scarecrow
  def self.run
    # eat yaml file
    hash = {
      "hello" => {
        "method" => "GET",
        "patterns" => [
          {
            "request" => {
            },
            "response" => {
              "body" => "hello, Tom!"
            }
          }
        ]
      }
    }
    
    # validate hash

    # setup definition
    app = Sinatra.new do
      hash.each_key do |path|
        # switch methods from hash[path][method]
        get File.join("/", path) do
          hash[path]["patterns"].each do |pattern|
            return pattern["response"]["body"]
          end
        end
      end
    end

    # run sinatra
    app.run! port: 7874
  end
end<commit_msg>return not only body but also status, headers<commit_after>require 'sinatra/base'

require 'scarecrow/version'

module Scarecrow
  def self.run
    # eat yaml file
    hash = {
      "hello" => {
        "method" => "GET",
        "patterns" => [
          {
            "request" => {
            },
            "response" => {
              "body" => "hello, Tom!"
            }
          }
        ]
      }
    }
    
    # validate hash

    # setup definition
    app = Sinatra.new do
      hash.each_key do |path|
        # switch methods from hash[path][method]
        get File.join("/", path) do
          hash[path]["patterns"].each do |pattern|
            status pattern["response"]["status"] || 200
            headers pattern["response"]["header"] || {}
            return body pattern["response"]["body"]
          end
        end
      end
    end

    # run sinatra
    app.run! port: 7874
  end
end
{'fraction_non_alphanumeric': 0.12759643916913946, 'fraction_numerical': 0.006528189910979229, 'mean_word_length': 1.4541484716157205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '4354448', 'n_tokens_mistral': 511, 'n_tokens_neox': 499, 'n_words': 122}