<commit_before># Eldr [![Build Status](https://travis-ci.org/eldr-rb/eldr.svg)](https://travis-ci.org/eldr-rb/eldr) [![Code Climate](https://codeclimate.com/github/eldr-rb/eldr/badges/gpa.svg)](https://codeclimate.com/github/eldr-rb/eldr) [![Coverage Status](https://coveralls.io/repos/eldr-rb/eldr/badge.svg?branch=master)](https://coveralls.io/r/eldr-rb/eldr?branch=master) [![Dependency Status](https://gemnasium.com/eldr-rb/eldr.svg)](https://gemnasium.com/eldr-rb/eldr) [![Inline docs](https://inch-ci.org/github/eldr-rb/eldr.svg?branch=master)](http://inch-ci.org/github/eldr-rb/eldr) [![Gratipay](https://img.shields.io/gratipay/k2052.svg)](https://www.gratipay.com/k2052/)

Eldr is a minimal ruby framework that doesn't hide the rack. It aims to be lightweight, simple, modular and above all, clear. Eldr is a ruby framework without all the magic.

Eldr apps are rack apps like this:

```ruby
class App < Eldr::App
  get '/posts' do |params|
    Rack::Response.new "posts", 200
  end
end
```

Since they are rack apps you can boot them like this:

```ruby
run App
```

And when you want to combine them you can do this:

```ruby
class Posts < Eldr::App
  get '/' do |params|
    Rack::Response.new "posts", 200
  end
end

class Tasks < Eldr::App
  get '/' do |params|
    Rack::Response.new "tasks", 200
  end
end

map '/posts' do
  Posts.new
end

map '/tasks' do
  run Tasks.new
end
```

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of Contents

