Module: Mnenv::Paths

Defined in:
lib/mnenv/paths.rb

Overview

Centralized directory paths for mnenv This ensures consistency across all components

Constant Summary collapse

MNENV_DIR =

Base directory for all mnenv data

File.expand_path('~/.mnenv').freeze
VERSIONS_DATA_DIR =

Directory for the git clone of metanorma/versions (READ-ONLY data) Contains: data/gemfile/versions.yaml, data/gemfile/v1.14.4/Gemfile, etc.

File.join(MNENV_DIR, 'versions').freeze
INSTALLED_DIR =

Directory for installed Metanorma versions Contains: 1.14.3-gemfile/, 1.14.3-binary/, 1.14.4-gemfile/, etc.

File.join(MNENV_DIR, 'installed').freeze
SHIMS_DIR =

Directory for shim scripts

File.join(MNENV_DIR, 'shims').freeze
LIB_DIR =

Directory for mnenv library files (resolver, etc.)

File.join(MNENV_DIR, 'lib', 'mnenv').freeze
VERSION_FILE =

Global version file

File.join(MNENV_DIR, 'version').freeze
SOURCE_FILE =

Global source file

File.join(MNENV_DIR, 'source').freeze

Class Method Summary collapse

Class Method Details

.ensure_directoriesObject

Ensure all required directories exist



32
33
34
35
36
37
# File 'lib/mnenv/paths.rb', line 32

def ensure_directories
  FileUtils.mkdir_p(MNENV_DIR)
  FileUtils.mkdir_p(INSTALLED_DIR)
  FileUtils.mkdir_p(SHIMS_DIR)
  FileUtils.mkdir_p(LIB_DIR)
end

.parse_version_dir(dir_name) ⇒ Array<String, String>

Parse a directory name into version and source components

Parameters:

  • dir_name (String)

    Directory name like “1.14.4-gemfile” or “1.14.4”

Returns:

  • (Array<String, String>)

    Tuple of [version, source] where source may be nil



60
61
62
63
64
65
66
# File 'lib/mnenv/paths.rb', line 60

def parse_version_dir(dir_name)
  if dir_name =~ /^(.+)-(gemfile|binary)$/
    [Regexp.last_match(1), Regexp.last_match(2)]
  else
    [dir_name, nil]
  end
end

.version_install_dir(version, source = nil) ⇒ String

Get the installation directory for a specific version and source

Parameters:

  • version (String)

    The version number (e.g., “1.14.4”)

  • source (String) (defaults to: nil)

    The source type (e.g., “gemfile”, “binary”)

Returns:

  • (String)

    The full path to the installation directory



43
44
45
46
47
48
49
50
# File 'lib/mnenv/paths.rb', line 43

def version_install_dir(version, source = nil)
  if source
    File.join(INSTALLED_DIR, "#{version}-#{source}")
  else
    # Backward compatibility: if no source specified, use version only
    File.join(INSTALLED_DIR, version)
  end
end

.versions_data_pathObject

Get the path to the data directory within the versions repo



53
54
55
# File 'lib/mnenv/paths.rb', line 53

def versions_data_path
  File.join(VERSIONS_DATA_DIR, 'data')
end