shiolink 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.gitmodules +4 -0
- data/.rspec +3 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +54 -0
- data/Rakefile +9 -0
- data/lib/shiolink.rb +54 -0
- data/shiolink.gemspec +23 -0
- metadata +137 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 75e139aea93e6540b01033cad7ac9fc703a7a0e5
|
4
|
+
data.tar.gz: 974a6722dd849723a7250bb8c592df662a8aeaf8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9746d02410582e198b12ca502b93d68115ddc1ed7299f8f5e2a24bc4c62fb1e9a844979d61299ac7c095ee00e7c1ee635af9e24ccddc594b3b07fae6c9619c06
|
7
|
+
data.tar.gz: 10b46d47f6ef00d5815fbb7071f432370815c5cd5faf8322986bea74efb890360a41cfed3db5a7b4f29bf0633c5a548f90d8f9a3cde1128e672ec3a4e1ac264b
|
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# [Shiolink](https://github.com/Narazaka/shiolink-ruby)
|
2
|
+
|
3
|
+
[![Gem](https://img.shields.io/gem/v/shiolink.svg)](https://rubygems.org/gems/shiolink)
|
4
|
+
[![Gem](https://img.shields.io/gem/dtv/shiolink.svg)](https://rubygems.org/gems/shiolink)
|
5
|
+
[![Gemnasium](https://gemnasium.com/Narazaka/shiolink-ruby.svg)](https://gemnasium.com/Narazaka/shiolink-ruby)
|
6
|
+
[![Inch CI](http://inch-ci.org/github/Narazaka/shiolink-ruby.svg)](http://inch-ci.org/github/Narazaka/shiolink-ruby)
|
7
|
+
[![Build Status](https://travis-ci.org/Narazaka/shiolink-ruby.svg)](https://travis-ci.org/Narazaka/shiolink-ruby)
|
8
|
+
[![codecov.io](https://codecov.io/github/Narazaka/shiolink-ruby/coverage.svg?branch=master)](https://codecov.io/github/Narazaka/shiolink-ruby?branch=master)
|
9
|
+
[![Code Climate](https://codeclimate.com/github/Narazaka/shiolink-ruby/badges/gpa.svg)](https://codeclimate.com/github/Narazaka/shiolink-ruby)
|
10
|
+
|
11
|
+
SHIORI Protocol Parser / Builder for Ruby
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'shiolink'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install shiolink
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'shiolink'
|
33
|
+
|
34
|
+
def load(dirpath)
|
35
|
+
end
|
36
|
+
|
37
|
+
def unload
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
|
41
|
+
def request(req)
|
42
|
+
end
|
43
|
+
|
44
|
+
shiolink = Shiolink.new(method(:load), method(:unload), method(:request))
|
45
|
+
shiolink.start
|
46
|
+
```
|
47
|
+
|
48
|
+
## API
|
49
|
+
|
50
|
+
[API Document](https://narazaka.github.io/shiolink-ruby/index.html)
|
51
|
+
|
52
|
+
## License
|
53
|
+
|
54
|
+
This is released under [MIT License](http://narazaka.net/license/MIT?2016).
|
data/Rakefile
ADDED
data/lib/shiolink.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# SHIOLINK interface
|
2
|
+
class Shiolink
|
3
|
+
# initialize with callbacks
|
4
|
+
# @param [Proc] load SHIORI load(dirpath)
|
5
|
+
# @param [Proc] unload SHIORI unload()
|
6
|
+
# @param [Proc] request SHIORI request(request_str)
|
7
|
+
def initialize(load, unload, request)
|
8
|
+
@load = load
|
9
|
+
@unload = unload
|
10
|
+
@request = request
|
11
|
+
@session = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
# add line
|
15
|
+
# @param [String] line line that ends with "\n"
|
16
|
+
# @return [String] SHIOLINK protocol response string or nil
|
17
|
+
def add_line(line)
|
18
|
+
unless @session
|
19
|
+
case line[0 ... 3]
|
20
|
+
when '*L:'
|
21
|
+
path = line[3 ... line.size].chomp + line.match(/[\/\\]/).to_s
|
22
|
+
@load.call(path)
|
23
|
+
nil
|
24
|
+
when '*S:'
|
25
|
+
@session = ''
|
26
|
+
line
|
27
|
+
when '*U:'
|
28
|
+
@unload.call
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
else
|
32
|
+
@session += line
|
33
|
+
if line.chomp.size != 0
|
34
|
+
nil
|
35
|
+
else
|
36
|
+
response = @request.call(@session)
|
37
|
+
@session = nil
|
38
|
+
response
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# start watching IO
|
44
|
+
# @param [IO] input readable stream
|
45
|
+
# @param [IO] output writable stream
|
46
|
+
def start(input = $stdin, output = $stdout)
|
47
|
+
input.each_line do |line|
|
48
|
+
if response = add_line(line)
|
49
|
+
output.print(response)
|
50
|
+
#output.flush
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/shiolink.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "shiolink"
|
6
|
+
spec.version = "0.0.1"
|
7
|
+
spec.authors = ["Narazaka"]
|
8
|
+
spec.email = ["info@narazaka.net"]
|
9
|
+
|
10
|
+
spec.summary = %q{SHIOLINK interface}
|
11
|
+
spec.description = %q{Ukagaka SHIOLINK inteface}
|
12
|
+
spec.homepage = "https://github.com/Narazaka/shiolink-ruby"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.add_development_dependency "bundler", ">= 1.7.9"
|
18
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
19
|
+
spec.add_development_dependency "rspec", "~> 3.4"
|
20
|
+
spec.add_development_dependency "yard", "~> 0.8.7"
|
21
|
+
spec.add_development_dependency "simplecov", "~> 0.11"
|
22
|
+
spec.add_development_dependency "codecov", "~>0.1"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shiolink
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Narazaka
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.7.9
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.7.9
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.8.7
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.8.7
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.11'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.11'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: codecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.1'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.1'
|
97
|
+
description: Ukagaka SHIOLINK inteface
|
98
|
+
email:
|
99
|
+
- info@narazaka.net
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".gitmodules"
|
106
|
+
- ".rspec"
|
107
|
+
- ".travis.yml"
|
108
|
+
- Gemfile
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- lib/shiolink.rb
|
112
|
+
- shiolink.gemspec
|
113
|
+
homepage: https://github.com/Narazaka/shiolink-ruby
|
114
|
+
licenses: []
|
115
|
+
metadata: {}
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.4.5.1
|
133
|
+
signing_key:
|
134
|
+
specification_version: 4
|
135
|
+
summary: SHIOLINK interface
|
136
|
+
test_files: []
|
137
|
+
has_rdoc:
|