Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jpmckinney/rabx-message
A RPC using Anything But XML (RABX) message parser and emitter
https://github.com/jpmckinney/rabx-message
Last synced: about 1 month ago
JSON representation
A RPC using Anything But XML (RABX) message parser and emitter
- Host: GitHub
- URL: https://github.com/jpmckinney/rabx-message
- Owner: jpmckinney
- License: mit
- Created: 2015-01-24T20:46:06.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-05-23T04:22:57.000Z (over 6 years ago)
- Last Synced: 2024-04-25T03:01:46.006Z (9 months ago)
- Language: Ruby
- Size: 11.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RPC using Anything But XML (RABX) message parser and emitter
[![Gem Version](https://badge.fury.io/rb/rabx-message.svg)](https://badge.fury.io/rb/rabx-message)
[![Build Status](https://secure.travis-ci.org/jpmckinney/rabx-message.png)](https://travis-ci.org/jpmckinney/rabx-message)
[![Coverage Status](https://coveralls.io/repos/jpmckinney/rabx-message/badge.png)](https://coveralls.io/r/jpmckinney/rabx-message)
[![Code Climate](https://codeclimate.com/github/jpmckinney/rabx-message.png)](https://codeclimate.com/github/jpmckinney/rabx-message)The RABX specification is a [Perl module](https://github.com/mysociety/commonlib/blob/master/perllib/RABX.pm) by [mySociety](https://www.mysociety.org/).
## Usage
```ruby
require 'rabx/message'
```Dump a RABX message:
```ruby
RABX::Message.dump('R', 'RPC.method', ['argument', 3])
# => "R1:0,10:RPC.method,L1:2,T8:argument,I1:3,"
RABX::Message.dump('S', {name: 'foo', email: '[email protected]'})
# => "S1:0,A1:2,T4:name,T3:foo,T5:email,T15:[email protected],"
RABX::Message.dump('E', 404, 'Not Found')
# => "E1:0,3:404,9:Not Found,N"
```Load a RABX message:
```ruby
message = RABX::Message.load("R1:0,10:RPC.method,L1:2,T8:argument,I1:3,")
message.type # "R"
message.method # "RPC.method"
message.arguments # ["argument", 3]message = RABX::Message.load("S1:0,A1:2,T4:name,T3:foo,T5:email,T15:[email protected],")
message.type # "S"
message.value # {"name"=>"foo", "email"=>"[email protected]"}message = RABX::Message.load("E1:0,3:404,9:Not Found,N")
message.type # "E"
message.code # "404"
message.text # "Not Found"
message.extra # nil
```See the [documentation](http://www.rubydoc.info/gems/rabx-message) to see how to work with `RABX::Message` instances.
## Notes
Generic RABX clients include:
* [Perl](https://github.com/mysociety/commonlib/blob/master/perllib/RABX.pm)
* [PHP](https://github.com/mysociety/commonlib/blob/master/phplib/rabx.php)
* [Python](https://github.com/mysociety/commonlib/blob/master/pylib/mysociety/rabx.py) (REST interface)
* [Ruby](https://github.com/mysociety/commonlib/blob/master/rblib/rabx.rb) (REST interface)
* [Command-line](https://github.com/mysociety/misc-scripts/blob/master/bin/rabx)mySociety has scripts to convert a Perl RABX server to a server-specific client in:
* [Perl](https://github.com/mysociety/misc-scripts/blob/master/bin/rabxtopl.pl)
* [PHP](https://github.com/mysociety/misc-scripts/blob/master/bin/rabxtophp.pl)
* [Python](https://github.com/mysociety/misc-scripts/blob/master/bin/rabxresttopy.pl)
* [Ruby](https://github.com/mysociety/misc-scripts/blob/master/bin/rabxresttorb.pl)Copyright (c) 2014 James McKinney, released under the MIT license