Sha256: d3e308e5c1efee864ccba7325c62295c99b3eaf4988c14dc87a8b791a1eb1537

Contents?: true

Size: 1012 Bytes

Versions: 4

Compression:

Stored size: 1012 Bytes

Contents

require 'sinatra/base'
require 'json'
require_relative '../../pairing_matrix'
require_relative '../config/config_reader'
require_relative '../commit_reader'
require_relative '../github_commit_reader'

module PairingMatrix
  class Server < Sinatra::Base
    set :bind, '0.0.0.0'

    logging_file = File.new('app.log', 'a+')
    logging_file.sync = true
    before {
      env["rack.errors"] = logging_file
    }
    configure do
      enable :logging
      logging_file.sync = true
      use Rack::CommonLogger, logging_file
    end

    config_reader = PairingMatrix::ConfigReader.new('pairing_matrix.yml')
    config = config_reader.config
    commit_reader = PairingMatrix::CommitReader.new(config)
    commit_reader = PairingMatrix::GithubCommitReader.new(config) if config.fetch_from_github?

    get '/data/:days' do
      commit_reader.authors_with_commits(params['days'].to_i).to_json
    end

    get '/matrix' do
      File.read(File.join(File.dirname(__FILE__), 'public/index.html'))
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pairing_matrix-2.0 lib/pairing_matrix/server/server.rb
pairing_matrix-1.2 lib/pairing_matrix/server/server.rb
pairing_matrix-1.1.1 lib/pairing_matrix/server/server.rb
pairing_matrix-1.1 lib/pairing_matrix/server/server.rb