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

class OrcamentoApp < Sinatra::Base
  helpers Sinatra::JSON

  configure do
    set :views, Proc.new { File.join(root, "public/views") }
  end

  get '/' do
    erb :index
  end

  get '/agencies' do
    json :x => 'bla'
  end

end<commit_msg>Adding rest handlers to retrieve agency data<commit_after>require 'sinatra/base'
require 'sinatra/json'
require 'json'

class OrcamentoApp < Sinatra::Base
  helpers Sinatra::JSON

  @@agencies = JSON.parse File.read('data/data.json')

  configure do
    set :views, Proc.new { File.join(root, "public/views") }
  end

  get '/' do
    erb :index
  end

  get '/agencies' do
    json exclude_from @@agencies, ['programs']
  end

  get '/agency/:name' do
    json @@agencies.find { |ag| ag['name'] == params[:name] }
  end

  private 

  def exclude_from(values, attr_to_exclude)
    values.collect do |value|
      value.reject { |key| attr_to_exclude.include? key  }
    end
  end

end
{'fraction_non_alphanumeric': 0.1263902932254803, 'fraction_numerical': 0.0, 'mean_word_length': 3.3043478260869565, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3660704', 'n_tokens_mistral': 365, 'n_tokens_neox': 343, 'n_words': 93}