Class: Spoom::Context

Inherits:
Object
  • Object
show all
Includes:
Bundle, Exec, FileSystem, Git, Sorbet
Defined in:
lib/spoom/context.rb,
lib/spoom/context/git.rb,
lib/spoom/context/exec.rb,
lib/spoom/context/bundle.rb,
lib/spoom/context/sorbet.rb,
lib/spoom/context/file_system.rb

Overview

An abstraction to a Ruby project context

A context maps to a directory in the file system. It is used to manipulate files and run commands in the context of this directory.

Defined Under Namespace

Modules: Bundle, Exec, FileSystem, Git, Sorbet

Constant Summary

Constants included from Sorbet

Sorbet::BIN_PATH, Sorbet::CONFIG_PATH, Sorbet::GEM_PATH, Sorbet::GEM_VERSION, Sorbet::KILLED_CODE, Sorbet::SEGFAULT_CODE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Git

#git, #git_checkout!, #git_checkout_new_branch!, #git_commit!, #git_current_branch, #git_diff, #git_init!, #git_last_commit, #git_log, #git_push!, #git_show, #git_workdir_clean?

Methods included from FileSystem

#absolute_path_to, #collect_files, #destroy!, #exist?, #file?, #glob, #list, #mkdir!, #move!, #read, #remove!, #write!

Methods included from Exec

#exec

Methods included from Bundle

#bundle, #bundle_exec, #bundle_install!, #gem_version_from_gemfile_lock, #gemfile_lock_specs, #read_gemfile, #read_gemfile_lock, #write_gemfile!

Constructor Details

#initialize(absolute_path) ⇒ Context

Create a new context about ‘absolute_path`

The directory will not be created if it doesn’t exist. Call ‘#make!` to create it. : (String absolute_path) -> void



47
48
49
# File 'lib/spoom/context.rb', line 47

def initialize(absolute_path)
  @absolute_path = T.let(::File.expand_path(absolute_path), String)
end

Instance Attribute Details

#absolute_pathObject (readonly)

The absolute path to the directory this context is about : String



40
41
42
# File 'lib/spoom/context.rb', line 40

def absolute_path
  @absolute_path
end

Class Method Details

.mktmp!(name = nil) ⇒ Object

Create a new context in the system’s temporary directory

‘name` is used as prefix to the temporary directory name. The directory will be created if it doesn’t exist. : (?String? name) -> instance



33
34
35
# File 'lib/spoom/context.rb', line 33

def mktmp!(name = nil)
  new(::Dir.mktmpdir(name))
end