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
rubocop Runs code linter
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 other web server like Puma, Unicorn, etc):
Adelnor::Server.run MyApp.application, 3000
- Open
localhost:3000
and cheers!