random-port 0.6.0 → 0.7.1

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
  SHA256:
3
- metadata.gz: ac043d33cc466631184efebe238cac398d491f15191cf9d9079ae8608c33f278
4
- data.tar.gz: 3813ccfe1a6a03f5a2492b68fde9f2108a44c9c72dffb7d98472f21198e31ba8
3
+ metadata.gz: 32d50b829c0ddc8747b50eaf9f25bcb4bcbf4d42858e4271ece9b92ac650a6e9
4
+ data.tar.gz: 034eeff20d6f3d8015fca8d4dada4002c9afeefbb49c8f0a94eaf9db45049562
5
5
  SHA512:
6
- metadata.gz: 720f803ac3d1913208418a00c53bfb53b17b6c391b8f567dca601c66424e035b53d994607d40c9f166bc660ff5e3cda4a9000f057fea5d3a8cd24c1b69732086
7
- data.tar.gz: 677c5930e62518598d7a626cb3d246ca4e7264fb237d2cd010f7f0c64fc291d294354ceaa7b7363caf1fe32a4aae70dcdfc4363a69788b5525eb00adcc444c04
6
+ metadata.gz: 74b9f7720d63cb7c30bcc0fb3e14a82832a2de8a36eb8e7025261d0b7073d75ea73fd9d7d4a58be5afb350e616bf0a95954cd4e798d1482f6844a87ac537fe9c
7
+ data.tar.gz: e0532ba0cc8d19fa521f236c1a7ca6d265a603b6207880217b4101c3466f625e1b03029983967c4956a7f163ced06e70c31670665d9224bf7f4c278253a267ad
data/.0pdd.yml CHANGED
@@ -1,3 +1,23 @@
1
+ # Copyright (c) 2018-2024 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+ ---
1
21
  errors:
2
22
  - yegor256@gmail.com
3
23
  # alerts:
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2018-2024 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+ ---
21
+ name: actionlint
22
+ 'on':
23
+ push:
24
+ branches:
25
+ - master
26
+ pull_request:
27
+ branches:
28
+ - master
29
+ jobs:
30
+ actionlint:
31
+ runs-on: ubuntu-22.04
32
+ steps:
33
+ - uses: actions/checkout@v4
34
+ - name: Download actionlint
35
+ id: get_actionlint
36
+ # yamllint disable-line rule:line-length
37
+ run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
38
+ shell: bash
39
+ - name: Check workflow files
40
+ run: ${{ steps.get_actionlint.outputs.executable }} -color
41
+ shell: bash
@@ -1,3 +1,22 @@
1
+ # Copyright (c) 2018-2024 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
1
20
  ---
2
21
  name: codecov
3
22
  on:
@@ -6,15 +25,14 @@ on:
6
25
  - master
7
26
  jobs:
8
27
  codecov:
9
- runs-on: ubuntu-20.04
28
+ runs-on: ubuntu-22.04
10
29
  steps:
11
- - uses: actions/checkout@v3
30
+ - uses: actions/checkout@v4
12
31
  - uses: ruby/setup-ruby@v1
13
32
  with:
14
33
  ruby-version: 2.7
15
34
  - run: bundle update
16
35
  - run: bundle exec rake
17
- - uses: codecov/codecov-action@v3
36
+ - uses: codecov/codecov-action@v4
18
37
  with:
19
- file: coverage/.resultset.json
20
- fail_ci_if_error: true
38
+ token: ${{ secrets.CODECOV_TOKEN }}
@@ -0,0 +1,30 @@
1
+ # Copyright (c) 2018-2024 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+ ---
21
+ name: copyrights
22
+ 'on':
23
+ push:
24
+ pull_request:
25
+ jobs:
26
+ copyrights:
27
+ runs-on: ubuntu-22.04
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+ - uses: yegor256/copyrights-action@0.0.4
@@ -0,0 +1,38 @@
1
+ # Copyright (c) 2018-2024 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+ ---
21
+ name: markdown-lint
22
+ 'on':
23
+ push:
24
+ branches:
25
+ - master
26
+ pull_request:
27
+ branches:
28
+ - master
29
+ paths-ignore: ['paper/**', 'sandbox/**']
30
+ concurrency:
31
+ group: markdown-lint-${{ github.ref }}
32
+ cancel-in-progress: true
33
+ jobs:
34
+ markdown-lint:
35
+ runs-on: ubuntu-22.04
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+ - uses: articulate/actions-markdownlint@v1
@@ -1,11 +1,34 @@
1
+ # Copyright (c) 2018-2024 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
1
20
  ---
