Sha256: 5c0f61c3c230cbd8f33f5ce12afcb9dadf70fb4d58b02ab7ad5e717d989afa54
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true require "json" require "yaml" require "digest/sha1" require "pathname" require "tempfile" require "tmpdir" require_relative "plugin_kit/version" require_relative "plugin_kit/exec" require_relative "plugin_kit/realloc" require_relative "plugin_kit/run" module Cocov # PluginKit implements helpers for implementing Cocov Plugins in Ruby. The # main module provides a single run function that must be used to wrap the # plugin runtime, and is responsible for preparing the environment and running # the provided block module PluginKit module_function # Public: Prepares the environment and executes a given `klass` (Class) or # a single block. When `klass` is not provided, PluginKit::Run is used. # When providing a custom class, make sure to inherit PluginKit::Run. # For examples, see the library's README file. def run(klass = nil, &block) output_file = File.open(ENV.fetch("COCOV_OUTPUT_FILE"), "w") exit_code = 0 klass ||= Run instance = klass.new(output_file) Dir.chdir(instance.workdir) do Realloc.mounts! if block_given? instance.instance_exec(&block) else instance.run end rescue SystemExit => e exit_code = e.status rescue Exception => e puts "Failed processing: #{e}" puts e.backtrace.join("\n") exit_code = 1 end output_file.flush output_file.close exit(exit_code) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cocov_plugin_kit-0.1.4 | lib/cocov/plugin_kit.rb |
cocov_plugin_kit-0.1.3 | lib/cocov/plugin_kit.rb |