I present you my new project – (American) Football Manager, which will be a Ruby application allowing you to become a manager of american football team. As a die-hard Panthers fan, I want to explore this world and dust off my Ruby development skill. I also want to share the progress on the blog.

Starting from complete zero, what needed to be done?

I like it primitive

In the long term, I would probably want this to be a Rails (Hanami?) app, but I like to start simple. I decide to start without any web framework, instead I created vanilla Ruby project. Until something substantial is developed in pure Ruby, I restrain from making is complicated.

As I said, I want it to be simple, primitive is more than fine for me. This is reflected in upcoming decisions.

rvm & ruby

As a rvm fan (more than Docker, probably), I installed with it on my machine newest stable Ruby version 3.1.2.

This is interesting from a perspective. Apparently, on Mac M1 chip, rubies below version 3 fail to build. This is one of the reasons why new project instead of developing exising ones.

rspec & TDD

This is a must in each of my side projects. I refure to work without tests. I picked up rspec, my favorite TDD/BDD framework. I ran rspec --init.

I also plan to go full ham on TDD. This is how my “hello world” looks like:

require "football-manager"

RSpec.describe Generator do
  describe "#generate" do
    it "generates kickoff stub" do
      team_1 = Team.new
      team_2 = Team.new
      generator = Generator.new
      match = generator.generate(team_1, team_2)
      expect(match).to eq(Kickoff.new)
    end
  end
end

Very primitive, which makes be delighted. But first of all, it’s a test. And it’s from the very core of the upcoming application – generating games between two teams.

README

Immediately after publishing even so primitive code, I must publish even the simplest README. It must contain Ruby version I work on, plus every information that is required for development. For now it’s only one – how to run tests πŸ˜‰,

These are very simple yet very important and very volatile information. I can’t stress enough how much I value devs who remember to put on README from the very beginning.

# (American) Football Manager

## Versions

ruby 3.1.2

## Run tests

`bundle exec rspec .`

file structure

In future, this project will become a gem. I don’t want a gemspec just yet – laser focus on the code. With that in mind, file structure is the one recommended by Gemspec:

.
β”œβ”€β”€ Gemfile
β”œβ”€β”€ Gemfile.lock
β”œβ”€β”€ README.md
β”œβ”€β”€ lib
β”‚Β Β  β”œβ”€β”€ football-manager
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ generator.rb
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ kickoff.rb
β”‚Β Β  β”‚Β Β  └── team.rb
β”‚Β Β  └── football-manager.rb
└── spec
    β”œβ”€β”€ generator_spec.rb
    └── spec_helper.rb

formatter

Last thing to set up is code formatter. I like my code cleaned up, but yet again – I don’t want to make the setup & process complicated from the beginning.

What I went for is Ruby formatter plugin in my code editor VS Code. CMD + Shift + F and all the issues are fixed πŸ˜‰.


Stay tuned!