riser 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/riser.rb +1 -0
- data/lib/riser/compat.rb +28 -0
- data/lib/riser/poll.rb +3 -0
- data/lib/riser/services.rb +1 -2
- data/lib/riser/stream.rb +19 -5
- data/lib/riser/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9ae7fbe0d87eb7546bcd3df41adb101c0c66bb964e07de7d3658cf63d397562
|
4
|
+
data.tar.gz: 288ab38bbd42a41f31a399f12289adf4cdc8ad700ac649a09fea2ec593a2b4f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98f72efdfda6c5eee8e7adcb0b3a0d5d6ceca0df6f73b1bd544b3eae535f62e671b76a29074bd60c9992943852e89d294e02b38788496e97bf0f66c276462dd4
|
7
|
+
data.tar.gz: e8f52a3f99f42d6bb4e7c05a260165a82d4712669490f9717c95e87639af9551c3aa0288102a813a212897d0f6f8b83465255d0eebdda89f69ead6d7e7757795
|
data/lib/riser.rb
CHANGED
data/lib/riser/compat.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
module Riser
|
6
|
+
# to use `StringIO' as mock in unit test. this module provides the
|
7
|
+
# refinement to add missing `IO' methods to `StringIO'.
|
8
|
+
module CompatibleStringIO
|
9
|
+
refine StringIO do
|
10
|
+
def to_io
|
11
|
+
self
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_i
|
15
|
+
-1
|
16
|
+
end
|
17
|
+
|
18
|
+
def wait_readable(timeout_seconds)
|
19
|
+
! eof?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Local Variables:
|
26
|
+
# mode: Ruby
|
27
|
+
# indent-tabs-mode: nil
|
28
|
+
# End:
|
data/lib/riser/poll.rb
CHANGED
data/lib/riser/services.rb
CHANGED
data/lib/riser/stream.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
+
require 'digest'
|
4
|
+
|
3
5
|
module Riser
|
4
6
|
class Stream
|
7
|
+
using CompatibleStringIO
|
8
|
+
|
5
9
|
def initialize(io)
|
6
10
|
@io = io
|
7
11
|
end
|
@@ -74,36 +78,46 @@ module Riser
|
|
74
78
|
end
|
75
79
|
|
76
80
|
class LoggingStream < Stream
|
81
|
+
using CompatibleStringIO
|
82
|
+
|
83
|
+
def self.make_tag(io)
|
84
|
+
hex = Digest::SHA256.hexdigest(io.to_s)[0, 7]
|
85
|
+
fd = io.to_io.to_i
|
86
|
+
"[#{hex},#{fd}]"
|
87
|
+
end
|
88
|
+
|
77
89
|
def initialize(io, logger)
|
78
90
|
super(io)
|
79
91
|
@logger = logger
|
92
|
+
@tag = self.class.make_tag(io)
|
93
|
+
@logger.debug("#{@tag} start") if @logger.debug?
|
80
94
|
end
|
81
95
|
|
82
96
|
def gets
|
83
97
|
line = super
|
84
|
-
@logger.info("r #{line.inspect}") if @logger.info?
|
98
|
+
@logger.info("#{@tag} r #{line.inspect}") if @logger.info?
|
85
99
|
line
|
86
100
|
end
|
87
101
|
|
88
102
|
def read(size)
|
89
103
|
data = super
|
90
|
-
@logger.info("r #{data.inspect}") if @logger.info?
|
104
|
+
@logger.info("#{@tag} r #{data.inspect}") if @logger.info?
|
91
105
|
data
|
92
106
|
end
|
93
107
|
|
94
108
|
def readpartial(maxlen, outbuf=nil)
|
95
109
|
data = super
|
96
|
-
@logger.info("r #{data.inspect}") if @logger.info?
|
110
|
+
@logger.info("#{@tag} r #{data.inspect}") if @logger.info?
|
97
111
|
data
|
98
112
|
end
|
99
113
|
|
100
114
|
def write(message)
|
101
|
-
@logger.info("w #{message.inspect}") if @logger.info?
|
115
|
+
@logger.info("#{@tag} w #{message.inspect}") if @logger.info?
|
102
116
|
super
|
103
117
|
end
|
104
118
|
|
105
119
|
def close
|
106
|
-
@logger.info(
|
120
|
+
@logger.info("#{@tag} close") if @logger.info?
|
107
121
|
super
|
108
122
|
end
|
109
123
|
end
|
data/lib/riser/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TOKI Yoshinori
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- example/simple_services.rb
|
95
95
|
- example/simple_tls.rb
|
96
96
|
- lib/riser.rb
|
97
|
+
- lib/riser/compat.rb
|
97
98
|
- lib/riser/daemon.rb
|
98
99
|
- lib/riser/poll.rb
|
99
100
|
- lib/riser/resource.rb
|