local_port 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.gitignore +1 -3
- data/ChangeLog.md +10 -0
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/{README.rdoc → README.md} +4 -7
- data/Rakefile +25 -33
- data/lib/local_port.rb +5 -12
- data/local_port.gemspec +3 -7
- metadata +16 -79
- data/.document +0 -4
- data/.rspec +0 -1
- data/ChangeLog.rdoc +0 -4
- data/lib/local_port/version.rb +0 -4
- data/spec/local_port_spec.rb +0 -8
- data/spec/spec_helper.rb +0 -4
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MjY2OTc2ZTRhODNkZmQ3MDk4MjRkZWVlMzA5ZTZiZDE3ZTE4ZDM1MjYzYjdh
|
10
|
-
NzEzNDFkZWU4ZWI3M2FlMmIwNzFmYjY0ODRiOTJiNzU0MmM2OWEwZGU1ODVi
|
11
|
-
Nzc0YmMzOWZhOTY3OTI4M2VkY2M2N2I0OGEyYWUxYmU5YTYzNmE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NmMzNWVkZmY1MTU0YTViN2Q1OTk5NzJhOWRlNTczMDc2MzU1MmI5MzJmMGVj
|
14
|
-
ZTI2M2EwMDI0Y2FlNDVjNGIyMjdiNmZhMTExMTMyN2YxN2Y2ZjVhMTNkMzJm
|
15
|
-
Njk5ZWE5MjhlMWQ4ZDkwMTg4MzgxZmI5ODI3NGQ1NmMxOGQwMTQ=
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 750f9b0d5e2734768d221787279ca37c22081efcc148f21c3edf5648777df5f8
|
4
|
+
data.tar.gz: dca68ca5257f08ef2f91343ca7e730a32227c8eb221d24b4ce81b0e2067b4416
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5ddd104a4a5bc9676339c35ba34b22f8db10f53669f4a3282562fa832e19e24468522511cd9b645612599e19b494ac90c20e47b6ef74484f1e77b893d5249f8a
|
7
|
+
data.tar.gz: ea7592b03ba1366220ac8c118bda60b363dbaef24669daaf35cd59030905e6fe9de510734b05d4485b163b920718ecac34313e1a650839a7ad037c27b8dd4ab6
|
data/.gitignore
CHANGED
data/ChangeLog.md
ADDED
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/{README.rdoc → README.md}
RENAMED
@@ -1,13 +1,10 @@
|
|
1
|
-
|
1
|
+
# LocalPort
|
2
2
|
|
3
|
-
|
4
|
-
* {Email}[mailto:mail at janlelis.de]
|
5
|
-
|
6
|
-
== Features
|
3
|
+
## Features
|
7
4
|
|
8
5
|
LocalPort.free?(port_number) # returns false when port already is in use
|
9
6
|
LocalPort.next_free_one(port_number) # returns number of port that is usable
|
10
7
|
|
11
|
-
|
8
|
+
## J-_-L
|
12
9
|
|
13
|
-
(c) 2013 Jan Lelis, MIT
|
10
|
+
(c) 2013, 2021 Jan Lelis, MIT
|
data/Rakefile
CHANGED
@@ -1,36 +1,28 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
require 'rake'
|
22
|
-
|
23
|
-
require 'rubygems/tasks'
|
24
|
-
Gem::Tasks.new
|
25
|
-
|
26
|
-
require 'rdoc/task'
|
27
|
-
RDoc::Task.new do |rdoc|
|
28
|
-
rdoc.title = "local_port"
|
1
|
+
# # #
|
2
|
+
# Get gemspec info
|
3
|
+
|
4
|
+
gemspec_file = Dir["*.gemspec"].first
|
5
|
+
gemspec = eval File.read(gemspec_file), binding, gemspec_file
|
6
|
+
info = "#{gemspec.name} | #{gemspec.version} | " \
|
7
|
+
"#{gemspec.runtime_dependencies.size} dependencies | " \
|
8
|
+
"#{gemspec.files.size} files"
|
9
|
+
|
10
|
+
# # #
|
11
|
+
# Gem build and install task
|
12
|
+
|
13
|
+
desc info
|
14
|
+
task :gem do
|
15
|
+
puts info + "\n\n"
|
16
|
+
print " "; sh "gem build #{gemspec_file}"
|
17
|
+
FileUtils.mkdir_p "pkg"
|
18
|
+
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", "pkg"
|
19
|
+
puts; sh %{gem install --no-document pkg/#{gemspec.name}-#{gemspec.version}.gem}
|
29
20
|
end
|
30
|
-
task :doc => :rdoc
|
31
21
|
|
32
|
-
|
33
|
-
|
22
|
+
# # #
|
23
|
+
# Start an IRB session with the gem loaded
|
34
24
|
|
35
|
-
|
36
|
-
task :
|
25
|
+
desc "#{gemspec.name} | IRB"
|
26
|
+
task :irb do
|
27
|
+
sh "irb -I ./lib -r #{gemspec.name.gsub '-','/'}"
|
28
|
+
end
|
data/lib/local_port.rb
CHANGED
@@ -1,24 +1,17 @@
|
|
1
1
|
require 'socket'
|
2
|
-
require 'timeout'
|
3
2
|
|
4
3
|
module LocalPort
|
5
|
-
VERSION = '
|
4
|
+
VERSION = '1.0.0'
|
6
5
|
|
7
6
|
def self.free?(port, seconds=1)
|
8
|
-
|
9
|
-
begin
|
10
|
-
TCPSocket.new("127.0.0.1", port).close
|
11
|
-
true
|
12
|
-
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
|
13
|
-
false
|
14
|
-
end
|
15
|
-
end
|
16
|
-
rescue Timeout::Error
|
7
|
+
Socket.tcp("127.0.0.1", port, connect_timeout: seconds)
|
17
8
|
false
|
9
|
+
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
|
10
|
+
true
|
18
11
|
end
|
19
12
|
|
20
13
|
def self.next_free_one(port)
|
21
|
-
port += 1
|
14
|
+
port += 1 until free?(port)
|
22
15
|
port
|
23
16
|
end
|
24
17
|
end
|
data/local_port.gemspec
CHANGED
@@ -6,10 +6,10 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.name = "local_port"
|
7
7
|
gem.version = LocalPort::VERSION
|
8
8
|
gem.summary = %q{Find out which local ports are usable.}
|
9
|
-
gem.description = %q{
|
9
|
+
gem.description = %q{Find out which ports on your system are free to use.}
|
10
10
|
gem.license = "MIT"
|
11
11
|
gem.authors = ["Jan Lelis"]
|
12
|
-
gem.email = "
|
12
|
+
gem.email = ["hi@ruby.consulting"]
|
13
13
|
gem.homepage = "https://rubygems.org/gems/local_port"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
@@ -17,9 +17,5 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ['lib']
|
19
19
|
|
20
|
-
gem.add_development_dependency '
|
21
|
-
gem.add_development_dependency 'rake', '~> 0.8'
|
22
|
-
gem.add_development_dependency 'rdoc', '~> 3.0'
|
23
|
-
gem.add_development_dependency 'rspec', '~> 2.4'
|
24
|
-
gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
|
20
|
+
gem.add_development_dependency 'rake', '~> 13.0'
|
25
21
|
end
|
metadata
CHANGED
@@ -1,104 +1,44 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: local_port
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Lelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rake
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
|
-
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.8'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ~>
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0.8'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rdoc
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ~>
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ~>
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '2.4'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '2.4'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rubygems-tasks
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ~>
|
17
|
+
- - "~>"
|
74
18
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0
|
19
|
+
version: '13.0'
|
76
20
|
type: :development
|
77
21
|
prerelease: false
|
78
22
|
version_requirements: !ruby/object:Gem::Requirement
|
79
23
|
requirements:
|
80
|
-
- - ~>
|
24
|
+
- - "~>"
|
81
25
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0
|
83
|
-
description:
|
84
|
-
email:
|
26
|
+
version: '13.0'
|
27
|
+
description: Find out which ports on your system are free to use.
|
28
|
+
email:
|
29
|
+
- hi@ruby.consulting
|
85
30
|
executables: []
|
86
31
|
extensions: []
|
87
32
|
extra_rdoc_files: []
|
88
33
|
files:
|
89
|
-
- .
|
90
|
-
- .
|
91
|
-
- .rspec
|
92
|
-
- ChangeLog.rdoc
|
34
|
+
- ".gitignore"
|
35
|
+
- ChangeLog.md
|
93
36
|
- Gemfile
|
94
37
|
- LICENSE.txt
|
95
|
-
- README.
|
38
|
+
- README.md
|
96
39
|
- Rakefile
|
97
40
|
- lib/local_port.rb
|
98
|
-
- lib/local_port/version.rb
|
99
41
|
- local_port.gemspec
|
100
|
-
- spec/local_port_spec.rb
|
101
|
-
- spec/spec_helper.rb
|
102
42
|
homepage: https://rubygems.org/gems/local_port
|
103
43
|
licenses:
|
104
44
|
- MIT
|
@@ -109,20 +49,17 @@ require_paths:
|
|
109
49
|
- lib
|
110
50
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
51
|
requirements:
|
112
|
-
- -
|
52
|
+
- - ">="
|
113
53
|
- !ruby/object:Gem::Version
|
114
54
|
version: '0'
|
115
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
56
|
requirements:
|
117
|
-
- -
|
57
|
+
- - ">="
|
118
58
|
- !ruby/object:Gem::Version
|
119
59
|
version: '0'
|
120
60
|
requirements: []
|
121
|
-
|
122
|
-
rubygems_version: 2.0.3
|
61
|
+
rubygems_version: 3.2.22
|
123
62
|
signing_key:
|
124
63
|
specification_version: 4
|
125
64
|
summary: Find out which local ports are usable.
|
126
|
-
test_files:
|
127
|
-
- spec/local_port_spec.rb
|
128
|
-
- spec/spec_helper.rb
|
65
|
+
test_files: []
|
data/.document
DELETED
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--colour --format documentation
|
data/ChangeLog.rdoc
DELETED
data/lib/local_port/version.rb
DELETED
data/spec/local_port_spec.rb
DELETED
data/spec/spec_helper.rb
DELETED