Class: R10K::Module::Tarball
- Includes:
- Util::Setopts
- Defined in:
- lib/r10k/module/tarball.rb
Overview
This class defines a tarball source module implementation
Constant Summary
Constants included from Logging
Logging::LOG_LEVELS, Logging::SYSLOG_LEVELS_MAP
Instance Attribute Summary collapse
-
#tarball ⇒ Object
readonly
Returns the value of attribute tarball.
Attributes inherited from Base
#dirname, #environment, #name, #origin, #owner, #path, #spec_deletable, #title
Class Method Summary collapse
Instance Method Summary collapse
-
#cachedir ⇒ String
Tarball caches are files, not directories.
-
#initialize(name, dirname, opts, environment = nil) ⇒ Tarball
constructor
A new instance of Tarball.
-
#properties ⇒ Hash
abstract
Return the properties of the module.
-
#status ⇒ Symbol
Return the status of the currently installed module.
-
#sync(opts = {}) ⇒ Boolean
Synchronize this module with the indicated state.
-
#version ⇒ Object
Return the desired version of this module.
Methods included from Logging
add_outputters, debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level
Methods inherited from Base
#accept, #delete_spec_dir, #full_path, #maybe_delete_spec_dir, #should_sync?
Constructor Details
#initialize(name, dirname, opts, environment = nil) ⇒ Tarball
Returns a new instance of Tarball.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/r10k/module/tarball.rb', line 27 def initialize(name, dirname, opts, environment=nil) super setopts(opts, { # Standard option interface :source => :self, :version => :checksum, :type => ::R10K::Util::Setopts::Ignore, :overrides => :self, # Type-specific options :checksum => :self, }) @tarball = R10K::Tarball.new(name, @source, checksum: @checksum) end |
Instance Attribute Details
#tarball ⇒ Object (readonly)
Returns the value of attribute tarball.
23 24 25 |
# File 'lib/r10k/module/tarball.rb', line 23 def tarball @tarball end |
Class Method Details
.implement?(name, args) ⇒ Boolean
10 11 12 13 14 |
# File 'lib/r10k/module/tarball.rb', line 10 def self.implement?(name, args) args.is_a?(Hash) && args[:type].to_s == 'tarball' rescue false end |
.statically_defined_version(name, args) ⇒ Object
16 17 18 |
# File 'lib/r10k/module/tarball.rb', line 16 def self.statically_defined_version(name, args) args[:version] || args[:checksum] end |
Instance Method Details
#cachedir ⇒ String
Tarball caches are files, not directories. An important purpose of this method is to indicate where the cache “path” is, for locking/parallelism, so for the Tarball module type, the relevant path location is returned.
98 99 100 |
# File 'lib/r10k/module/tarball.rb', line 98 def cachedir tarball.cache_path end |
#properties ⇒ Hash
Return the properties of the module
85 86 87 88 89 90 91 |
# File 'lib/r10k/module/tarball.rb', line 85 def properties { :expected => version, :actual => ((state = status) == :insync) ? version : state, :type => :tarball, } end |
#status ⇒ Symbol
Return the status of the currently installed module.
46 47 48 49 50 51 52 53 54 |
# File 'lib/r10k/module/tarball.rb', line 46 def status if not path.exist? :absent elsif not (tarball.cache_valid? && tarball.insync?(path.to_s)) :mismatched else :insync end end |
#sync(opts = {}) ⇒ Boolean
Synchronize this module with the indicated state.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/r10k/module/tarball.rb', line 59 def sync(opts={}) tarball.get unless tarball.cache_valid? if should_sync? case status when :absent tarball.unpack(path.to_s) when :mismatched path.rmtree tarball.unpack(path.to_s) end maybe_delete_spec_dir true else false end end |
#version ⇒ Object
Return the desired version of this module
77 78 79 |
# File 'lib/r10k/module/tarball.rb', line 77 def version @checksum || '(present)' end |