Module: Kettle::Jem::Appraisals::XStdLibsExclusion

Defined in:
lib/kettle/jem/appraisals/x_std_libs_exclusion.rb,
sig/kettle/jem/appraisals.rbs

Overview

Introspects the kettle-jem template's x_std_libs/vHEAD.gemfile to determine which gems are already handled by the standard library extraction framework.

These gems should be excluded from appraisal matrix generation because they are managed separately via the x_std_libs modular gemfiles.

Examples:

Check if a gem is excluded

XStdLibsExclusion.excluded?("mutex_m") #=> true
XStdLibsExclusion.excluded?("sqlite3")  #=> false

Constant Summary collapse

ALWAYS_EXCLUDED =

Returns gem names that are always excluded regardless of template content.

Returns:

  • (Array<String>)

    gem names that are always excluded regardless of template content

%w[version_gem].freeze

Class Method Summary collapse

Class Method Details

.default_template_pathString?

Locates the x_std_libs/vHEAD.gemfile in the installed kettle-jem gem.

Returns:

  • (String, nil)

    absolute path to the template file, or nil if kettle-jem is not installed or the file does not exist



50
51
52
53
54
55
56
# File 'lib/kettle/jem/appraisals/x_std_libs_exclusion.rb', line 50

def default_template_path
  spec = Gem::Specification.find_by_name("kettle-jem")
  path = File.join(spec.gem_dir, "template", "gemfiles", "modular", "x_std_libs", "vHEAD.gemfile.example")
  File.exist?(path) ? path : nil
rescue Gem::MissingSpecError
  nil
end

.excluded?(gem_name, exclusion_list: nil) ⇒ Boolean

Returns whether the gem should be excluded from the appraisal matrix.

Parameters:

  • gem_name (String)

    the gem name to check

  • exclusion_list (Array<String>, nil) (defaults to: nil)

    an explicit exclusion list; when nil, calls from_template to build the list

  • exclusion_list: (Array[String], nil) (defaults to: nil)

Returns:

  • (Boolean)

    true if the gem is excluded



64
65
66
# File 'lib/kettle/jem/appraisals/x_std_libs_exclusion.rb', line 64

def excluded?(gem_name, exclusion_list: nil)
  (exclusion_list || from_template).include?(gem_name)
end

.from_template(template_path = nil) ⇒ Array<String>

Parses the x_std_libs vHEAD template to extract the set of gems managed by the x_std_libs framework.

The template contains eval_gemfile lines like:

eval_gemfile "../erb/vHEAD.gemfile"
eval_gemfile "../mutex_m/vHEAD.gemfile"

This extracts the gem directory names (+erb+, mutex_m, etc.) and merges them with ALWAYS_EXCLUDED.

Parameters:

  • template_path (String, nil) (defaults to: nil)

    path to the vHEAD.gemfile template; when nil, uses default_template_path

Returns:

  • (Array<String>)

    frozen list of excluded gem names



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/kettle/jem/appraisals/x_std_libs_exclusion.rb', line 33

def from_template(template_path = nil)
  template_path ||= default_template_path
  return ALWAYS_EXCLUDED.dup unless template_path && File.exist?(template_path)

  gems = File.readlines(template_path).filter_map { |line|
    if (match = line.match(%r{eval_gemfile\s+["']\.\./([\w-]+)/}))
      match[1]
    end
  }

  (gems + ALWAYS_EXCLUDED).uniq.freeze
end