Module: Cocov::PluginKit
- Defined in:
- lib/cocov/plugin_kit.rb,
lib/cocov/plugin_kit/run.rb,
lib/cocov/plugin_kit/exec.rb,
lib/cocov/plugin_kit/realloc.rb,
lib/cocov/plugin_kit/version.rb
Overview
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
Defined Under Namespace
Modules: Exec Classes: Realloc, Run
Constant Summary collapse
- VERSION =
"0.1.6"
Class Method Summary collapse
-
.run(klass = nil, &block) ⇒ Object
Public: Prepares the environment and executes a given
klass(Class) or a single block.
Class Method Details
.run(klass = nil, &block) ⇒ Object
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.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cocov/plugin_kit.rb', line 27 def run(klass = nil, &block) if Process.uid != 1000 && !ENV.key?("COCOV_DEVELOPMENT") puts "Initialization failed: Cocov plugins must run as uid 1000. " \ "For more information, please refer to the documentation" exit 2 end 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 |