Skip to content

marciofrayze/rackstep

Repository files navigation

RackStep

RackStep is (yet another) micro ruby framework for web development.

Main goals are:

  • be as simple as possible.
  • keep the source code small.
  • implement only the necessary; no overcomplications.
  • be a pure object-oriented approach, avoiding DSLs and configuration files.

Status

Travis CI Code Climate Coverage Ich CI Gem Version Gem Downloads

License

A quick introduction to RackStep

A quick introduction to RackStep

Source code of the presentation: github.com/marciofrayze/rackstep-presentations

Example code

Let's create a simple service that returns the current date and time.

# app.rb
require 'rackstep'
require 'json'

class TimeController < RackStep::Controller
  def process_request
    time_hash = {:time => Time.now}
    response.body = time_hash.to_json
  end
end

class App < RackStep::App
  # Routing all GET requests from "/time" path to the TimeController class.
  add_route('GET', 'time', TimeController)
end
# config.ru
require_relative 'app.rb'

run App

The service will be available at /time path and will return the current date and time in json format.

Dependancies

RackStep is developed and tested with Ruby 3.3.1. The only hard dependency is Rack itself, but there are a few recommended gems:

  • puma: fast rack-compatible server that can be used for production.
  • simplecov: a simple way to generate statistics about your tests coverage.

How to use RackStep

Make sure you have ruby 3.3.1 installed (ruby --version). If you don't, we recommend you to use rbenv to install it. RackStep may work with older ruby implementations but we always develop and test with the latest Ruby MRI stable version.

Install the bundle gem if you don't have it already:

gem install bundle

To create a new application, you may clone one of the following repositories as a starting point example:

A full app example: github.com/marciofrayze/rackstep-app-template

A minimum app example: github.com/marciofrayze/rackstep-minimum-app-template

Go into the directory you cloned the project and install the dependancies by running:

bundle install

Start the application server using any rack-compatible server. For development we recommend using shotgun or rackup. RackStep full app template example is pre-configured to use puma in production.

Running tests

In the main folder of the project, execute:

rake test

Open coverage/index.html to see the results.

Author

RackStep is maintained by Marcio Frayze David - marcio@segunda.tech.

About

A tiny ruby framework for web development.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published