freeport 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/bin/console +0 -0
- data/lib/freeport.rb +12 -7
- data/lib/freeport/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: 5d3dbad6699fca1be886a0469085c98e4c118079
|
4
|
+
data.tar.gz: f939a9f26d7b48c0fce4533f1e3f5016bc39f801
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26be12bf825b026a92fc5504ea502269fc97ef76905647b90f17fe6ae6ea878ae248664b28b93dc1c51988642d8eb087dbce7473e79fd97a15030206b5dc1c7f
|
7
|
+
data.tar.gz: 86f4763d6248c3f56940c6b27054a4a2aff64f028273448c2073165a66e2eb7ab3bb7965a006437bed9b7b2191061f23c6332f79c912b1e5f66b0e2672cb15f4
|
data/bin/console
CHANGED
File without changes
|
data/lib/freeport.rb
CHANGED
@@ -10,21 +10,21 @@ module Freeport
|
|
10
10
|
class OutOfPorts < Exception; end
|
11
11
|
class << self
|
12
12
|
def port
|
13
|
-
@ports ||= (PORT_START..PORT_END).to_a
|
14
13
|
2.times do |try|
|
15
|
-
|
16
|
-
until
|
17
|
-
port =
|
18
|
-
|
14
|
+
ports.empty? and try==0 and @ports = (PORT_START..PORT_END).to_a
|
15
|
+
until ports.empty?
|
16
|
+
port = ports.sample
|
17
|
+
ports.delete(port)
|
19
18
|
return port if useable port
|
20
19
|
end
|
21
20
|
end
|
22
21
|
raise Freeport::OutOfPorts if try > 0
|
23
22
|
end
|
23
|
+
alias_method :p,:port
|
24
24
|
def available
|
25
|
-
|
25
|
+
ports.size
|
26
26
|
end
|
27
|
-
|
27
|
+
alias_method :a,:available
|
28
28
|
def useable port
|
29
29
|
begin
|
30
30
|
Timeout::timeout(2) do
|
@@ -39,5 +39,10 @@ module Freeport
|
|
39
39
|
true
|
40
40
|
end
|
41
41
|
end
|
42
|
+
alias_method :u,:useable
|
43
|
+
private
|
44
|
+
def ports
|
45
|
+
@ports ||= (PORT_START..PORT_END).to_a
|
46
|
+
end
|
42
47
|
end
|
43
48
|
end
|
data/lib/freeport/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: freeport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathias Kaufmann
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -79,3 +79,4 @@ signing_key:
|
|
79
79
|
specification_version: 4
|
80
80
|
summary: Simple helper to search for bindable tcp ports.
|
81
81
|
test_files: []
|
82
|
+
has_rdoc:
|