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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c93b6cac5618173e86c540e2446d38951fe8d850
4
- data.tar.gz: 8fec53e267e784fff36b0590f29d229ab2f5cec1
3
+ metadata.gz: 6c408fa52aaca6497e9232d1d40b6838087e5141
4
+ data.tar.gz: 35f591904b7ed9cbca28c806133b9f31e733ac7d
5
5
  SHA512:
6
- metadata.gz: a194fe567ce9591b13df3148a7f4f10b388e13bd3c70a95477db1e0f575113b2e5555d7fe1a326a9d2d0402028e930e20da5ee7cb5a0cca437c0d8faa82136bc
7
- data.tar.gz: ea83519987f2cffe4798a6e7622cc93304e2c61abf24b4396f3e47a8965ffec6c2e5222ec0ecc73c19da360a8b7a48ea3674786ffb30aa2a1977eaa62dc0e4cc
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
- # run a daemon bound to localhost port 23456
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
- port: 12123
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|
@@ -45,7 +45,7 @@ module Sockd
45
45
  Options:
46
46
  EOF
47
47
 
48
- instance_exec(opts, callback) if callback
48
+ instance_exec(opts, &callback) if callback
49
49
 
50
50
  opts.on("-p", "--port PORT", String, "Listen on TCP port PORT (default: #{options[:port]})") do |x|
51
51
  options[:port] = x
data/lib/sockd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sockd
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.2
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-03-19 00:00:00.000000000 Z
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