kdwatch 0.5.1 → 0.5.4

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: ec097b76b694691e1a066ec87c23ebe004f085940b5ce222e1ec8b383f7cbbd8
4
- data.tar.gz: 3f3b1dff065d860cc01a8a7e6598013faa679aeb9c0206dffd17a0dd85b9a6c8
3
+ metadata.gz: 1a9da0314481e385e7c7809d744245974f7f03c1ec545d010dccf1e11ad798a1
4
+ data.tar.gz: efb937cffffac1f963b2768e712c720a502e6fc596e256c457fa5636de5238fd
5
5
  SHA512:
6
- metadata.gz: f105edcc85863d728f629c9b49fae44343b67e7f98af8943a1f22202b0f7ff4f88ad347a9a69b77672539dad159ab2ba0c51f08877a1a18e429794c365b764b7
7
- data.tar.gz: 17801699b473113c2b66b8aedf3ac5c15ee124d05a460a25b9023409130aed0c703dac48c831404f410eb53d9be148e64d4ca8566d52e2ddad716d8e6bc06e79
6
+ metadata.gz: 591eeb97f79a48774586fb4f213aebd00b0e9e2604e4cc2644e30d69a2cca6e1869b58907f68b6098e3db734cb253a01178879b7239229e3fb0d3d361a9137d2
7
+ data.tar.gz: 5889974b1b930571d73b96fc1b6f3b423f5a0449859bc14aef429a2c1a05264e4b36a5082ff3b1a8c68fdb1b7fc47b160f1a702fff956e4ee139e666bbb4daec
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
@@ -121,6 +121,35 @@ another laptop), and save some screen real-estate on your laptop.
121
121
  With a globally routable address, kdwatch even can be used for joint
122
122
  viewing in a team.
123
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
+
124
153
  ## Feedback, please
125
154
 
126
155
  This has only been tested on macOS and briefly on Linux. No idea about WSL.
data/bin/kds CHANGED
@@ -23,10 +23,10 @@ BANNER
23
23
  puts opts
24
24
  exit
25
25
  end
26
- opts.on("-fNUM", "--from=NUM", Integer, "Search from port number") do |v|
26
+ opts.on("-fNUM", "--from=NUM", Integer, "Search from port number (#{loport})") do |v|
27
27
  loport = v
28
28
  end
29
- opts.on("-tNUM", "--to=NUM", Integer, "Search to port number") do |v|
29
+ opts.on("-tNUM", "--to=NUM", Integer, "Search to port number (#{hiport})") do |v|
30
30
  hiport = v
31
31
  end
32
32
  end
data/bin/kdwatch CHANGED
@@ -7,12 +7,14 @@ ENV["KRAMDOWN_PERSISTENT"]="yes"
7
7
  require 'optparse'
8
8
  require 'ostruct'
9
9
  require 'socket'
10
+ require 'tempfile'
10
11
 
11
12
  require_relative "../lib/kdwatch/version"
12
13
 
13
14
  KDWATCH_PORT = 7991 # currently unregistered...
14
15
 
15
16
  def socket_is_free(host, port, uri)
17
+ host = "localhost" if host == "::"
16
18
  begin
17
19
  TCPSocket.new(host, port, connect_timeout: 1)
18
20
  rescue Errno::ECONNREFUSED => e
@@ -152,11 +154,19 @@ ENV["KDWATCH_PORT"] = options.port.to_s
152
154
  live_reload_port = options.port + 51234 # move up into ephemeral space
153
155
  ENV["KDWATCH_LRPORT"] = live_reload_port.to_s
154
156
 
155
- File.write(".config.ru", <<HERE)
157
+ tf = Tempfile.new('kdwatch-config-ru-')
158
+ path = tf.path
159
+ rupath = "#{path}.ru"
160
+
161
+ tf.write(<<HERE)
156
162
  require 'rack-livereload'
157
163
  use Rack::LiveReload, min_delay: 500, source: :vendored, no_swf: true, port: #{live_reload_port}, live_reload_port: #{live_reload_port}
158
164
  require 'kdwatch-app.rb'
159
165
  run Sinatra::Application
166
+ File.delete("#{rupath}")
160
167
  HERE
161
168
 
162
- exec("rackup -E production -s thin -o #{options.host} -p #{options.port} .config.ru")
169
+ tf.close
170
+ File.rename(path, rupath)
171
+
172
+ exec("rackup -E production -s thin -o #{options.host} -p #{options.port} #{rupath}")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kdwatch
4
- VERSION = "0.5.1"
4
+ VERSION = "0.5.4"
5
5
  end
data/lib/kdwatch-app.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require_relative "kdwatch/version"
2
2
  require 'bundler'
3
+ require 'tempfile'
3
4
 
4
5
  # Bundler.require
5
6
  require "bundler"
@@ -62,14 +63,19 @@ get "/rfc-local.css" do
62
63
  # insert local css here
63
64
  end
64
65
 
65
- File.write(".Guardfile", <<GF)
66
+ guardfile = Tempfile.new("kdwatch-guard-")
67
+ guardfile.write(<<GF)
66
68
  guard :livereload, :port => #{ENV["KDWATCH_LRPORT"]} do
67
69
  watch("#{sfn}")
68
70
  end
69
71
  GF
72
+ guardfile.close
73
+ gfpath = guardfile.path
74
+ # gfpath = "#{path}.guardfile"
75
+ # File.rename(path, gfpath)
70
76
 
71
77
  rd, _wr = IO.pipe
72
- spawn("guard -G .Guardfile", in: rd, close_others: true)
78
+ spawn("guard -G #{gfpath}", in: rd, close_others: true)
73
79
 
74
80
  # wrong: puts settings.port
75
81
 
@@ -80,4 +86,3 @@ url = "http://#{host}:#{port}"
80
86
 
81
87
  spawn("sleep 5; open #{url} || xdg-open #{url} || echo @@@ Please open #{url}")
82
88
 
83
-
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.1
4
+ version: 0.5.4
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-06-02 00:00:00.000000000 Z
11
+ date: 2022-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler