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 CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NjA4M2ZhNzJjZWUzMjk2NjFhNjEwNGQ3NjdjOTUyZmQ3ZWVjMjU1Zg==
5
- data.tar.gz: !binary |-
6
- MzVhNGY2ZTMyZDFkYTExMjA2YjAxMmZmZTIxZTdhN2VlZDgzZGFlMg==
7
- !binary "U0hBNTEy":
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
@@ -1,4 +1,2 @@
1
1
  Gemfile.lock
2
- html/
3
- pkg/
4
- vendor/cache/*.gem
2
+ pkg/
data/ChangeLog.md ADDED
@@ -0,0 +1,10 @@
1
+ # ChangeLog
2
+
3
+ ## 1.0.0 / 2021-10-21
4
+
5
+ - Fix LocalPort#free? - Actually return true for free ports
6
+ - Use socket's timeout instead of timeout stdlib
7
+
8
+ ## 0.1.0 / 2013-08-22
9
+
10
+ - Initial release
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Jan Lelis
1
+ Copyright (c) 2013, 2021 Jan Lelis
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,13 +1,10 @@
1
- = LocalPort
1
+ # LocalPort
2
2
 
3
- * {Homepage}[https://rubygems.org/gems/local_port]
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
- == Copyright
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
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
-
5
- begin
6
- require 'bundler'
7
- rescue LoadError => e
8
- warn e.message
9
- warn "Run `gem install bundler` to install Bundler."
10
- exit -1
11
- end
12
-
13
- begin
14
- Bundler.setup(:development)
15
- rescue Bundler::BundlerError => e
16
- warn e.message
17
- warn "Run `bundle install` to install missing gems."
18
- exit e.status_code
19
- end
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
- require 'rspec/core/rake_task'
33
- RSpec::Core::RakeTask.new
22
+ # # #
23
+ # Start an IRB session with the gem loaded
34
24
 
35
- task :test => :spec
36
- task :default => :spec
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 = '0.1.0'
4
+ VERSION = '1.0.0'
6
5
 
7
6
  def self.free?(port, seconds=1)
8
- Timeout::timeout(seconds) do
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 while free?(port)
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{Gives you tools to find out which ports on your system are free to use}
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 = "mail@janlelis.de"
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 'bundler', '~> 1.0'
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: 0.1.0
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: 2013-08-22 00:00:00.000000000 Z
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.2'
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.2'
83
- description: Gives you tools to find out which ports on your system are free to use
84
- email: mail@janlelis.de
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
- - .document
90
- - .gitignore
91
- - .rspec
92
- - ChangeLog.rdoc
34
+ - ".gitignore"
35
+ - ChangeLog.md
93
36
  - Gemfile
94
37
  - LICENSE.txt
95
- - README.rdoc
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
- rubyforge_project:
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
@@ -1,4 +0,0 @@
1
- lib/**/*.rb
2
- README.rdoc
3
- ChangeLog.rdoc
4
- LICENSE.txt
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --colour --format documentation
data/ChangeLog.rdoc DELETED
@@ -1,4 +0,0 @@
1
- === 0.1.0 / 2013-08-22
2
-
3
- * Initial release:
4
-
@@ -1,4 +0,0 @@
1
- module LocalPort
2
- # local_port version
3
- VERSION = "0.1.0"
4
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
- require 'local_port'
3
-
4
- describe LocalPort do
5
- it "should have a VERSION constant" do
6
- subject.const_get('VERSION').should_not be_empty
7
- end
8
- end
data/spec/spec_helper.rb DELETED
@@ -1,4 +0,0 @@
1
- require 'rspec'
2
- require 'local_port/version'
3
-
4
- include LocalPort