percy-common 1.4.0 → 1.4.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/lib/percy/common/version.rb +1 -1
- data/lib/percy/network_helpers.rb +20 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 711a2ac9579789989cc96bb04e0f0b3b4449be39
|
4
|
+
data.tar.gz: 53358f2998aaaba1f64178c2bf948792656791c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 001cb2a5c604a329b26ecbe8b80d78e6a773dc40ab4a0df2baac28c0820938d32eb32bd86ec2d03f3b838cfaad3e3f4e2f316c3a52d7da1696e3ab025dc19981
|
7
|
+
data.tar.gz: b77f16727712ee9c572478917d4b09f6f2e2a62c60f25189c0efba0f62446097f7c74e5d6ed2a4a04531e1efeed39730f6ecee6e6625920ac2803f0d0c178402
|
data/lib/percy/common/version.rb
CHANGED
@@ -3,14 +3,29 @@ require 'excon'
|
|
3
3
|
|
4
4
|
module Percy
|
5
5
|
class NetworkHelpers
|
6
|
+
MIN_PORT = 1_024 # 0-1023 are not available without privilege
|
7
|
+
MAX_PORT = 65_535 # (2^16) -1
|
8
|
+
MAX_PORT_ATTEMPTS = 50
|
9
|
+
|
6
10
|
class ServerDown < RuntimeError; end
|
11
|
+
class OpenPortNotFound < RuntimeError; end
|
7
12
|
|
8
13
|
def self.random_open_port
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
+
MAX_PORT_ATTEMPTS.times do
|
15
|
+
port = rand(MIN_PORT..MAX_PORT)
|
16
|
+
return port if port_open? port
|
17
|
+
end
|
18
|
+
|
19
|
+
raise OpenPortNotFound
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.port_open?(port)
|
23
|
+
begin
|
24
|
+
TCPServer.new(port).close
|
25
|
+
true
|
26
|
+
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::EADDRINUSE
|
27
|
+
false
|
28
|
+
end
|
14
29
|
end
|
15
30
|
|
16
31
|
def self.verify_healthcheck(url:, expected_body: 'ok', retry_wait_seconds: 0.5)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: percy-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Perceptual Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dogstatsd-ruby
|
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
166
|
version: '0'
|
167
167
|
requirements: []
|
168
168
|
rubyforge_project:
|
169
|
-
rubygems_version: 2.
|
169
|
+
rubygems_version: 2.6.13
|
170
170
|
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: Server-side common library for Percy.
|