Class: FilesInMyDiff::TmpDir::RevisionDir
- Inherits:
-
Object
- Object
- FilesInMyDiff::TmpDir::RevisionDir
- Defined in:
- lib/files_in_my_diff/tmp_dir/revision_dir.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Instance Method Summary collapse
- #create! ⇒ Object
- #decorate(changes) ⇒ Object
-
#initialize(sha:, file_strategy: FileStrategy) ⇒ RevisionDir
constructor
A new instance of RevisionDir.
Constructor Details
#initialize(sha:, file_strategy: FileStrategy) ⇒ RevisionDir
Returns a new instance of RevisionDir.
8 9 10 11 |
# File 'lib/files_in_my_diff/tmp_dir/revision_dir.rb', line 8 def initialize(sha:, file_strategy: FileStrategy) @sha = sha @file_strategy = file_strategy end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
6 7 8 |
# File 'lib/files_in_my_diff/tmp_dir/revision_dir.rb', line 6 def dir @dir end |
Instance Method Details
#create! ⇒ Object
13 14 15 16 17 |
# File 'lib/files_in_my_diff/tmp_dir/revision_dir.rb', line 13 def create! tmpdir = @file_strategy.tmpdir @dir = File.join(tmpdir, 'files_in_my_diff', @sha) @file_strategy.mkdir_p(@dir) end |
#decorate(changes) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/files_in_my_diff/tmp_dir/revision_dir.rb', line 19 def decorate(changes) raise DirectoryError, "Directory for #{@sha} not yet created" if @dir.nil? d_changes = changes.map do |change| change => { path:, type: } { full_path: full_path(path), relative_path: path, type: } end { dir: @dir, sha: @sha, changes: d_changes } end |