kdwatch 0.5.0 → 0.5.3

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: 2e2ba541b81a0758e14930c2daeeb13f8795ef86f13db41d2099ba2c863ae6a8
4
- data.tar.gz: 225edec007a3005fb9e401888073d3e74fd6d92db622560685d812d0a37527ea
3
+ metadata.gz: 974abb5a5f84e7afb0d7bde78c81a8072b9627a90e1aa25bb26811ba02605c56
4
+ data.tar.gz: e4777968c970488118701adf24fd6c86efce9ae8d08ee4f999ddf2cf851e05d0
5
5
  SHA512:
6
- metadata.gz: 7f61fd99900cb3e4b1951863424816438e7e426b84c3cc0e4854f4a64954f26e2ec56f13b08394d4c086fe2d9b919cd4fa66ed4486ef10daebace7d30767c0b1
7
- data.tar.gz: 4c0853a737166b50b728d6ecbd29845c908fa5e1fcc4b07ea88bbd762c3b6f71b281a7429acbc07f452e3a1a6e9e18f29d7198b97e6d96edef98bbdaef8aa6ad
6
+ metadata.gz: c62d74513d5fdc91cd5736c2c0410f2d985d64bd4784680f387fae825ba33ab08770eef3930ceb9da21c092d2670083b372c356ac0e1940202f14376d598a99b
7
+ data.tar.gz: f5e5a995913f7b7bdd5ab264045062452ceaea3840cc7c3ff47780fd11b648c2f203f0a850c29896871874f4ccdeb514439c5ae73c1423f5ad951a061bfbcfa3
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 Carsten Bormann
3
+ Copyright (c) 2021, 2022 Carsten Bormann
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
@@ -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
  ```
@@ -118,6 +121,35 @@ another laptop), and save some screen real-estate on your laptop.
118
121
  With a globally routable address, kdwatch even can be used for joint
119
122
  viewing in a team.
120
123
 
124
+ ### Finding and accessing kdwatch servers
125
+
126
+ The `kds` tool can list active local (127.0.0.1) kdwatch servers and
127
+ optionally quickly open the page for a selected kdwatch server.
128
+
129
+ ```
130
+ Usage: kds [options] [match...]
131
+ Version: n.m.l (from kdwatch)
132
+ -v, --version Show version and exit
133
+ -h, --help Show option summary and exit
134
+ -f, --from=NUM Search from port number (7991)
135
+ -t, --to=NUM Search to port number (7999)
136
+ ```
137
+
138
+ ```
139
+ $ kds
140
+ http://127.0.0.1:7991 Packed CBOR
141
+ http://127.0.0.1:7992 Concise Problem Details For CoAP APIs
142
+ $ kds prob
143
+ http://127.0.0.1:7991 Packed CBOR
144
+ http://127.0.0.1:7992 Concise Problem Details For CoAP APIs
145
+ (...web page http://127.0.0.1:7992 opens...)
146
+ $
147
+ ```
148
+
149
+ Any match arguments are concatenated with spaces; for servers that
150
+ offer a page with the match string in the title (case insensitive), a
151
+ window is opened in the default browser.
152
+
121
153
  ## Feedback, please
122
154
 
123
155
  This has only been tested on macOS and briefly on Linux. No idea about WSL.
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 (#{loport})") do |v|
27
+ loport = v
28
+ end
29
+ opts.on("-tNUM", "--to=NUM", Integer, "Search to port number (#{hiport})") 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/bin/kdwatch CHANGED
@@ -13,6 +13,7 @@ require_relative "../lib/kdwatch/version"
13
13
  KDWATCH_PORT = 7991 # currently unregistered...
14
14
 
15
15
  def socket_is_free(host, port, uri)
16
+ host = "localhost" if host == "::"
16
17
  begin
17
18
  TCPSocket.new(host, port, connect_timeout: 1)
18
19
  rescue Errno::ECONNREFUSED => e
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.3"
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.3
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-07-07 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