nest 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +1 -1
- data/lib/nest.rb +2 -0
- data/nest.gemspec +2 -2
- metadata +2 -3
- data/test/commands.rb +0 -72
data/README.markdown
CHANGED
data/lib/nest.rb
CHANGED
data/nest.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "nest"
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.2"
|
4
4
|
s.summary = "Generate nested namespaced keys for key-value databases."
|
5
5
|
s.description = "It is a design pattern in key-value databases to use the key to simulate structure, and Nest can take care of that."
|
6
6
|
s.authors = ["Michel Martens"]
|
7
7
|
s.email = ["michel@soveran.com"]
|
8
8
|
s.homepage = "http://github.com/soveran/nest"
|
9
|
-
s.files = ["LICENSE", "README.markdown", "Rakefile", "lib/nest.rb", "nest.gemspec", "test/
|
9
|
+
s.files = ["LICENSE", "README.markdown", "Rakefile", "lib/nest.rb", "nest.gemspec", "test/nest_test.rb", "test/test_helper.rb"]
|
10
10
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Michel Martens
|
@@ -33,7 +33,6 @@ files:
|
|
33
33
|
- Rakefile
|
34
34
|
- lib/nest.rb
|
35
35
|
- nest.gemspec
|
36
|
-
- test/commands.rb
|
37
36
|
- test/nest_test.rb
|
38
37
|
- test/test_helper.rb
|
39
38
|
has_rdoc: true
|
data/test/commands.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
require "open3"
|
2
|
-
require "socket"
|
3
|
-
|
4
|
-
module Test::Commands
|
5
|
-
def sh(cmd)
|
6
|
-
out, err = nil
|
7
|
-
|
8
|
-
Open3.popen3(cmd) do |_in, _out, _err|
|
9
|
-
out = _out.read
|
10
|
-
err = _err.read
|
11
|
-
end
|
12
|
-
|
13
|
-
[out, err]
|
14
|
-
end
|
15
|
-
|
16
|
-
# Runs a command in the background, silencing all output.
|
17
|
-
# For debugging purposes, set the environment variable VERBOSE.
|
18
|
-
def sh_bg(cmd)
|
19
|
-
if ENV["VERBOSE"]
|
20
|
-
streams_to_silence = []
|
21
|
-
else
|
22
|
-
streams_to_silence = [$stdout, $stderr]
|
23
|
-
cmd = "#{cmd} 2>&1>/dev/null"
|
24
|
-
end
|
25
|
-
|
26
|
-
silence_stream(*streams_to_silence) do
|
27
|
-
(pid = fork) ? Process.detach(pid) : exec(cmd)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def listening?(host, port)
|
32
|
-
begin
|
33
|
-
socket = TCPSocket.new(host, port)
|
34
|
-
socket.close unless socket.nil?
|
35
|
-
true
|
36
|
-
rescue Errno::ECONNREFUSED,
|
37
|
-
Errno::EBADF, # Windows
|
38
|
-
Errno::EADDRNOTAVAIL # Windows
|
39
|
-
false
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def wait_for_service(host, port, timeout = 3)
|
44
|
-
start_time = Time.now
|
45
|
-
|
46
|
-
until listening?(host, port)
|
47
|
-
if timeout && (Time.now > (start_time + timeout))
|
48
|
-
raise SocketError.new("Socket #{host}:#{port} did not open within #{timeout} seconds")
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
true
|
53
|
-
end
|
54
|
-
|
55
|
-
def suspects(port)
|
56
|
-
list = sh("lsof -i :#{port}").first.split("\n")[1..-1] || []
|
57
|
-
list.map {|s| s[/^.+? (\d+)/, 1] }
|
58
|
-
end
|
59
|
-
|
60
|
-
def silence_stream(*streams) #:yeild:
|
61
|
-
on_hold = streams.collect{ |stream| stream.dup }
|
62
|
-
streams.each do |stream|
|
63
|
-
stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
|
64
|
-
stream.sync = true
|
65
|
-
end
|
66
|
-
yield
|
67
|
-
ensure
|
68
|
-
streams.each_with_index do |stream, i|
|
69
|
-
stream.reopen(on_hold[i])
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|