StompParser
Fast STOMP parser and serializer for Ruby with native extensions in C for MRI and Rubinius and in Java for JRuby, as well as a pure Ruby parser.
Parsing
parser = StompParser::Parser.new
parser.parse(chunk) do |frame|
puts "We received #{frame.command} frame with #{frame.body} and headers #{frame.headers}!"
end
The chunks do not have to be complete STOMP frames. The callback will be called whenever a complete frame has been parsed. Additionally, StompParser handles escape sequences in headers and body encoding for you.
Serializing
StompParser::Frame.new("SEND", { some: "header" }, "Hello").to_str
Development
Development should be ez.
git clone git@github.com:elabs/stomp_parser.git # git, http://git-scm.com/
cd stomp_parser
brew bundle # Homebrew, http://brew.sh/
bundle install # Bundler, http://bundler.io/
rake # compile state machine, run test suite
A few notes:
- Native dependencies are listed in the Brewfile.
- The stomp message parser is written in Ragel, see parser_common.rl.
- Graphviz is used to visualize the Ragel state machine.
- Most rake tasks will compile the state machine anew if needed.
Contributing
- Fork it on GitHub (http://github.com/elabs/stomp_parser/fork).
- Create your feature branch (
git checkout -b my-new-feature
). - Follow the Development instructions in this README.
- Create your changes, please add tests.
- Commit your changes (
git commit -am 'Add some feature'
). - Push to the branch (
git push origin my-new-feature
). - Create new pull request on GitHub.