kdwatch 0.5.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e2ba541b81a0758e14930c2daeeb13f8795ef86f13db41d2099ba2c863ae6a8
4
- data.tar.gz: 225edec007a3005fb9e401888073d3e74fd6d92db622560685d812d0a37527ea
3
+ metadata.gz: ec097b76b694691e1a066ec87c23ebe004f085940b5ce222e1ec8b383f7cbbd8
4
+ data.tar.gz: 3f3b1dff065d860cc01a8a7e6598013faa679aeb9c0206dffd17a0dd85b9a6c8
5
5
  SHA512:
6
- metadata.gz: 7f61fd99900cb3e4b1951863424816438e7e426b84c3cc0e4854f4a64954f26e2ec56f13b08394d4c086fe2d9b919cd4fa66ed4486ef10daebace7d30767c0b1
7
- data.tar.gz: 4c0853a737166b50b728d6ecbd29845c908fa5e1fcc4b07ea88bbd762c3b6f71b281a7429acbc07f452e3a1a6e9e18f29d7198b97e6d96edef98bbdaef8aa6ad
6
+ metadata.gz: f105edcc85863d728f629c9b49fae44343b67e7f98af8943a1f22202b0f7ff4f88ad347a9a69b77672539dad159ab2ba0c51f08877a1a18e429794c365b764b7
7
+ data.tar.gz: 17801699b473113c2b66b8aedf3ac5c15ee124d05a460a25b9023409130aed0c703dac48c831404f410eb53d9be148e64d4ca8566d52e2ddad716d8e6bc06e79
data/README.md CHANGED
@@ -51,9 +51,11 @@ There can only be one kdwatch active on each host and port. You will
51
51
  need to specify a different port (or host!) to run more than one
52
52
  kdwatch at the same time.
53
53
 
54
- * `-p port` to select a port number (default: 7991)
55
- * `-1` to `6` as a shortcut for `-p 7991` (default) to `-p 7996` (must be last
54
+ * `-p port` to select a specific port number
55
+ * `-1` to `6` as a shortcut for `-p 7991` to `-p 7996` (must be last
56
56
  option because of an idiosyncrasy of the optionparser library)
57
+ * if no port number is given, `kdwatch` will hunt for a port number
58
+ that doesn't have a listener, starting with 7991.
57
59
 
58
60
  kdwatch has two flags to simplify handling servers that might be
59
61
  accumulating on one host/port:
@@ -64,18 +66,19 @@ accumulating on one host/port:
64
66
  So the most likely use is going to be:
65
67
 
66
68
  ```
67
- kdwatch -r
69
+ kdwatch
68
70
  ```
69
71
 
70
- or maybe
72
+ to start a new server on a new port number.
73
+
74
+ These tend to accumulate a bit, so sometimes you'll want to replace an
75
+ existing one (here: port number 7992):
71
76
 
72
77
  ```
73
78
  kdwatch -r2
74
79
  ```
75
80
 
76
- for the second draft you are editing at the same time,
77
-
78
- or, if your drafts are weirdly named or you need to select one out of
81
+ If your drafts are weirdly named or you need to select one out of
79
82
  many
80
83
 
81
84
  ```
data/bin/kds ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env ruby
2
+ require 'socket'
3
+ require 'uri'
4
+ require 'open-uri'
5
+ require 'optparse'
6
+
7
+ KDWATCH_VERSION=Gem.loaded_specs["kdwatch"].version rescue "unknown-version"
8
+
9
+ loport = 7991
10
+ hiport = 7999
11
+ match = nil
12
+
13
+ op = OptionParser.new do |opts|
14
+ opts.banner = <<BANNER
15
+ Usage: kds [options] [match...]
16
+ Version: #{KDWATCH_VERSION} (from kdwatch)
17
+ BANNER
18
+ opts.on("-v", "--version", "Show version and exit") do |v|
19
+ puts "kds, from kdwatch #{KDWATCH_VERSION}"
20
+ exit
21
+ end
22
+ opts.on("-h", "--help", "Show option summary and exit") do |v|
23
+ puts opts
24
+ exit
25
+ end
26
+ opts.on("-fNUM", "--from=NUM", Integer, "Search from port number") do |v|
27
+ loport = v
28
+ end
29
+ opts.on("-tNUM", "--to=NUM", Integer, "Search to port number") do |v|
30
+ hiport = v
31
+ end
32
+ end
33
+ op.parse!
34
+
35
+ if ARGV.size != 0
36
+ match = ARGV.join(" ")
37
+ end
38
+
39
+ (loport..hiport).each do |p|
40
+ url = "http://127.0.0.1:#{p}"
41
+ URI(url).open do |f|
42
+ s = f.readpartial(40000)
43
+ sc = s.scan(/id="title".*?<|Internal server error/)
44
+ sc.each do |scl|
45
+ scl.sub!(/id="title">/, "")
46
+ scl.chomp!('<')
47
+ puts "#{url} #{scl}"
48
+ if match && scl.downcase.include?(match.downcase)
49
+ spawn("open #{url} || xdg-open #{url} || echo @@@ Please open #{url}")
50
+ end
51
+ break
52
+ end
53
+ end rescue nil
54
+ end
data/kdwatch.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
24
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
25
  end
26
- spec.executables = ['kdwatch']
26
+ spec.executables = ['kdwatch', 'kds']
27
27
  spec.require_paths = ["lib"]
28
28
 
29
29
  spec.add_dependency "bundler", '~> 2.2'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kdwatch
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  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.0
4
+ version: 0.5.1
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-05-29 00:00:00.000000000 Z
11
+ date: 2022-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,6 +127,7 @@ email:
127
127
  - cabo@tzi.org
128
128
  executables:
129
129
  - kdwatch
130
+ - kds
130
131
  extensions: []
131
132
  extra_rdoc_files: []
132
133
  files:
@@ -134,6 +135,7 @@ files:
134
135
  - Gemfile
135
136
  - LICENSE.txt
136
137
  - README.md
138
+ - bin/kds
137
139
  - bin/kdwatch
138
140
  - kdwatch.gemspec
139
141
  - lib/kdwatch-app.rb