Corneal is a Great Deal

Emmanuel Rivera
3 min readMar 4, 2021

--

As programmers, we like to be lazy… In a good way, I promise.

Corneal Logo
Corneal Logo

While learning how to create a web application with Sinatra, which already makes it easy enough, I was worried about making sure I know how to start the scaffolding of the app. As a beginner, I wanted to make sure that I had all the required folders and files. While I can, of course, do this myself with my teachings and lessons I’ve done, I knew there had to be an easier way. I’d like to introduce you to this gem, Corneal.

The creator (Brian Emory) of Corneal basically compared his gem to starting a web app with Rails. He wanted to make it JUST like it but for Sinatra. For example:

rails new APP-NAME

This would give you the scaffolding to a Rails app. So to make the a similar scaffolding to a Sinatra app you use:

corneal new APP-NAME

It’s THAT easy! It saves you loads of time and gives you a ton of useful files and folders. This is what your skeleton would look like:

├── config.ru
├── Gemfile
├── Gemfile.lock
├── Rakefile
├── README
├── app
│ ├── controllers
│ │ └── application_controller.rb
│ ├── models
│ └── views
│ ├── layout.erb
│ └── welcome.erb
├── config
│ ├── initializers
│ └── environment.rb
├── db
│ └── migrate
├── lib
│ └── .gitkeep
└── public
| ├── images
| ├── javascripts
| └── stylesheets
| └── main.css
└── spec
├── application_controller_spec.rb
└── spec_helper.rb

You start off with you MVC, your database folder, your config.ru and Gemfile. As a first-time Sinatra user, starting the app was like deer and headlights. I didn’t know where to even begin. Corneal solved this problem. It’s a real life saver… but wait, there’s more!

It has a list of commands for other things you may want to do!

corneal -v              # Show Corneal version number
corneal help [COMMAND] # Describe available commands or one specific command
corneal new APP-NAME # Creates a new Sinatra application
corneal model NAME # Generate a model
corneal controller NAME # Generate a controller
corneal scaffold NAME # Generate a model with its associated views and controllers

For example, if I wanted to create a new model along with database tables. something like this:

corneal model User name:string age:integer

Would give me this:

class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.age :integer

t.timestamps null: false
end
end
end

As you can see not only does it save a lot of typing for you but also it makes sure it’s typed out correctly and conventions are in place. I cannot imagine how long it would have taken me to do all of this myself. Besides, I’m a lazy programmer, why not enjoy having some commands do it for me!

https://github.com/thebrianemory/corneal

--

--