Module: Evilution::GemDetector Private

Defined in:
lib/evilution/gem_detector.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.gem_entry_for(root, target_paths: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/evilution/gem_detector.rb', line 29

def gem_entry_for(root, target_paths: nil)
  gem_name = gem_name_for(root, target_paths: target_paths)
  return nil unless gem_name

  dotted = File.join(root, "lib", "#{gem_name.tr("-", "/")}.rb")
  return dotted if File.file?(dotted)

  flat = File.join(root, "lib", "#{gem_name}.rb")
  return flat if File.file?(flat)

  nil
end

.gem_name(root, target_paths: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Public accessor for the resolved gem name (gemspec basename, disambiguated by target paths for multi-gemspec roots). Callers use it to derive conventional paths such as a namespaced test helper (test//helper.rb).



49
50
51
# File 'lib/evilution/gem_detector.rb', line 49

def gem_name(root, target_paths: nil)
  gem_name_for(root, target_paths: target_paths)
end

.gem_root_for(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/evilution/gem_detector.rb', line 8

def gem_root_for(path)
  return nil if path.nil?

  dir = starting_dir(path)
  return nil if dir.nil?

  @mutex.synchronize do
    return @cache[dir] if @cache.key?(dir)

    @cache[dir] = walk_up(dir)
  end
end

.gem_root_for_any(paths) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
24
25
26
27
# File 'lib/evilution/gem_detector.rb', line 21

def gem_root_for_any(paths)
  Array(paths).each do |path|
    root = gem_root_for(path)
    return root if root
  end
  nil
end

.reset_cache!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
# File 'lib/evilution/gem_detector.rb', line 42

def reset_cache!
  @mutex.synchronize { @cache.clear }
end