kdwatch 0.5.4 → 0.5.6

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: 1a9da0314481e385e7c7809d744245974f7f03c1ec545d010dccf1e11ad798a1
4
- data.tar.gz: efb937cffffac1f963b2768e712c720a502e6fc596e256c457fa5636de5238fd
3
+ metadata.gz: 6a512a725cd5620b46a4e07dbb7cf04169d33c26d449bee7b12f565bdf17a6c5
4
+ data.tar.gz: e635c44eaa9f4a3413666113ca399020249feb12ae19a63f544f1716ab3c3956
5
5
  SHA512:
6
- metadata.gz: 591eeb97f79a48774586fb4f213aebd00b0e9e2604e4cc2644e30d69a2cca6e1869b58907f68b6098e3db734cb253a01178879b7239229e3fb0d3d361a9137d2
7
- data.tar.gz: 5889974b1b930571d73b96fc1b6f3b423f5a0449859bc14aef429a2c1a05264e4b36a5082ff3b1a8c68fdb1b7fc47b160f1a702fff956e4ee139e666bbb4daec
6
+ metadata.gz: 6695bad925d18d8be9fe52b7f0c32581310a49c3b0f580e569a997d8ffeb2630aadc06549c6b6494aa523516feec0b05b579fa29495fc66f03aaf2346c67e71f
7
+ data.tar.gz: 2d5739a44678c2035798575ac4fca4dfb583594fc8aba94f14fd7cabc4e9cba3eb133ffeb8c869415548b0c0baf28b5edca78ae9854d799b640f80c2580d1aac
data/README.md CHANGED
@@ -85,10 +85,6 @@ many
85
85
  kdwatch -r5 weird-draft.md
86
86
  ```
87
87
 
88
- (Glitches are to be expected if you *start* more than one server out of
89
- the same directory at the same instant; TODO; for now, wait 10 seconds
90
- before starting another from the same directory.)
91
-
92
88
  ### 7991, haven't I heard that number before?
93
89
 
94
90
  The default port number was chosen after [RFC 7991], the initial (no
data/bin/kds CHANGED
@@ -3,12 +3,14 @@ require 'socket'
3
3
  require 'uri'
4
4
  require 'open-uri'
5
5
  require 'optparse'
6
+ require 'optparse/uri'
6
7
 
7
8
  KDWATCH_VERSION=Gem.loaded_specs["kdwatch"].version rescue "unknown-version"
8
9
 
9
10
  loport = 7991
10
11
  hiport = 7999
11
12
  match = nil
13
+ uri = URI.parse("http://127.0.0.1")
12
14
 
13
15
  op = OptionParser.new do |opts|
14
16
  opts.banner = <<BANNER
@@ -23,11 +25,20 @@ BANNER
23
25
  puts opts
24
26
  exit
25
27
  end
28
+ opts.on("-uURI", "--uri=URI", URI, "Use base URI (#{uri})") do |v|
29
+ uri = v
30
+ unless uri.host # questionable convenience feature
31
+ uri.host = uri.path #.sub(/\A([A-Za-z0-9:]+)\z/) {"[#{$1}]"}
32
+ uri.path = ""
33
+ end
34
+ uri.scheme ||= "http"
35
+ end
26
36
  opts.on("-fNUM", "--from=NUM", Integer, "Search from port number (#{loport})") do |v|
27
37
  loport = v
28
38
  end
29
39
  opts.on("-tNUM", "--to=NUM", Integer, "Search to port number (#{hiport})") do |v|
30
40
  hiport = v
41
+ hiport += 8000 if hiport < loport # questionable convenience feature
31
42
  end
32
43
  end
33
44
  op.parse!
@@ -37,7 +48,8 @@ if ARGV.size != 0
37
48
  end
38
49
 
39
50
  (loport..hiport).each do |p|
40
- url = "http://127.0.0.1:#{p}"
51
+ uri.port = p
52
+ url = uri.to_s
41
53
  URI(url).open do |f|
42
54
  s = f.readpartial(40000)
43
55
  sc = s.scan(/id="title".*?<|Internal server error/)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kdwatch
4
- VERSION = "0.5.4"
4
+ VERSION = "0.5.6"
5
5
  end
data/lib/kdwatch-app.rb CHANGED
@@ -71,8 +71,6 @@ end
71
71
  GF
72
72
  guardfile.close
73
73
  gfpath = guardfile.path
74
- # gfpath = "#{path}.guardfile"
75
- # File.rename(path, gfpath)
76
74
 
77
75
  rd, _wr = IO.pipe
78
76
  spawn("guard -G #{gfpath}", in: rd, close_others: true)
@@ -83,6 +81,22 @@ host = "localhost" if host == "::" # work around macOS peculiarity
83
81
  host = "[#{host}]" if host =~ /:/
84
82
 
85
83
  url = "http://#{host}:#{port}"
86
-
87
- spawn("sleep 5; open #{url} || xdg-open #{url} || echo @@@ Please open #{url}")
88
-
84
+ command = "open #{url} || xdg-open #{url} || echo @@@ Please open #{url}"
85
+
86
+ if Process.respond_to?(:fork) && fork do
87
+ begin
88
+ # warn "** Making connection to #{host} #{port}"
89
+ TCPSocket.new host, port
90
+ # warn "** Successful connection to #{host} #{port}"
91
+ rescue => _e
92
+ # warn "** #{e.detailed_message}"
93
+ sleep 0.5
94
+ retry
95
+ end
96
+ exec(command)
97
+ warn "** exec didn't work"
98
+ exit!
99
+ end
100
+ else
101
+ spawn("sleep 3; #{command}")
102
+ end
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.5.4
4
+ version: 0.5.6
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-07-09 00:00:00.000000000 Z
11
+ date: 2023-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  requirements: []
162
- rubygems_version: 3.3.11
162
+ rubygems_version: 3.4.10
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: 'kdwatch: open auto-reloaded HTML for kramdown-rfc in a browser.'