Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tonytonyjan/rr3
Ruby wrapper of c9s/r3
https://github.com/tonytonyjan/rr3
Last synced: about 2 months ago
JSON representation
Ruby wrapper of c9s/r3
- Host: GitHub
- URL: https://github.com/tonytonyjan/rr3
- Owner: tonytonyjan
- License: mit
- Created: 2014-07-29T20:16:05.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-08T18:36:51.000Z (over 10 years ago)
- Last Synced: 2024-04-09T21:30:14.959Z (9 months ago)
- Language: C
- Homepage: https://github.com/c9s/r3
- Size: 262 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Rr3
## Dependency
### OS X
brew install r3
### Ubuntu PPA
The PPA for libr3 can be found in https://launchpad.net/~r3-team/+archive/libr3-daily
## Installation
$ gem install rr3
## Usage
```ruby
require 'rr3'
@tree = Rr3::Tree.new(10)
@tree.insert_path "/bar"
@tree.insert_path "/zoo", 9527
@tree.insert_path "/foo/bar", 9527
@tree.insert_path "/post/{id}", 9527
@tree.insert_path "/user/{id:\\d+}", 9527
@tree.compile!
@tree.match "/user/xxx" # => false # not matched
@tree.match "/asd" # => false
@tree.match "/bar" # => nil # matched, and the route data is `nil`
@tree.match "/zoo" # => 9527 # matched, and the route data is `9527`
@tree.match "/foo/bar" # => 9527
@tree.match "/post/1234" # => 9527
@tree.match "/user/1234" # => 9527
```