gretl 1.0.1 → 1.0.3
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/lib/gretl.rb +26 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5ec89db993e1173b658f0212d7400f2ff72ec28df4e916d06496633b983d8e83
|
|
4
|
+
data.tar.gz: 0b9b805cb901980105a889b53c08c01d07ce15941e2ab6e3d8fa590fce724598
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18c3a255ebe2071a6d26f37f5e902a981916caf3ae56a810637205f331904adbfc3e85275b6490c17b848a1686d37ce35268c31a638efc6f50501363f957089d
|
|
7
|
+
data.tar.gz: b61235716204afefda5eb1a4cb7f9461f0c760aab819c5b5aa7225b9dd62d2c09a1aa9efd5fa61e05455ee7e039afa2859906dc28ce99ff7915f5d3a86e73132
|
data/lib/gretl.rb
CHANGED
|
@@ -5,6 +5,27 @@ require "uri"
|
|
|
5
5
|
module Gretl
|
|
6
6
|
BASE = "http://127.0.0.1:27892"
|
|
7
7
|
|
|
8
|
+
module_function
|
|
9
|
+
|
|
10
|
+
def _daemon_running?
|
|
11
|
+
uri = URI("#{BASE}/health")
|
|
12
|
+
Net::HTTP.get_response(uri).is_a?(Net::HTTPSuccess)
|
|
13
|
+
rescue
|
|
14
|
+
false
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def _ensure_daemon
|
|
18
|
+
return if _daemon_running?
|
|
19
|
+
gr = `which gr 2>/dev/null`.strip
|
|
20
|
+
raise "Gretl daemon is not running and `gr` was not found on PATH.\nInstall with: npm install -g @gretl/cli then run: gr daemon start" if gr.empty?
|
|
21
|
+
spawn(gr, "daemon", "start", out: File::NULL, err: File::NULL)
|
|
22
|
+
25.times do
|
|
23
|
+
sleep 0.2
|
|
24
|
+
return if _daemon_running?
|
|
25
|
+
end
|
|
26
|
+
raise "Gretl daemon did not start in time. Run: gr daemon start"
|
|
27
|
+
end
|
|
28
|
+
|
|
8
29
|
PortInfo = Struct.new(
|
|
9
30
|
:port, :name, :active, :pid, :process,
|
|
10
31
|
:has_command, :group, :is_docker, :links,
|
|
@@ -18,6 +39,7 @@ module Gretl
|
|
|
18
39
|
module_function
|
|
19
40
|
|
|
20
41
|
def _request(method, path)
|
|
42
|
+
_ensure_daemon
|
|
21
43
|
uri = URI("#{BASE}#{path}")
|
|
22
44
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
23
45
|
http.open_timeout = 5
|
|
@@ -29,8 +51,8 @@ module Gretl
|
|
|
29
51
|
end
|
|
30
52
|
res = http.request(req)
|
|
31
53
|
JSON.parse(res.body, symbolize_names: true)
|
|
32
|
-
rescue Errno::ECONNREFUSED
|
|
33
|
-
raise "Cannot connect to Gretl
|
|
54
|
+
rescue Errno::ECONNREFUSED => e
|
|
55
|
+
raise "Cannot connect to Gretl daemon: #{e}"
|
|
34
56
|
end
|
|
35
57
|
|
|
36
58
|
def _fetch_ports
|
|
@@ -50,8 +72,8 @@ module Gretl
|
|
|
50
72
|
class Client
|
|
51
73
|
def ports = Gretl._fetch_ports
|
|
52
74
|
def port(query) = Gretl._resolve(query)
|
|
53
|
-
def active = _fetch_ports.select(&:active)
|
|
54
|
-
def inactive = _fetch_ports.reject(&:active)
|
|
75
|
+
def active = Gretl._fetch_ports.select(&:active)
|
|
76
|
+
def inactive = Gretl._fetch_ports.reject(&:active)
|
|
55
77
|
|
|
56
78
|
def start(query)
|
|
57
79
|
matches = Gretl._resolve(query)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gretl
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gretl
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email:
|