Module: Enola::Providers
- Defined in:
- lib/enola/providers.rb
Overview
Prism and Rubydex are on by default. Prism runs as the vendored upstream script under the Ruby running this gem; Rubydex is built into the binary and needs its engine library fetched once per binary version.
Constant Summary collapse
- RUBYDEX_EXPECTED_VERSION =
"0.4.0"
Class Method Summary collapse
-
.ensure_rubydex(binary, channel: Enola.channel, cache_root: Enola.cache_root, stderr: $stderr) ⇒ Object
Runs
providers fetch rubydexonce per binary version; the outcome is remembered beside the binary so a session never asks twice, and a failure is a named skip the graph will also report, never silence. - .prism_script ⇒ Object
- .prism_version ⇒ Object
- .ruby ⇒ Object
- .rubydex_expected_version(binary = nil) ⇒ Object
Class Method Details
.ensure_rubydex(binary, channel: Enola.channel, cache_root: Enola.cache_root, stderr: $stderr) ⇒ Object
Runs providers fetch rubydex once per binary version; the outcome is
remembered beside the binary so a session never asks twice, and a
failure is a named skip the graph will also report, never silence.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/enola/providers.rb', line 39 def self.ensure_rubydex(binary, channel: Enola.channel, cache_root: Enola.cache_root, stderr: $stderr) marker = File.join(channel.cache_dir(cache_root), "providers-rubydex") return File.read(marker).strip if File.exist?(marker) out, status = Open3.capture2e(binary, "providers", "fetch", "rubydex") outcome = status.success? ? "fetched" : "skipped: #{out.lines.last&.strip || 'providers fetch rubydex failed'}" stderr.puts "enola: rubydex #{outcome}; Rubydex facts will be a named skip in the receipt until it succeeds" unless status.success? FileUtils.mkdir_p(File.dirname(marker)) File.write(marker, "#{outcome}\n") outcome rescue SystemCallError => e "skipped: #{e.}" end |
.prism_script ⇒ Object
14 15 16 |
# File 'lib/enola/providers.rb', line 14 def self.prism_script File.("providers/prism/enola_prism_provider.rb", __dir__) end |
.prism_version ⇒ Object
22 23 24 25 |
# File 'lib/enola/providers.rb', line 22 def self.prism_version out, status = Open3.capture2(ruby, prism_script, "--version") status.success? ? out.strip : nil end |
.ruby ⇒ Object
18 19 20 |
# File 'lib/enola/providers.rb', line 18 def self.ruby RbConfig.ruby end |
.rubydex_expected_version(binary = nil) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/enola/providers.rb', line 27 def self.rubydex_expected_version(binary = nil) return RUBYDEX_EXPECTED_VERSION unless binary out, status = Open3.capture2(binary, "providers", "list") return RUBYDEX_EXPECTED_VERSION unless status.success? out[/rubydex\s+(\d+\.\d+\.\d+)/, 1] || RUBYDEX_EXPECTED_VERSION end |