2
21
  name: pdd
3
22
  on:
4
23
  push:
24
+ branches:
25
+ - master
5
26
  pull_request:
27
+ branches:
28
+ - master
6
29
  jobs:
7
30
  pdd:
8
- runs-on: ubuntu-20.04
31
+ runs-on: ubuntu-22.04
9
32
  steps:
10
- - uses: actions/checkout@v3
11
- - uses: g4s8/pdd-action@master
33
+ - uses: actions/checkout@v4
34
+ - uses: volodya-lombrozo/pdd-action@master
@@ -1,3 +1,22 @@
1
+ # Copyright (c) 2018-2024 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
1
20
  ---
2
21
  name: rake
3
22
  on:
@@ -16,7 +35,7 @@ jobs:
16
35
  ruby: [2.7, 3.2]
17
36
  runs-on: ${{ matrix.os }}
18
37
  steps:
19
- - uses: actions/checkout@v3
38
+ - uses: actions/checkout@v4
20
39
  - uses: ruby/setup-ruby@v1
21
40
  with:
22
41
  ruby-version: ${{ matrix.ruby }}
@@ -1,3 +1,22 @@
1
+ # Copyright (c) 2018-2024 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
1
20
  ---
2
21
  name: xcop
3
22
  on:
@@ -5,7 +24,7 @@ on:
5
24
  pull_request:
6
25
  jobs:
7
26
  xcop:
8
- runs-on: ubuntu-20.04
27
+ runs-on: ubuntu-22.04
9
28
  steps:
10
- - uses: actions/checkout@v3
29
+ - uses: actions/checkout@v4
11
30
  - uses: g4s8/xcop-action@master
data/.gitignore CHANGED
@@ -4,3 +4,5 @@ Gemfile.lock
4
4
  .DS_Store
5
5
  rdoc/
6
6
  coverage/
7
+ .yardoc/
8
+ doc/
data/.rubocop.yml CHANGED
@@ -1,3 +1,23 @@
1
+ # Copyright (c) 2018-2024 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+ ---
1
21
  AllCops:
2
22
  DisplayCopNames: true
3
23
  TargetRubyVersion: 2.3.3
data/.rultor.yml CHANGED
@@ -1,5 +1,25 @@
1
+ # Copyright (c) 2018-2024 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+ ---
1
21
  docker:
2
- image: yegor256/rultor-image:1.19.0
22
+ image: yegor256/rultor-image:1.23.1
3
23
  assets:
4
24
  rubygems.yml: yegor256/home#assets/rubygems.yml
5
25
  install: |-
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018 Yegor Bugayenko
3
+ # Copyright (c) 2018-2024 Yegor Bugayenko
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -23,10 +23,10 @@
23
23
  source 'https://rubygems.org'
24
24
  gemspec
25
25
 
26
- gem 'minitest', '5.18.0', require: false
27
- gem 'rake', '13.0.6', require: false
28
- gem 'rdoc', '6.5.0', require: false
29
- gem 'rubocop', '1.51.0', require: false
30
- gem 'rubocop-rspec', '2.22.0', require: false
26
+ gem 'minitest', '5.24.1', require: false
27
+ gem 'rake', '13.2.1', require: false
28
+ gem 'rubocop', '1.65.0', require: false
29
+ gem 'rubocop-rspec', '3.0.3', require: false
31
30
  gem 'simplecov', '0.22.0', require: false
