kdwatch 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/kdwatch +34 -2
- data/lib/kdwatch/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e2ba541b81a0758e14930c2daeeb13f8795ef86f13db41d2099ba2c863ae6a8
|
4
|
+
data.tar.gz: 225edec007a3005fb9e401888073d3e74fd6d92db622560685d812d0a37527ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f61fd99900cb3e4b1951863424816438e7e426b84c3cc0e4854f4a64954f26e2ec56f13b08394d4c086fe2d9b919cd4fa66ed4486ef10daebace7d30767c0b1
|
7
|
+
data.tar.gz: 4c0853a737166b50b728d6ecbd29845c908fa5e1fcc4b07ea88bbd762c3b6f71b281a7429acbc07f452e3a1a6e9e18f29d7198b97e6d96edef98bbdaef8aa6ad
|
data/bin/kdwatch
CHANGED
@@ -6,11 +6,24 @@ ENV["KRAMDOWN_PERSISTENT"]="yes"
|
|
6
6
|
|
7
7
|
require 'optparse'
|
8
8
|
require 'ostruct'
|
9
|
+
require 'socket'
|
9
10
|
|
10
11
|
require_relative "../lib/kdwatch/version"
|
11
12
|
|
12
13
|
KDWATCH_PORT = 7991 # currently unregistered...
|
13
14
|
|
15
|
+
def socket_is_free(host, port, uri)
|
16
|
+
begin
|
17
|
+
TCPSocket.new(host, port, connect_timeout: 1)
|
18
|
+
rescue Errno::ECONNREFUSED => e
|
19
|
+
return true
|
20
|
+
rescue => e
|
21
|
+
warn "*** #{uri} -- #{e.inspect}"
|
22
|
+
return nil # break, but don't use
|
23
|
+
end
|
24
|
+
return false
|
25
|
+
end
|
26
|
+
|
14
27
|
options = OpenStruct.new
|
15
28
|
|
16
29
|
op = OptionParser.new do |opts|
|
@@ -30,7 +43,7 @@ BANNER
|
|
30
43
|
opts.on("-r", "--[no-]replace", "Replace existing server")
|
31
44
|
opts.on("-oNAME", "--host=NAME", String, "Server host (127.0.0.1)")
|
32
45
|
opts.on("-i", "--internet", 'Abbr. "on the Internet" (host = "::")')
|
33
|
-
opts.on("-pNUM", "--port=NUM", Integer, "Port number (#{KDWATCH_PORT})")
|
46
|
+
opts.on("-pNUM", "--port=NUM", Integer, "Port number (#{KDWATCH_PORT}...)")
|
34
47
|
opts.on("-[1-6]", "--[1-6]", Integer, "Abbr. port number (#{KDWATCH_PORT/10}x), must be last")
|
35
48
|
end
|
36
49
|
begin
|
@@ -52,7 +65,26 @@ if short_port = options[""]
|
|
52
65
|
warn "** overriding port #{options.port} with #{port}" if options.port
|
53
66
|
options.port = port
|
54
67
|
else
|
55
|
-
options.port
|
68
|
+
unless options.port
|
69
|
+
port = KDWATCH_PORT
|
70
|
+
host = options.host
|
71
|
+
host = "[#{host}]" if host =~ /:/
|
72
|
+
uri = nil
|
73
|
+
found = false
|
74
|
+
100.times do
|
75
|
+
uri = "http://#{host}:#{port}"
|
76
|
+
# warn "Trying URI #{uri}"
|
77
|
+
found = socket_is_free(options.host, port, uri)
|
78
|
+
break unless found == false
|
79
|
+
port += 1
|
80
|
+
end
|
81
|
+
unless found
|
82
|
+
warn "*** Cannot find port number available to serve from!"
|
83
|
+
exit 1
|
84
|
+
end
|
85
|
+
warn "*** Using URI: #{uri}"
|
86
|
+
options.port = port
|
87
|
+
end
|
56
88
|
end
|
57
89
|
|
58
90
|
# p options
|
data/lib/kdwatch/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kdwatch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
- !ruby/object:Gem::Version
|
158
158
|
version: '0'
|
159
159
|
requirements: []
|
160
|
-
rubygems_version: 3.
|
160
|
+
rubygems_version: 3.3.11
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: 'kdwatch: open auto-reloaded HTML for kramdown-rfc in a browser.'
|