Module: R10K::Util::Cacheable Abstract
- Included in:
- Git::Cache, Tarball
- Defined in:
- lib/r10k/util/cacheable.rb
Overview
This module is abstract.
Classes using this mixin need to implement #managed_directory and #desired_contents
Utility mixin for classes that need to implement caches
Class Method Summary collapse
-
.default_cachedir(basename = 'cache') ⇒ String
Provide a default cachedir location.
Instance Method Summary collapse
-
#sanitized_dirname(string) ⇒ String
Reformat a string into something that can be used as a directory.
Class Method Details
.default_cachedir(basename = 'cache') ⇒ String
Provide a default cachedir location. This is consumed by R10K::Settings for appropriate global default values.
14 15 16 17 18 19 20 |
# File 'lib/r10k/util/cacheable.rb', line 14 def self.default_cachedir(basename = 'cache') if R10K::Util::Platform.windows? File.join(ENV['LOCALAPPDATA'], 'r10k', basename) else File.join(ENV['HOME'] || '/root', '.r10k', basename) end end |
Instance Method Details
#sanitized_dirname(string) ⇒ String
Reformat a string into something that can be used as a directory
26 27 28 |
# File 'lib/r10k/util/cacheable.rb', line 26 def sanitized_dirname(string) string.gsub(/(\w+:\/\/)(.*)(@)/, '\1').gsub(/[^@\w\.-]/, '-') end |