Add @ref_type and @ref needef for fossil.

This commit is contained in:
Markus Reiter 2018-07-09 22:11:26 +02:00
parent 5dfa4ded43
commit cba55c8fd4
2 changed files with 6 additions and 4 deletions

View File

@ -47,7 +47,7 @@ class AbstractDownloadStrategy
# chdir into the newly-unpacked directory. # chdir into the newly-unpacked directory.
# Unlike {Resource#stage}, this does not take a block. # Unlike {Resource#stage}, this does not take a block.
def stage def stage
UnpackStrategy.detect(cached_location) UnpackStrategy.detect(cached_location, ref_type: @ref_type, ref: @ref)
.extract(basename: basename_without_params) .extract(basename: basename_without_params)
end end

View File

@ -27,7 +27,7 @@ class UnpackStrategy
end end
private_class_method :strategies private_class_method :strategies
def self.detect(path) def self.detect(path, ref_type: nil, ref: nil)
magic_number = if path.directory? magic_number = if path.directory?
"" ""
else else
@ -48,13 +48,15 @@ class UnpackStrategy
UncompressedUnpackStrategy UncompressedUnpackStrategy
end end
strategy.new(path) strategy.new(path, ref_type: ref_type, ref: ref)
end end
attr_reader :path attr_reader :path
def initialize(path) def initialize(path, ref_type: nil, ref: nil)
@path = Pathname(path).expand_path @path = Pathname(path).expand_path
@ref_type = ref_type
@ref = ref
end end
def extract(to: nil, basename: nil) def extract(to: nil, basename: nil)