- [Eldr](#eldr)
  - [Features](#features)
  - [Installation and Usage](#installation-and-usage)
  - [Quickstart Guides](#quickstart-guides)
    - [Hello World](#hello-world)
    - [Rendering a Template](#rendering-a-template)
    - [Before/After Filters](#beforeafter-filters)
    - [Helpers](#helpers)
    - [Rails Style Routing](#rails-style-routing)
    - [Rails Style Responses](#rails-style-responses)
    - [Errors](#errors)
    - [Error Catching](#error-catching)
    - [Rails Style Requests](#rails-style-requests)
    - [Conditions](#conditions)
    - [Access Control](#access-control)
    - [Inheritance](#inheritance)
    - [Extensions](#extensions)
      - [Extending using Ruby patterns](#extending-using-ruby-patterns)
      - [Extending using Rack](#extending-using-rack)
    - [Using Rack inside Eldr](#using-rack-inside-eldr)
    - [Redirecting Things](#redirecting-things)
    - [Route Handlers: The Power of Action Objects](#route-handlers-the-power-of-action-objects)
    - [Testing Eldr Apps](#testing-eldr-apps)
  - [Performance](#performance)
  - [Help/Resources](#helpresources)
  - [Contributing](#contributing)
  - [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Features

- **Small**           Eldr's core is under 500 lines; you can learn it in an afternoon.
- **Flexible**        Build your apps how you want to and with what you want.
- **Modular**         Eldr's views, response helpers, sessions etc; are all independent gems.
- **No Magic**        Eldr encourages you to build apps that you actually understand.
- **Fast**            Eldr is among the fastest ruby microframeworks and it is getting faster.
- **Powerful Router** Powered by [Mustermann](https://github.com/rkh/mustermann) -- you can use everything from Sinatra to Rails style routing.
- **Flexible**        That router? Is also just a Rack app. You can swap it out just like everything else in Eldr.
- **Extensible** with standard ruby classes, modules, and patterns. In Eldr there are no mystical helper blocks.

## Installation and Usage

To install Eldr add the following to your gemfile:

```ruby
gem 'eldr'
# or if you want to use the master branch:
# gem 'eldr', github: 'eldr-rb/eldr'
```

Then run bundler:

```sh
$ bundle
```

To use it you need to create a rackup file. Add the following to a config.ru file:

```ruby
class HelloWorld < Edlr::App
  get '/', proc { [200, {'Content-Type' => 'txt'}, ['Hello World!']]}
end

run HelloWorld
```

Route handlers are anything that respond to call and return a valid Rack response. All the http verbs you expect are available:

```ruby
get '/',  proc { [200, {'Content-Type' => 'txt'}, ['Hello World!']]}
post '/', proc { [201, {'Content-Type' => 'txt'}, ['Hello World!']]}
```

etc...

For further usage examples checkout the  [https://github.com/eldr-rb/eldr/tree/master/examples](examples folder)

I have already built and released extensions for many common tasks:

- [eldr-sessions](https://github.com/eldr-rb/eldr-sessions): session helpers like `signed_in?` and `current_user?`
- [eldr-rendering](https://github.com/eldr-rb/eldr-rendering): a `render` helper for templating.
- [eldr-assets](https://github.com/eldr-rb/eldr-assets): asset tag helpers like `js('jquery', 'app')`, `css('app')` etc
- [eldr-responders](https://github.com/eldr-rb/eldr-responders): rails-responder like helpers
- [eldr-action](https://github.com/eldr-rb/eldr-action): Action Objects
- [eldr-service](https://github.com/eldr-rb/eldr-service): Action Objects for external services.
- [eldr-cascade](https://github.com/eldr-rb/eldr-cascade): A fork of Rack::Cascade that plays well with Rack::Response and eldr-action.<commit_msg>remove eldr-service link from readme<commit_after># Eldr [![Build Status](https://travis-ci.org/eldr-rb/eldr.svg)](https://travis-ci.org/eldr-rb/eldr) [![Code Climate](https://codeclimate.com/github/eldr-rb/eldr/badges/gpa.svg)](https://codeclimate.com/github/eldr-rb/eldr) [![Coverage Status](https://coveralls.io/repos/eldr-rb/eldr/badge.svg?branch=master)](https://coveralls.io/r/eldr-rb/eldr?branch=master) [![Dependency Status](https://gemnasium.com/eldr-rb/eldr.svg)](https://gemnasium.com/eldr-rb/eldr) [![Inline docs](https://inch-ci.org/github/eldr-rb/eldr.svg?branch=master)](http://inch-ci.org/github/eldr-rb/eldr) [![Gratipay](https://img.shields.io/gratipay/k2052.svg)](https://www.gratipay.com/k2052/)

Eldr is a minimal ruby framework that doesn't hide the rack. It aims to be lightweight, simple, modular and above all, clear. Eldr is a ruby framework without all the magic.

Eldr apps are rack apps like this:

```ruby
class App < Eldr::App
  get '/posts' do |params|
    Rack::Response.new "posts", 200
  end
end
```

Since they are rack apps you can boot them like this:

```ruby
run App
```

And when you want to combine them you can do this:

```ruby
class Posts < Eldr::App
  get '/' do |params|
    Rack::Response.new "posts", 200
  end
end

class Tasks < Eldr::App
  get '/' do |params|
    Rack::Response.new "tasks", 200
  end
end

map '/posts' do
  Posts.new
end

map '/tasks' do
  run Tasks.new
end
```

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of Contents

- [Eldr](#eldr)
  - [Features](#features)
  - [Installation and Usage](#installation-and-usage)
  - [Quickstart Guides](#quickstart-guides)
    - [Hello World](#hello-world)
    - [Rendering a Template](#rendering-a-template)
    - [Before/After Filters](#beforeafter-filters)
    - [Helpers](#helpers)
    - [Rails Style Routing](#rails-style-routing)
    - [Rails Style Responses](#rails-style-responses)
    - [Errors](#errors)
    - [Error Catching](#error-catching)
    - [Rails Style Requests](#rails-style-requests)
    - [Conditions](#conditions)
    - [Access Control](#access-control)
    - [Inheritance](#inheritance)
    - [Extensions](#extensions)
      - [Extending using Ruby patterns](#extending-using-ruby-patterns)
      - [Extending using Rack](#extending-using-rack)
    - [Using Rack inside Eldr](#using-rack-inside-eldr)
    - [Redirecting Things](#redirecting-things)
    - [Route Handlers: The Power of Action Objects](#route-handlers-the-power-of-action-objects)
    - [Testing Eldr Apps](#testing-eldr-apps)
  - [Performance](#performance)
  - [Help/Resources](#helpresources)
  - [Contributing](#contributing)
  - [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Features

- **Small**           Eldr's core is under 500 lines; you can learn it in an afternoon.
- **Flexible**        Build your apps how you want to and with what you want.
- **Modular**         Eldr's views, response helpers, sessions etc; are all independent gems.
- **No Magic**        Eldr encourages you to build apps that you actually understand.
- **Fast**            Eldr is among the fastest ruby microframeworks and it is getting faster.
- **Powerful Router** Powered by [Mustermann](https://github.com/rkh/mustermann) -- you can use everything from Sinatra to Rails style routing.
- **Flexible**        That router? Is also just a Rack app. You can swap it out just like everything else in Eldr.
- **Extensible** with standard ruby classes, modules, and patterns. In Eldr there are no mystical helper blocks.

## Installation and Usage

To install Eldr add the following to your gemfile:

```ruby
gem 'eldr'
# or if you want to use the master branch:
# gem 'eldr', github: 'eldr-rb/eldr'
```

Then run bundler:

```sh
$ bundle
```

To use it you need to create a rackup file. Add the following to a config.ru file:

```ruby
class HelloWorld < Edlr::App
  get '/', proc { [200, {'Content-Type' => 'txt'}, ['Hello World!']]}
end

run HelloWorld
```

Route handlers are anything that respond to call and return a valid Rack response. All the http verbs you expect are available:

```ruby
get '/',  proc { [200, {'Content-Type' => 'txt'}, ['Hello World!']]}
post '/', proc { [201, {'Content-Type' => 'txt'}, ['Hello World!']]}
```

etc...

For further usage examples checkout the  [https://github.com/eldr-rb/eldr/tree/master/examples](examples folder)

I have already built and released extensions for many common tasks:

- [eldr-sessions](https://github.com/eldr-rb/eldr-sessions): session helpers like `signed_in?` and `current_user?`
- [eldr-rendering](https://github.com/eldr-rb/eldr-rendering): a `render` helper for templating.
- [eldr-assets](https://github.com/eldr-rb/eldr-assets): asset tag helpers like `js('jquery', 'app')`, `css('app')` etc
- [eldr-responders](https://github.com/eldr-rb/eldr-responders): rails-responder like helpers
- [eldr-action](https://github.com/eldr-rb/eldr-action): Action Objects
- [eldr-cascade](https://github.com/eldr-rb/eldr-cascade): A fork of Rack::Cascade that plays well with Rack::Response and eldr-action.
{'fraction_non_alphanumeric': 0.15454199200152352, 'fraction_numerical': 0.0055227575699866695, 'mean_word_length': 3.9056515646893977, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 39, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3033796', 'n_tokens_mistral': 3647, 'n_tokens_neox': 3401, 'n_words': 999}