chespirito
( ) _ _ ( )_
___ | |__ __ ___ _ _ (_) _ __ (_)| ,_) _
/'___)| _ `\ /'__`\/',__)( '_`\ | |( '__)| || | /'_`\
( (___ | | | |( ___/\__, \| (_) )| || | | || |_ ( (_) )
`\____)(_) (_)`\____)(____/| ,__/'(_)(_) (_)`\__)`\___/'
| |
(_)
chespirito is a dead simple, yet Rack-compatible, web framework written in Ruby.
Requirements
Ruby
Installation
$ gem install chespirito
Development tooling
Make and Docker
Using make
$ make help
Output:
Usage: make <target>
help Prints available commands
bundle.install Installs the Ruby gems
bash Creates a container Bash
run.tests Runs Unit tests
ci Runs code linter and unit tests in CI
sample.hello-app Runs a sample Hello World app
sample.login-app Runs a sample app with Login feature
gem.publish Publishes the gem to https://rubygems.org (auth required)
gem.yank Removes a specific version from the Rubygems
Boostrapping an application using Chespirito and Adelnor
- Install the gems:
$ gem install chespirito adelnor
- Register the Chespirito app and routes:
class MyApp
def self.application
Chespirito::App.configure do |app|
app.register_route('GET', '/', [HelloController, :index])
app.register_route('POST', '/', [HelloController, :create])
end
end
end
- Create the Controller and action:
class HelloController < Chespirito::Controller
def index
response.status = 200
response.headers['Content-Type'] = 'text/html'
response.body = '<h1>Hello, world!</h1>'
end
def create
response.status = 204
end
end
- Run the app using Adelnor (or you can choose another web server like Puma, Unicorn, etc):
Adelnor::Server.run MyApp.application, 3000
- Open
localhost:3000
and cheers!