<commit_before>require 'bundler'

ENV['RACK_ENV'] ||= 'development'
Bundler.require :default, ENV['RACK_ENV'].to_sym

Dir['./models/**/*.rb'].each {|f| require f }

class Application < Sinatra::Base
  register Sinatra::ActiveRecordExtension

  configure :production, :development do
    enable :logging
  end


#Configurations	
  register Sinatra::ActiveRecordExtension

  configure :production, :development do
    enable :logging
  end

  #Reloader
  configure :development do
    register Sinatra::Reloader
  end
  #Database
  set :database, YAML.load_file('config/database.yml')[ENV['RACK_ENV']]


#Methods & Helpers
helpers do
    def json_status(code, reason)
      status code
      {
        :status => code,
        :reason => reason
      }.to_json
    end
end    

#Setting the content type of the answers
before do
  content_type :json
end


#Endpoints
	
  get '/' do
    JSON.pretty_generate({'Welcome to:'=>'Badges Api'})
  end	

  get '/badges' do
    slug="90812gjd"
    name="Joven Cientifico"
    [{id_badge_class:slug,name:name},{id_badge_class:slug,name:"Cientifico Avanzado"}].to_json

  end

  get '/issuers/:id_app/badges' do
    
    status 200

    [
      {
          id_badge_class: "h1k2bfhg",
          name: "Asesino de aliens"
      },
      {
          id_badge_class: "2gd1d2w3g",
          name: "<NAME>"
      },
      {
          id_badge_class: "2134gdsa8",
          name: "<NAME>"
      }
    ].to_json
  end

  post '/badges/:id_badge_class/instances' do

    json_status 200, "ok"

  end

  get '/error' do
    json_status 404,"Not found"
  end


end<commit_msg>First deploy.<commit_after>require 'bundler'

ENV['RACK_ENV'] ||= 'development'
Bundler.require :default, ENV['RACK_ENV'].to_sym

Dir['./models/**/*.rb'].each {|f| require f }

class Application < Sinatra::Base
  register Sinatra::ActiveRecordExtension

  configure :production, :development do
    enable :logging
  end


#Configurations	
  register Sinatra::ActiveRecordExtension

  configure :production, :development do
    enable :logging
  end

  #Reloader
  configure :development do
    register Sinatra::Reloader
  end
  #Database
  set :database, YAML.load_file('config/database.yml')[ENV['RACK_ENV']]


#Methods & Helpers
helpers do
    def json_status(code, reason)
      status code
      {
        :status => code,
        :reason => reason
      }.to_json
    end
end    

#Setting the content type of the answers
before do
  content_type :json
end


#Endpoints
	
  get '/' do
    JSON.pretty_generate({'Welcome to:'=>'Badges Api'})
  end	

  #BADGE CLASSES ENDPOINTS

  #List all Cientificos Ciudadanos Badge Classes. 
  get '/badges' do
    slug="90812gjd"
    name="Joven Cientifico"
    [{id_badge_class:slug,name:name},{id_badge_class:slug,name:"Cientifico Avanzado"}].to_json

  end

  #List all <Application> Badge Classes (achievements).
  get '/issuers/:id_app/badges' do
    status 200

    [
      {
          id_badge_class: "h1k2bfhg",
          name: "Asesino de aliens"
      },
      {
          id_badge_class: "2gd1d2w3g",
          name: "<NAME>"
      },
      {
          id_badge_class: "2134gdsa8",
          name: "<NAME>"
      }
    ].to_json
  end

  #BADGE INSTANCES ENDPOINTS

  #Create Badge Instance
  post '/badges/:id_badge_class/instances' do
     status 201
    {issuedOn:"2015-04-21"}.to_json

  end


  #Create <Application> Badge (achievement) Instance
  post '/issuers/:id_app/badges/:id_badge_class/instances' do
    status 201
    {issuedOn:"2015-04-17"}.to_json

  end

  #List all Cientificos Ciudadanos Badge Instances for <email>
  get '/instances/:email' do
    JSON.pretty_generate({params[:email] => [
      {
          id_badge_class: "h1k2bfhg",
          name: "<NAME>"
      },
      {
          id_badge_class: "2gd1d2w3g",
          name: "Cientifico Avanzado"
      },
      {
          id_badge_class: "2134gdsa8",
          name: "Arquimedes"
      }
    ]})
  end

  #List all <Application> Badge Instances (Achievements) for <email>
  get '/issuers/:id_app/instances/:email' do

    JSON.pretty_generate({params[:email] => [
      {
          id_badge_class: "h1k2bfhg",
          name: "<NAME> aliens"
      },
      {
          id_badge_class: "2gd1d2w3g",
          name: "<NAME>"
      },
      {
          id_badge_class: "2134gdsa8",
          name: "<NAME>"
      }
    ]})
  end
  
  #Retrieve specific badge instance for <email> and <Badge Class> 
  get '/badges/:id_badge_class/instances/:email' do
    
    {issuedOn: "2009-09-25"}.to_json

  end

  #Retrieve specific badge instance for <email>, <Application> and <Badge Class> (Achievement)
  get '/issuers/:id_app/badges/:id_badge_class/instances/:email' do

    params[:email]=="error" ? ({ issuedOn: nil }.to_json) : ({issuedOn: "2015-03-05"}.to_json)   
  
  end  
  

  #Error example 404.
  get '/error' do
    json_status 404,"Not found"
  end  

end
{'fraction_non_alphanumeric': 0.12272820093935062, 'fraction_numerical': 0.022462732285072493, 'mean_word_length': 2.652498135719612, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 29, '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': '6102642', 'n_tokens_mistral': 1859, 'n_tokens_neox': 1744, 'n_words': 372}