We have updated the content of our program. To access the current Software Engineering curriculum visit curriculum.turing.edu.
File I/O and Setup
Setup
We have provided a starting repository for this project. That repository has the usual lib
and spec
directories that you have seen in the past, but also includes a data
directory that includes three .csv
files. These files are text files that include tables represented as comma-separated values (hence .csv
). The first row includes headers, while every other row includes entries in the table.
Begin by picking one team member to fork the project repository here. Once one of you has forked the repository, each of the other team members should clone that repository.
In order to complete your setup:
- One team member forks the repository here and adds the other(s) as collaborators.
- Each of the other team members accepts the invitation to collaborate and then clones the repository.
- Setup SimpleCov to monitor test coverage along the way.
Note: we have linked the GitHub repository for SimpleCov, but you should not expect that those are the only resources you will use to set up these tools in your project. Use your research skills to find other resources to help you determine how to use these tools. You may want to consider using Rubys CSV class.
File I/O
In order to get data into the system we’re going to create, we’re going to read information from CSV files. At this point, we don’t expect that you have determined exactly what you will be doing with the information that you collect, so for now you may just want to print some information to the terminal about each record you read in.
At a high level, if you create a runner file including the code below, you should drop into a pry session with an instance of StatTracker
held in the stat_tracker
variable.
Note that ::from_csv
is a method you have defined called directly on the StatTracker
class, and not an instance of StatTracker
.
::from_csv
returns an instance of StatTracker. That instance of StatTracker
will hold all of the information you need for the methods included in the remainder of the project description.
# runner.rb
require './lib/stat_tracker'
game_path = './data/games.csv'
team_path = './data/teams.csv'
game_teams_path = './data/game_teams.csv'
locations = {
games: game_path,
teams: team_path,
game_teams: game_teams_path
}
stat_tracker = StatTracker.from_csv(locations)
require 'pry'; binding.pry