Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/undr/middlestack
The Middlestack is a simple and convenient way to build and run your own middleware stack for ruby
https://github.com/undr/middlestack
Last synced: about 1 month ago
JSON representation
The Middlestack is a simple and convenient way to build and run your own middleware stack for ruby
- Host: GitHub
- URL: https://github.com/undr/middlestack
- Owner: undr
- License: mit
- Created: 2015-04-01T16:17:36.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-04-02T05:04:40.000Z (over 9 years ago)
- Last Synced: 2024-08-31T23:15:45.269Z (4 months ago)
- Language: Ruby
- Homepage: https://github.com/undr/middlestack
- Size: 121 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Middlestack
The Middlestack is a simple and convenient way to build and run of your own middleware stack for ruby
[![Build Status](https://travis-ci.org/undr/middlestack.svg)](https://travis-ci.org/undr/middlestack)
[![Code Climate](https://codeclimate.com/github/undr/middlestack/badges/gpa.svg)](https://codeclimate.com/github/undr/middlestack)
[![Test Coverage](https://codeclimate.com/github/undr/middlestack/badges/coverage.svg)](https://codeclimate.com/github/undr/middlestack)
[![Gem Version](https://badge.fury.io/rb/middlestack.svg)](http://badge.fury.io/rb/middlestack)## Installation
Add this line to your application's Gemfile:
```ruby
gem 'middlestack'
```And then execute:
```
$ bundle
```Or install it yourself as:
```
$ gem install middlestack
```## Usage
It's pretty simple.
```ruby
class TraceValue < Struct.new(:env, :value)
def before
env << ('->' + value)
enddef after
env << ('<-' + value)
end
endclass Executor
include Middlestack::Helpermiddlewares do
use TraceValue, 'A'
use TraceValue, 'B'
use TraceValue, 'C'
enddef execute
run_middlewares([]){|env| env << 'run' }
end
endExecutor.new.execute
# => ['->A', '->B', '->C', 'run', '<-C', '<-B', '<-A']
```That's all. Have a nice code!
## Contributing
1. Fork it ( https://github.com/undr/middlestack/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request