32
- gem 'threads', '0.3.0', require: false
31
+ gem 'threads', '0.4.0', require: false
32
+ gem 'yard', '0.9.36', require: false
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2019 Yegor Bugayenko
3
+ Copyright (c) 2018-2024 Yegor Bugayenko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the 'Software'), to deal
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ # Random TCP Port Generator for Ruby
2
+
1
3
  [![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/random-port)](http://www.rultor.com/p/yegor256/random-port)
2
4
  [![We recommend RubyMine](http://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
3
5
 
@@ -14,7 +16,7 @@ It's a simple Ruby gem to get a random TCP port.
14
16
  First, install it:
15
17
 
16
18
  ```bash
17
- $ gem install random-port
19
+ gem install random-port
18
20
  ```
19
21
 
20
22
  Then, use it like this, to reserve a random TCP port:
@@ -56,14 +58,16 @@ not-thread-safe, using optional `sync` argument of the constructor.
56
58
 
57
59
  ## How to contribute
58
60
 
59
- Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
61
+ Read
62
+ [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
60
63
  Make sure you build is green before you contribute
61
- your pull request. You will need to have [Ruby](https://www.ruby-lang.org/en/) 2.3+ and
64
+ your pull request. You will need to have
65
+ [Ruby](https://www.ruby-lang.org/en/) 2.3+ and
62
66
  [Bundler](https://bundler.io/) installed. Then:
63
67
 
64
- ```
65
- $ bundle update
66
- $ bundle exec rake
68
+ ```bash
69
+ bundle update
70
+ bundle exec rake
67
71
  ```
68
72
 
69
73
  If it's clean and you don't see any error messages, submit your pull request.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018 Yegor Bugayenko
3
+ # Copyright (c) 2018-2024 Yegor Bugayenko
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -34,7 +34,7 @@ def version
34
34
  Gem::Specification.load(Dir['*.gemspec'].first).version
35
35
  end
36
36
 
37
- task default: %i[clean test rubocop]
37
+ task default: %i[clean test yard rubocop]
38
38
 
39
39
  require 'rake/testtask'
40
40
  desc 'Run all unit tests'
@@ -50,3 +50,9 @@ RuboCop::RakeTask.new(:rubocop) do |task|
50
50
  task.fail_on_error = true
51
51
  task.requires << 'rubocop-rspec'
52
52
  end
53
+
54
+ require 'yard'
55
+ desc 'Build Yard documentation'
56
+ YARD::Rake::YardocTask.new do |t|
57
+ t.files = ['lib/**/*.rb']
58
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # (The MIT License)
4
4
  #
5
- # Copyright (c) 2018 Yegor Bugayenko
5
+ # Copyright (c) 2018-2024 Yegor Bugayenko
6
6
  #
7
7
  # Permission is hereby granted, free of charge, to any person obtaining a copy
8
8
  # of this software and associated documentation files (the 'Software'), to deal
@@ -25,7 +25,7 @@
25
25
  # The module for all classes.
26
26
  #
27
27
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
- # Copyright:: Copyright (c) 2018 Yegor Bugayenko
28
+ # Copyright:: Copyright (c) 2018-2024 Yegor Bugayenko
29
29
  # License:: MIT
30
30
  module RandomPort
31
31
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # (The MIT License)
4
4
  #
5
- # Copyright (c) 2018 Yegor Bugayenko
5
+ # Copyright (c) 2018-2024 Yegor Bugayenko
6
6
  #
7
7
  # Permission is hereby granted, free of charge, to any person obtaining a copy
8
8
  # of this software and associated documentation files (the 'Software'), to deal
@@ -43,7 +43,7 @@ require_relative 'module'
43
43
  # passing <tt>FALSE</tt>.
44
44
  #
45
45
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
46
- # Copyright:: Copyright (c) 2018 Yegor Bugayenko
46
+ # Copyright:: Copyright (c) 2018-2024 Yegor Bugayenko
47
47
  # License:: MIT
48
48
  class RandomPort::Pool
49
49
  # If can't acquire by time out.
@@ -52,13 +52,14 @@ class RandomPort::Pool
52
52
  attr_reader :limit
53
53
 
54
54
  # Ctor.
55
- # @param [bool] Set it to FALSE if you want this pool to be NOT thread-safe
56
- # @param [int] Set the maximum number of ports in the pool
55
+ # @param [Boolean] sync Set it to FALSE if you want this pool to be NOT thread-safe
56
+ # @param [Integer] limit Set the maximum number of ports in the pool
57
57
  def initialize(sync: true, limit: 65_536)
58
58
  @ports = []
59
59
  @sync = sync
60
60
  @monitor = Monitor.new
61
61
  @limit = limit
62
+ @next = 0
62
63
  end
63
64
 
64
65
  # Application wide pool of ports
@@ -86,15 +87,17 @@ class RandomPort::Pool
86
87
  start = Time.now
87
88
  loop do
88
89
  if Time.now > start + timeout
89
- raise Timeout, "Can't find a place in the pool of #{@limit} ports \
90
- for #{total} port(s), in #{format('%.02f', Time.now - start)}s"
90
+ raise \
91
+ Timeout,
92
+ "Can't find a place in the pool of #{@limit} ports " \
93
+ "for #{total} port(s), in #{format('%.02f', Time.now - start)}s"
91
94
  end
92
95
  opts = safe do
93
96
  next if @ports.count + total > @limit
94
97
  opts = Array.new(0, total)
95
98
  begin
96
99
  (0..(total - 1)).each do |i|
97
- opts[i] = i.zero? ? take : take(opts[i - 1] + 1)
100
+ opts[i] = take(i.zero? ? @next : opts[i - 1] + 1)
98
101
  end
99
102
  rescue Errno::EADDRINUSE, SocketError
100
103
  next
@@ -106,6 +109,8 @@ for #{total} port(s), in #{format('%.02f', Time.now - start)}s"
106
109
  opts
107
110
  end
108
111
  next if opts.nil?
112
+ @next = opts.max + 1
113
+ @next = 0 if @next > 65_535
109
114
  opts = opts[0] if total == 1
110
115
  return opts unless block_given?
111
116
  begin
@@ -129,6 +134,9 @@ for #{total} port(s), in #{format('%.02f', Time.now - start)}s"
129
134
 
130
135
  private
131
136
 
137
+ # Find one possible TCP port.
138
+ # @param [Integer] opt Suggested port number
139
+ # @return [Integer] Port found
132
140
  def take(opt = 0)
133
141
  server = TCPServer.new('127.0.0.1', opt)
134
142
  p = server.addr[1]
data/lib/random-port.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # (The MIT License)
4
4
  #
5
- # Copyright (c) 2018 Yegor Bugayenko
5
+ # Copyright (c) 2018-2024 Yegor Bugayenko
6
6
  #
7
7
  # Permission is hereby granted, free of charge, to any person obtaining a copy
8
8
  # of this software and associated documentation files (the 'Software'), to deal
data/random-port.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # (The MIT License)
4
4
  #
5
- # Copyright (c) 2018 Yegor Bugayenko
5
+ # Copyright (c) 2018-2024 Yegor Bugayenko
6
6
  #
7
7
  # Permission is hereby granted, free of charge, to any person obtaining a copy
8
8
  # of this software and associated documentation files (the 'Software'), to deal
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
28
28
  s.required_ruby_version = '>=2.3'
29
29
  s.name = 'random-port'
30
- s.version = '0.6.0'
30
+ s.version = '0.7.1'
31
31
  s.license = 'MIT'
32
32
  s.summary = 'Random TCP port'
33
33
  s.description = 'Reserves a random TCP port'
data/renovate.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "config:recommended"
5
+ ]
6
+ }
data/test/test__helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2019 Yegor Bugayenko
3
+ # Copyright (c) 2018-2024 Yegor Bugayenko
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
data/test/test_pool.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # (The MIT License)
4
4
  #
5
- # Copyright (c) 2018 Yegor Bugayenko
5
+ # Copyright (c) 2018-2024 Yegor Bugayenko
6
6
  #
7
7
  # Permission is hereby granted, free of charge, to any person obtaining a copy
8
8
  # of this software and associated documentation files (the 'Software'), to deal
@@ -24,17 +24,18 @@
24
24
 
25
25
  require 'minitest/autorun'
26
26
  require 'threads'
27
+ require 'socket'
27
28
  require_relative '../lib/random-port/pool'
28
29
 
29
30
  # Pool test.
30
31
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
31
- # Copyright:: Copyright (c) 2018 Yegor Bugayenko
32
+ # Copyright:: Copyright (c) 2018-2024 Yegor Bugayenko
32
33
  # License:: MIT
33
34
  class RandomPort::TestPool < Minitest::Test
34
35
  def test_acquires_and_releases
35
36
  pool = RandomPort::Pool.new
36
37
  port = pool.acquire
37
- server = TCPServer.new(port)
38
+ server = TCPServer.new('localhost', port)
38
39
  server.close
39
40
  assert(!port.nil?)
40
41
  assert(port.positive?)
@@ -46,7 +47,7 @@ class RandomPort::TestPool < Minitest::Test
46
47
  assert_equal(0, pool.size)
47
48
  ports = pool.acquire(3, timeout: 16)
48
49
  ports.each do |p|
49
- server = TCPServer.new(p)
50
+ server = TCPServer.new('localhost', p)
50
51
  server.close
51
52
  end
52
53
  assert_equal(3, pool.size)
@@ -63,7 +64,7 @@ class RandomPort::TestPool < Minitest::Test
63
64
  assert_equal(3, ports.count)
64
65
  assert_equal(3, pool.size)
65
66
  ports.each do |p|
66
- server = TCPServer.new(p)
67
+ server = TCPServer.new('localhost', p)
67
68
  server.close
68
69
  end
69
70
  end
@@ -84,7 +85,7 @@ class RandomPort::TestPool < Minitest::Test
84
85
  Threads.new(100).assert do
85
86
  pool.acquire(5) do |ports|
86
87
  ports.each do |p|
87
- server = TCPServer.new(p)
88
+ server = TCPServer.new('localhost', p)
88
89
  server.close
89
90
  end
90
91
  end
@@ -114,6 +115,16 @@ class RandomPort::TestPool < Minitest::Test
114
115
  assert_equal(total, numbers.uniq.count)
115
116
  end
116
117
 
118
+ def test_acquires_unique_numbers_in_block
119
+ total = 25
120
+ numbers = (0..total - 1).map do
121
+ RandomPort::Pool::SINGLETON.acquire do |port|
122
+ port
123
+ end
124
+ end
125
+ assert_equal(total, numbers.uniq.count)
126
+ end
127
+
117
128
  def test_raises_when_too_many
118
129
  pool = RandomPort::Pool.new(limit: 1)
119
130
  pool.acquire
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: random-port
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-26 00:00:00.000000000 Z
11
+ date: 2024-07-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Reserves a random TCP port
14
14
  email: yegor256@gmail.com
@@ -18,7 +18,10 @@ extra_rdoc_files:
18
18
  - README.md
19
19
  files:
20
20
  - ".0pdd.yml"
21
+ - ".github/workflows/actionlint.yml"
21
22
  - ".github/workflows/codecov.yml"
23
+ - ".github/workflows/copyrights.yml"
24
+ - ".github/workflows/markdown-lint.yml"
22
25
  - ".github/workflows/pdd.yml"
23
26
  - ".github/workflows/rake.yml"
24
27
  - ".github/workflows/xcop.yml"
@@ -26,7 +29,6 @@ files:
26
29
  - ".pdd"
27
30
  - ".rubocop.yml"
28
31
  - ".rultor.yml"
29
- - ".travis.yml"
30
32
  - Gemfile
31
33
  - LICENSE.txt
32
34
  - README.md
@@ -35,6 +37,7 @@ files:
35
37
  - lib/random-port/module.rb
36
38
  - lib/random-port/pool.rb
37
39
  - random-port.gemspec
40
+ - renovate.json
38
41
  - test/test__helper.rb
39
42
  - test/test_pool.rb
40
43
  homepage: http://github.com/yegor256/random-port
@@ -58,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
61
  - !ruby/object:Gem::Version
59
62
  version: '0'
60
63
  requirements: []
61
- rubygems_version: 3.2.15
64
+ rubygems_version: 3.4.10
62
65
  signing_key:
63
66
  specification_version: 4
64
67
  summary: Random TCP port
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.6.0
4
- cache: bundler
5
- branches:
6
- only:
7
- - master
8
- install:
9
- - travis_retry bundle update
10
- script:
11
- - bundle exec rake
12
- after_success:
13
- - "bash <(curl -s https://codecov.io/bash)"