0% found this document useful (0 votes)
37 views

Modularize - Sinatra - Modular Sinatra App Generator: What Does It Do?

modularize_sinatra is a gem that generates a modular structure for Sinatra applications without the overhead of Rails. It creates directories for models, views, controllers, and other standard MVC components, allowing code to be organized and managed more easily as an application grows beyond a single file. The gem addresses the need for modularization when simple Sinatra apps become more complex, while avoiding unnecessary features of Rails.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Modularize - Sinatra - Modular Sinatra App Generator: What Does It Do?

modularize_sinatra is a gem that generates a modular structure for Sinatra applications without the overhead of Rails. It creates directories for models, views, controllers, and other standard MVC components, allowing code to be organized and managed more easily as an application grows beyond a single file. The gem addresses the need for modularization when simple Sinatra apps become more complex, while avoiding unnecessary features of Rails.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

modularize_sinatra - modular sinatra app

generator
July 23, 2013

Sinatra is simple, small and fast.

Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort. - sinatra
readme

The only downside is that it doesnt offer you the typical MVC like Rails.

Lot of times Rails is an overkill for a simple application and Sinatra seems like a perfect choice.
Since using Sinatra, you could write all your code in a single file, and at one time it becomes
really hard to manage the code and you may feel the need of porting it to a framework like Rails.
However, you dont need all the features that comes with Rails. What you need here is some
kind of modularization in your application. For this very purpose I created a gem called
modularize_sinatra

modularize_sinatra creates a Rails like MVC structure without the overhead.

modularize_sinatra is available on rubygems. For installation and usage instructions please


visit modularize_sinatra

What does it do?


It generates the following directory structure, when generated using modularize_sinatra
myapp -C user

.
|-- Gemfile
|-- Rakefile
|-- config
| `-- environment.rb
|-- config.ru
|-- lib
| |-- app.rb
| |-- controllers
| | `-- user.rb
| `-- views
| `-- users
| `-- index.erb
|-- myapp.rb
|-- public
|-- script
|-- spec
| |-- controllers
| | `-- user_spec.rb
| |-- spec_helper.rb
| `-- support
`-- tmp

It generated some usual ruby files like:

Gemfile - A format for describing gem dependencies for Ruby programs.


Rakefile - Contains task to run specs.
config.ru - Rack configuration file.
config/environment.rb - Here you could load your configuration files. Hint: Could load
configuration given in .yml files
lib contains directories for placing your controllers and views.
myapp.rb loads all ruby files inside lib, lib/controllers and lib/models.

Note the lib/models in above point. You could create a directory called models in lib directory
to place your models and it will also be loaded.

public - To serve public assets.


script - You could get rid of this directory. This is just a container to put your scripts.
spec - Place your specifications inside this. modularize_sinatra integrates rspec for you
by default.

Please contribute at modularize_sinatra

Comments and suggestions are most welcome.

You might also like