Jumpstart Lab Curriculum

EventReporter

This project builds on the lessons learned in EventManager
and MicroBlogger to focus on fundamental Ruby style/concepts.

Project Overview

Learning & Practice Goals

Become comfortable with implementing basic classes and methods

Demonstrate understanding of variable scope and lifecycle

Create multiple coordinating methods and objects

Use default and named parameters

Utilize effective debugging techniques

Abstract

Let’s take EventManager to the next level. Based on the same data file, build an interactive query and reporting tool which fulfills the expectations below. Re-use data cleaning procedures from the original EventManager to handle dirty input and generate beautiful output.

Data Supplied

Base Expectations

As a user launching the program, I’m provided a REPL where I can issue one of several commands, described below. After each command completes, the prompt returns, waiting for another instruction.

The Queue

The program has a concept called the "queue". The queue holds the stored results from a previous search. As a user, I issue a search command to find records, then later issue another command to do work with those results. The queue is not cleared until the user runs the command queue clear or a new find command.

The REPL

The program must respond to the following commands:

load <filename>

Erase any loaded data and parse the specified file. If no filename is given, default to event_attendees.csv.

help

Output a listing of the available individual commands

help <command>

Output a description of how to use the specific command. For example:

12

help queue clear
help find

queue count

Output how many records are in the current queue

queue clear

Empty the queue

queue print

Print out a tab-delimited data table with a header row following this format:

1

LAST NAME FIRST NAME EMAIL ZIPCODE CITY STATE ADDRESS PHONE

queue print by <attribute>

Print the data table sorted by the specified attribute like zipcode.

queue save to <filename.csv>

Export the current queue to the specified filename as a CSV. The file should should include data and headers for last name, first name, email, zipcode, city, state, address, and phone number.

find <attribute> <criteria>

Load the queue with all records matching the criteria for the given attribute. Example usages:

find zipcode 20011

find last_name Johnson

find state VA

The comparison should:

Be case insensitive, so "Mary" and "mary" would be found in the same search

Be insensitive to internal whitespace, but not external:

"John" and "John " are considered matches

"John Paul" and "Johnpaul" are not matches

Not do substring matches, so a find first_name Mary does not find a record with first name "marybeth"

Test Cases for Base Expectations

Your program must handle the following scenarios correctly:

A. Happy Path

load event_attendees.csv

queue count should return 0

find first_name John

queue count should return 63

queue clear

queue count should return 0

help should list the commands

help queue count should explain the queue count function

help queue print should explain the printing function

B. Let’s Try Printing

load

queue count should return 0

find first_name John

find first_name Mary

queue print should print out the 16 attendees

queue print by last_name should print the same attendees sorted alphabetically by last name

queue count should return 16

C. Saving

load

find city Salt Lake City

queue print should display 13 attendees

queue save to city_sample.csv

Open the CSV and inspect that it has correct headers and the data rows from step 3.

find state DC

queue print by last_name should print them alphabetically by last name

queue save to state_sample.csv

Open the CSV and inspect that it has the headers, the data from step 7, but not the data previously found in step 2.

D. Reading Your Data

load

find state MD

queue save to state_sample.csv

quit

Restart the program and continue…

load state_sample.csv

find first_name John

queue count should return 4

E. Emptiness

Note that this set intentionally has no call to load:

find last_name Johnson

queue count should return 0

queue print should not print any attendee data

queue clear should not return an error

queue print by last_name should not print any data

queue save to empty.csv should output a file with only headers

queue count should return 0

Extensions

Improving queue print

Modify your queue print command so it prints in left-aligned columns where the size of each column is determined by the longest entry in the column.

If the queue is more than 10 lines, pause after ten until the user hits either the spacebar or enter keys.

Add a status line that reads like "Showing Matches 20-30 of 80"

Improving find

Modify your find instruction so all searches are case insensitive

Modify your find instruction to allow compound searches using a single and such as:

1

find zipcode 20011 and last_name Johnson

Improving queue save to

Modify the instruction to respect the filename extension so that:

csv generates comma-separated values

txt generates tab-delimited values

json generates valid, parsable JSON

xml generates valid, parsable XML

yml generates valid YAML

Implementing Queue Math

Assuming I have results currently in the queue, implement queue math like this:

12

find state DC
subtract zipcode 20011

That would find me all entries for DC that are not in 20011. Similarly: