Module: Contrast::Extension::Assess::InstrumentHelper
- Extended by:
- Components::Logger::InstanceMethods
- Defined in:
- lib/contrast/extension/extension.rb
Overview
This is the main instrument helper giving the method of requiring C patches
Class Method Summary collapse
-
.assign_value(path) ⇒ Object
Some of the requires have some extra conditions for them to require the C patches, so this method is helping us move the logic by making some conditions.
-
.gen_name(path) ⇒ Object
Generate the needed instance variable name and return the extracted name.
-
.instrument(path) ⇒ Object
Unites the different require methods into one, using only the provided path for the C patches parameters.
Methods included from Components::Logger::InstanceMethods
Class Method Details
.assign_value(path) ⇒ Object
Some of the requires have some extra conditions for them to require the C patches, so this method is helping us move the logic by making some conditions
37 38 39 40 41 42 43 44 45 |
# File 'lib/contrast/extension/extension.rb', line 37 def assign_value path case path when /fiber/, /interpolation/ require(path) if Funchook.available? else require(path) end true end |
.gen_name(path) ⇒ Object
Generate the needed instance variable name and return the extracted name
48 49 50 51 52 53 54 |
# File 'lib/contrast/extension/extension.rb', line 48 def gen_name path extracted_name = path.split(%r{[\s_/]})&.uniq&.delete_if do |s| s.empty? || s == 'cs' || s == 'assess' || s == 'track' end extracted_name = (extracted_name&.length || 0) > 1 ? extracted_name&.join('_') : extracted_name&.pop ["@_instrument_#{ extracted_name }_track", extracted_name] end |
.instrument(path) ⇒ Object
Unites the different require methods into one, using only the provided path for the C patches parameters
24 25 26 27 28 29 30 31 32 |
# File 'lib/contrast/extension/extension.rb', line 24 def instrument path var_name, extracted_name = gen_name(path) return if instance_variable_get(var_name) == true instance_variable_set(var_name, assign_value(path)) rescue StandardError, LoadError => e logger.error("Error loading #{ extracted_name&.nil? ? '' : extracted_name } patch", e) false end |