Class: Moku::SCM::WorkingDirectory

Inherits:
Object
  • Object
show all
Defined in:
lib/moku/scm/working_directory.rb

Overview

Represents a working directory of a checked-out git repository, with a reference to both the checked-out directory and all files within the working directory.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, relative_files) ⇒ WorkingDirectory

Returns a new instance of WorkingDirectory.

Parameters:

  • dir (Pathname)
  • relative_files (Array<Pathname>)

24
25
26
27
# File 'lib/moku/scm/working_directory.rb', line 24

def initialize(dir, relative_files)
  @dir = dir
  @relative_files = relative_files
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir


29
30
31
# File 'lib/moku/scm/working_directory.rb', line 29

def dir
  @dir
end

#relative_filesObject (readonly)

Returns the value of attribute relative_files


29
30
31
# File 'lib/moku/scm/working_directory.rb', line 29

def relative_files
  @relative_files
end

Class Method Details

.from_path(path) ⇒ Object


14
15
16
17
18
19
20
# File 'lib/moku/scm/working_directory.rb', line 14

def self.from_path(path)
  files = Find.find(path.to_s)
    .map {|f| Pathname.new(f) }
    .select(&:file?)
    .map {|f| f.relative_path_from(path) }
  new(Pathname.new(path), files)
end

Instance Method Details

#real_filesObject


31
32
33
# File 'lib/moku/scm/working_directory.rb', line 31

def real_files
  relative_files.map {|file| dir/file }
end