Project

shioruby

0.0
No commit activity in last 3 years
No release in over 3 years
Ukagaka SHIORI Protocol Request Parser / Response Builder
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.7.9
~> 0.1
~> 10.0
~> 3.4
~> 0.11
~> 0.8.7
 Project Readme

Gem Gem Gemnasium Inch CI Travis Build Status AppVeyor Build Status codecov.io Code Climate

SHIORI Protocol Parser / Builder for Ruby

Installation

Add this line to your application's Gemfile:

gem 'shioruby'

And then execute:

$ bundle

Or install it yourself as:

$ gem install shioruby

Usage

require 'shioruby'

p Shioruby.parse_request(<<-EOS
GET SHIORI/3.0
Charset: UTF-8
Sender: ikagaka
ID: OnClose
Reference0: user

EOS
)
#<OpenStruct method="GET", version="3.0", Charset="UTF-8", Sender="ikagaka", ID="OnClose", Reference0="user">

p Shioruby.build_response(OpenStruct.new({
  code: 200,
  version: '3.0',
  Value: '\h\s[0]\e',
  Charset: 'UTF-8',
  Sender: 'shioruby',
}))
#"SHIORI/3.0 200 OK\nValue: \\h\\s[0]\\e\nCharset: UTF-8\nSender: shioruby\n\n"

request = Shioruby.parse_request(<<-EOS
GET SHIORI/3.0
Charset: UTF-8
Sender: ikagaka
ID: otherghostname
Reference0: sakura\x010\x0110

EOS
)
p request.Reference0.separated
#["sakura", "0", "10"]

# sakura.recommendsites etc.
sites = [
  ['Shioruby', 'https://github.com/Narazaka/shioruby', '', '\h\s[0]This is Shioruby site.\e'],
  ['ShioriJK', 'https://github.com/Narazaka/shiorijk', '', '\h\s[0]This is ShioriJK site.\e'],
]
response_str = Shioruby.build_response(OpenStruct.new({
  code: 200,
  version: '3.0',
  Value: sites.combined2,
  Charset: 'UTF-8',
  Sender: 'shioruby',
}))
p response_str
#"SHIORI/3.0 200 OK\nValue: Shioruby\u0001https://github.com/Narazaka/shioruby\u0001\u0001\\h\\s[0]This is Shioruby site.\\e\u0002ShioriJK\u0001https://github.com/Narazaka/shiorijk\u0001\u0001\\h\\s[0]This is ShioriJK site.\\e\nCharset: UTF-8\nSender: shioruby\n\n"

API

API Document

License

This is released under MIT License.