ruby main.rb webserver.log
ruby main.rb path/to/logfile.log
- Different components are dependency-injected using constructors
FileReader
expects a block to read the file line by line, allowing to stream from the fileLineParser
will ignore invalid lines, or lines containing invalid ipv4 or ipv6 addressPageviewsAggregator
uses Sets to keep track of unique IPs per pathService
returns a response object to be passed to theConsolePresenter
for renderingApplication
encapsulates CLI app logic and calls service
- Turn into a gem by potentially wrapping Application under the LogParser module
- Provide advanced CLI options/commands to specify which counters to see
+--------------------+ +--------------------+ +---------------------+
| | | | | |
| FileReader | | LineParser | | PageviewsAggregator |
| | | | |
+--------------------+ +--------------------+ +---------------------+
^ ^ ^
| | |
| | |
| | |
| | |
| | |
| + |
| +--------------------+ | +-------------------+
| | | | | |
| | Service | | | ConsolePresenter |
+--------------+ +-------------+ | |
+--------------------+ +-------------------+
^ +
| |
| |
| |
| |
| |
+---------+---------+ |
| | |
| Application +--------------------------+
| |
+-------------------+