sockd 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/listd.rb +50 -0
- data/examples/piglatin.rb +4 -3
- data/lib/sockd/optparse.rb +1 -1
- data/lib/sockd/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c408fa52aaca6497e9232d1d40b6838087e5141
|
4
|
+
data.tar.gz: 35f591904b7ed9cbca28c806133b9f31e733ac7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d97338cf055354fc53625b0ed8fe2a41319b12f8851e67e65ebfedd6a0255c7dc7acc4ee0cd640769a585fef5986c5fab525a7cf94cda12bdb2f31f41bbee0aa
|
7
|
+
data.tar.gz: d3eb97509a892e7ed8c8f13f7d929e339f8069719554f9abe30feb480840bc8c00f9ae392559052aecfd6040d22f0812076d174c8899a722a31012adc4409f26
|
data/examples/listd.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'sockd'
|
4
|
+
|
5
|
+
Sockd.run 'listd' do |sockd|
|
6
|
+
|
7
|
+
sockd.options = {
|
8
|
+
pid_path: '/tmp/listd.pid',
|
9
|
+
socket: '/tmp/listd.sock'
|
10
|
+
}
|
11
|
+
|
12
|
+
array = []
|
13
|
+
index = 0
|
14
|
+
|
15
|
+
sockd.handle do |message, socket|
|
16
|
+
command, *params = message.split(' ')
|
17
|
+
|
18
|
+
response =
|
19
|
+
case command
|
20
|
+
when 'add'
|
21
|
+
array.push(*params)
|
22
|
+
sockd.log 'added ' + params.join(' ')
|
23
|
+
''
|
24
|
+
when 'remove'
|
25
|
+
array.delete(*params)
|
26
|
+
sockd.log 'removed ' + params.join(' ')
|
27
|
+
index = 0
|
28
|
+
''
|
29
|
+
when 'get'
|
30
|
+
if array.empty?
|
31
|
+
''
|
32
|
+
else
|
33
|
+
value = array[index]
|
34
|
+
index = (index + 1) % array.size
|
35
|
+
value
|
36
|
+
end
|
37
|
+
when 'list'
|
38
|
+
array.join(' ') || ''
|
39
|
+
when 'reset'
|
40
|
+
array = []
|
41
|
+
index = 0
|
42
|
+
sockd.log 'list reset'
|
43
|
+
''
|
44
|
+
else
|
45
|
+
'bad command'
|
46
|
+
end
|
47
|
+
|
48
|
+
socket.print response + "\r\n"
|
49
|
+
end
|
50
|
+
end
|
data/examples/piglatin.rb
CHANGED
@@ -2,11 +2,12 @@
|
|
2
2
|
|
3
3
|
require 'sockd'
|
4
4
|
|
5
|
-
|
6
|
-
Sockd.run 'piglatin', pid_path: '/tmp/piglatin.pid', port: 23456 do |sockd|
|
5
|
+
Sockd.run 'piglatin' do |sockd|
|
7
6
|
|
8
7
|
sockd.options = {
|
9
|
-
|
8
|
+
pid_path: '/tmp/piglatin.pid',
|
9
|
+
host: '0.0.0.0',
|
10
|
+
port: 23456
|
10
11
|
}
|
11
12
|
|
12
13
|
sockd.handle do |message, socket|
|
data/lib/sockd/optparse.rb
CHANGED
data/lib/sockd/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sockd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Greiling
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- LICENSE
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
|
+
- examples/listd.rb
|
53
54
|
- examples/piglatin.rb
|
54
55
|
- lib/sockd.rb
|
55
56
|
- lib/sockd/errors.rb
|