Class: Hbc::HbVCSDownloadStrategy

Inherits:
AbstractDownloadStrategy show all
Defined in:
Library/Homebrew/cask/lib/hbc/download_strategy.rb

Direct Known Subclasses

SubversionDownloadStrategy

Constant Summary collapse

REF_TYPES =
[:branch, :revision, :revisions, :tag].freeze

Instance Attribute Summary

Attributes inherited from AbstractDownloadStrategy

#cask, #name, #uri_object, #url, #version

Instance Method Summary collapse

Methods inherited from AbstractDownloadStrategy

#fetch

Constructor Details

#initialize(*args, **options) ⇒ HbVCSDownloadStrategy



36
37
38
39
40
# File 'Library/Homebrew/cask/lib/hbc/download_strategy.rb', line 36

def initialize(*args, **options)
  super(*args, **options)
  @ref_type, @ref = extract_ref
  @clone = Hbc.cache.join(cache_filename)
end

Instance Method Details

#cache_filenameObject



49
50
51
# File 'Library/Homebrew/cask/lib/hbc/download_strategy.rb', line 49

def cache_filename
  "#{name}--#{cache_tag}"
end

#cache_tagObject



53
54
55
# File 'Library/Homebrew/cask/lib/hbc/download_strategy.rb', line 53

def cache_tag
  "__UNKNOWN__"
end

#cached_locationObject



57
58
59
# File 'Library/Homebrew/cask/lib/hbc/download_strategy.rb', line 57

def cached_location
  @clone
end

#clear_cacheObject



61
62
63
# File 'Library/Homebrew/cask/lib/hbc/download_strategy.rb', line 61

def clear_cache
  cached_location.rmtree if cached_location.exist?
end

#extract_refObject



42
43
44
45
46
47
# File 'Library/Homebrew/cask/lib/hbc/download_strategy.rb', line 42

def extract_ref
  key = REF_TYPES.find do |type|
    uri_object.respond_to?(type) && uri_object.send(type)
  end
  [key, key ? uri_object.send(key) : nil]
end