LeagueTrackAbrophy

This gem serves as a solution to an OOP problem where it is required to build out a class heirarchy to calculate and format the results of a football league.

Installation and Usage

There are three ways to install and use the gem:

clone from github

git clone https://github.com/abrophy/server-side-developer-test.git

after cloning the repo onto your computer, enter the directory and run:

bundle install

To install the dev dependencies.

A sample input file has been provided with the repo as league_track_input.example.

You can then use rake to process this sample input file:

rake run league_track_input.example

simply replace the sample input filename with your own if desired.

install gem for command line usage

The gem is hosted on rubygems so it can be installed to your environment through a simple gem install:

gem install league_track_abrophy

to process an input file call from command line via

league_track_abrophy input_file_name

requiring it into an existing ruby project

Add the gem to your gemfile:

gem 'league_track_abrophy', '1.0.0'

it can then be required and used to process inputs already split into an array:

require 'league_track_abrophy'

input_array = [
    'Lions 3, Snakes 3',
     'Tarantulas 1, FC Awesome 0',
     'Lions 1, FC Awesome 1',
     'Tarantulas 3, Snakes 1',
     'Lions 4, Grouches 0'
]

# returns a formatted string ready to print of the final results
LeagueTrackAbrophy.process(input_array)

Testing

After cloning the repo and installing dev dependencies with bundle, you can run tests against the codebase through:

rake test

Notes On Testing

I used RSpec to cover unit and integration tests, and used rubocop to test code style across the project.

License

The gem is available as open source under the terms of the MIT License.

PROBLEM

original problem statement and information below

Problem Statement & Instructions

Read the problem statement, code a working solution (valid input and output will be provided) and supporting tests using a language of your choice.

The Problem

We want you to create a command-line application that will calculate the ranking table for a soccer league.

Input/output

The input will be a text file and the output should log to your terminal.

The input contains results of games, one per line. See “Sample input” for details. The output should be ordered from most to least points, following the format specified in “Expected output”.

You can expect that the input will be well-formed. There is no need to add special handling for malformed input files.

The rules

In this league, a draw (tie) is worth 1 point and a win is worth 3 points. A loss is worth 0 points.

If two or more teams have the same number of points, they should have the same rank and be printed in alphabetical order (as in the tie for 3rd place in the sample data).

Guidelines

This should be implemented in a language with which you are familiar. We would prefer that you use Ruby, JavaScript, Python or Elixir, if you are comfortable doing so. If none of these is comfortable, please choose a language that is both comfortable for you and suited to the task.

Please fork the repo and commit your changes early and often.

If you use other libraries installed by a common package manager (Rubygems / Bundler, NPM), it is not necessary to commit the installed packages.

We write automated tests and we would like you to do so as well.

If there are any complicated setup steps necessary to run your solution, please document them.

Sample input:

Lions 3, Snakes 3
Tarantulas 1, FC Awesome 0
Lions 1, FC Awesome 1
Tarantulas 3, Snakes 1
Lions 4, Grouches 0

Expected output:

1. Tarantulas, 6 pts
2. Lions, 5 pts
3. FC Awesome, 1 pt
3. Snakes, 1 pt
5. Grouches, 0 pts