Class: Mnenv::ShimManager
- Inherits:
-
Object
- Object
- Mnenv::ShimManager
- Defined in:
- lib/mnenv/shim_manager.rb
Constant Summary collapse
- RESOLVER_SCRIPT =
File.('resolver', __dir__).freeze
Instance Attribute Summary collapse
-
#installed_dir ⇒ Object
readonly
Returns the value of attribute installed_dir.
-
#shims_dir ⇒ Object
readonly
Returns the value of attribute shims_dir.
Instance Method Summary collapse
- #create_shims(executable_name) ⇒ Object
-
#initialize(shims_dir: nil, installed_dir: nil) ⇒ ShimManager
constructor
A new instance of ShimManager.
- #regenerate_all ⇒ Object
Constructor Details
#initialize(shims_dir: nil, installed_dir: nil) ⇒ ShimManager
Returns a new instance of ShimManager.
12 13 14 15 |
# File 'lib/mnenv/shim_manager.rb', line 12 def initialize(shims_dir: nil, installed_dir: nil) @shims_dir = shims_dir || Paths::SHIMS_DIR @installed_dir = installed_dir || Paths::INSTALLED_DIR end |
Instance Attribute Details
#installed_dir ⇒ Object (readonly)
Returns the value of attribute installed_dir.
10 11 12 |
# File 'lib/mnenv/shim_manager.rb', line 10 def installed_dir @installed_dir end |
#shims_dir ⇒ Object (readonly)
Returns the value of attribute shims_dir.
10 11 12 |
# File 'lib/mnenv/shim_manager.rb', line 10 def shims_dir @shims_dir end |
Instance Method Details
#create_shims(executable_name) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/mnenv/shim_manager.rb', line 36 def create_shims(executable_name) # Create shims for all platform-appropriate shells Shells::ShellFactory.platform_shells.each do |shell| create_shim_for_shell(executable_name, shell) end end |
#regenerate_all ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mnenv/shim_manager.rb', line 17 def regenerate_all FileUtils.mkdir_p(@shims_dir) FileUtils.mkdir_p(Paths::LIB_DIR) # Copy resolver script to mnenv lib directory (for Unix shells) if File.exist?(RESOLVER_SCRIPT) FileUtils.cp(RESOLVER_SCRIPT, File.join(Paths::LIB_DIR, 'resolver')) File.chmod(0o755, File.join(Paths::LIB_DIR, 'resolver')) end executables = discover_executables executables.each do |exe| create_shims(exe) end remove_obsolete_shims(executables) end |