kdwatch 0.1.0 → 0.1.1

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: fc8f8c23c6efa56df70b322eb61dc16b913fdf1a93640d3de4da1feeadfba752
4
- data.tar.gz: ab67e9ebabd65974a86d65f89a0ffc20af380a1806a13501fa6ecefb07076663
3
+ metadata.gz: eaba18036cbe879e4f88d5b74513ad4a5d36abb843234c83c35e688aaaf36e03
4
+ data.tar.gz: ea272b95fef2f02ec9513539dee9f4f5126b4e65c3c6a97b0603d94fa7cd37e2
5
5
  SHA512:
6
- metadata.gz: c072cf5ae36599a794e6af8520f2fb0d4cb31d87441cec63c9e9137198bea04f4169b553a173787b1073759f04e27603f162b20ca8b0df745f24b2be4b1aa033
7
- data.tar.gz: '012684f1584c8f9ddb902a52369510b137840d9a29bac34732cc1939821d6ae96f6598bd57eb925515f9715936935351aa123fd4c9f619c63976b99274e174fc'
6
+ metadata.gz: 603817fcb75e8b474a4f6bc7d58408c4d8fcc55f7cbd50d1cd6a48f8d21a8b2672f2b221697b9948412e2bf4825dd9925ae10f9a4be6a6360e7c5e54c94c9471
7
+ data.tar.gz: 4237a7b045723de06320999301e0c388d879d6f5016b12c7170702b7b24981e302848eb76aad46513cde1a0d37792811165710c865a9cb597064dca17a54eed5
data/bin/kdwatch CHANGED
@@ -3,15 +3,55 @@ ENV["LANG"]="en_US.utf-8"
3
3
  ENV["LC_CTYPE"]="en_US.utf-8"
4
4
  ENV["KRAMDOWN_PERSISTENT"]="yes"
5
5
 
6
+ KDWATCH_PORT = 7991 # currently unregistered...
7
+
8
+ ## -r: Kill any previous kdwatch and continue ("restart")
9
+ ## -e: Kill any previous kdwatch and exit
10
+ if ARGV[0] == "-e" || ARGV[0] == "-r"
11
+ require 'open3'
12
+
13
+ status = 1
14
+ flag = ARGV.shift
15
+
16
+ stdout_str, stderr_str, s = Open3.capture3("lsof -ti :#{KDWATCH_PORT} -s TCP:LISTEN")
17
+ pids = if s.success? && stdout_str =~ /\A[0-9\s]*\z/ && stderr_str
18
+ stdout_str.split
19
+ else
20
+ text = stdout_str + stderr_str
21
+ warn "** lsof, status #{s}, says: #{text}" if text != "" || s.exitstatus != 1
22
+ []
23
+ end
24
+ if pids == []
25
+ warn "** Nothing listening on kdwatch port" unless flag == "-r"
26
+ elsif pids.size != 1
27
+ warn "** More than one process listening on kdwatch port, nothing done"
28
+ else
29
+ begin
30
+ status = Process.kill(2, Integer(pids[0])) - 1 # should be 1 for 1 kill, exit 0 then
31
+ rescue Errno => e
32
+ warn "** #{pids[0]}: #{e.inspect}"
33
+ end
34
+ end
35
+ exit(status) if flag == "-e"
36
+ end
37
+
38
+ ## Find an .mkd or a draft-*.md (excluding README.md and such)
6
39
  if ARGV == []
7
- ARGV.replace Dir["draft-*.md"]
40
+ ARGV.replace Dir.glob(["draft-*.md", "*.mkd"])
8
41
  warn_replace = 1
9
42
  end
10
43
 
11
44
  if ARGV.size != 1
12
- warn "** Usage: #$0 [draft-foo.md]"
13
- warn "** More than one draft file found #{ARGV.inspect}" if warn_replace
14
- warn "** Please select one for watching." if warn_replace
45
+ warn "** Usage: #$0 [-r] [draft-foo.md]"
46
+ warn "** #$0 -e"
47
+ if warn_replace
48
+ if ARGV.size > 1
49
+ warn "** More than one draft file found #{ARGV.inspect}"
50
+ warn "** Please select one for watching."
51
+ else
52
+ warn "** No draft file draft-*.md or *.mkd found."
53
+ end
54
+ end
15
55
  exit 1
16
56
  end
17
57
 
@@ -24,4 +64,4 @@ require 'kdwatch-app.rb'
24
64
  run Sinatra::Application
25
65
  HERE
26
66
 
27
- exec("rackup -E production -s thin -p 7991 .config.ru")
67
+ exec("rackup -E production -s thin -p #{KDWATCH_PORT} .config.ru")
data/lib/kdwatch-app.rb CHANGED
@@ -45,7 +45,7 @@ end
45
45
  GF
46
46
 
47
47
  rd, _wr = IO.pipe
48
- spawn("guard -G .Guardfile", in: rd)
48
+ spawn("guard -G .Guardfile", in: rd, close_others: true)
49
49
 
50
50
  # wrong: puts settings.port
51
51
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kdwatch
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.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.1.0
4
+ version: 0.1.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: 2021-07-03 00:00:00.000000000 Z
11
+ date: 2021-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler