Skeleton Ruby Project: Mac Edition

Nic Ollis
Nic Ollis
May 23, 2016 · 3 min read
Screen Shot 2016-05-22 at 3.21.58 PM
Screen Shot 2016-05-22 at 3.21.58 PM

A nice thing to have in your Ruby journey will be a skeleton project so you can quickly get up and running when you need to create a new project. We have done this project in an earlier post for computers running Windows. However, with the upcoming video series on algorithmic challenges in Ruby I wanted to translate the old post for Mac systems. We will be doing all the commands in the terminal, and the Atom editor for writing to the files.

First we will create our skeleton project folder and its sub folders.

Now with our folder structure of project in place we will just need to create the template files. The commands are:

This will create an places we can start putting our new projects code. Next we will want to make a simple gemspec file that will hold the details of our project. We will name this PROJECT.gemspec and it will be located in our root project directory.

PROJECT.gemspec file contents:

After the gemspec file is done we will want to create our Rakefile to help us with automating common task when working with Ruby. This Rakefile will be used to help run our test.

Rakefile file contents:

Finally we will want to make a simple test file to finish up our skeleton project

test_PROJECT.rb contents:

Now we should have our test project all finished up. You can test your project by calling “rake test” from your project’s root directory. If setup correctly you should get a passed test without any failures or errors. Below is the file structure you should have now.

Now when you want to use this to creating a new project all you will need to do is the following.

  • Copy the skeleton project and rename the root folder to your new project name
  • Rename the lib/PROJECT.rb file and the lib/PROJECT folder to the new project name
  • Edit the Gemspec file to fit the new project
  • rename and tests/test_PROJECT.rb and make sure to edit the ‘require “./lib/PROJECT.rb”’ inside that test file
  • Double check everything is working by calling “rake tests”.
  • Happy Coding!

As always thanks for reading, and follow me on twitter for more daily updates, live stream alerts, and post on my journey from Senior IT Admin to Junior Developer. Subscribe to the Program Practical channel on YouTube. Feel free to ask any questions in the comments below, and don’t forget it’s always a good time to start to #LearnToCode

Program Practical

Easy to digest post to help make you a better programmer.

    Nic Ollis

    Written by

    Nic Ollis

    Software Engineer working out of Indiana

    Program Practical

    Easy to digest post to help make you a better programmer.