Class: FPM::Fry::Source::Archive
- Inherits:
-
Object
- Object
- FPM::Fry::Source::Archive
- Defined in:
- lib/fpm/fry/source/archive.rb
Overview
Used to build from an archive.
It is highly advised to supply a checksum ( althought it’s not mandatory ). This checksum will be used to test for cache validity and data integrity. The checksum algorithm is automatically guessed based on the length of the checksum.
- 40 characters = sha1
- 64 characters = sha256
- 128 characters = sha512
Let’s be honest: all other checksum algorithms aren’t or shouldn’t be in use anyway.
Defined Under Namespace
Classes: Cache, PlainCache, RedirectError, TarBz2Cache, TarCache, TarGzCache, UnknownArchiveType, ZipCache
Constant Summary collapse
- REGEX =
%r!\Ahttps?:!
- CACHE_CLASSES =
{ '.tar' => TarCache, '.tar.gz' => TarGzCache, '.tgz' => TarGzCache, '.tar.bz2' => TarBz2Cache, '.zip' => ZipCache, '.bin' => PlainCache, '.bundle' => PlainCache }
Instance Attribute Summary collapse
-
#checksum ⇒ Object
readonly
Returns the value of attribute checksum.
-
#checksum_algorithm ⇒ Object
readonly
Returns the value of attribute checksum_algorithm.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#file_map ⇒ Object
readonly
Returns the value of attribute file_map.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
- .aliases ⇒ Object
-
.guess(url) ⇒ nil, Numeric
Guesses if the given url is an archive.
- .name ⇒ :archive
Instance Method Summary collapse
-
#build_cache(tempdir) ⇒ TarCache, ...
Creates a cache.
-
#initialize(url, options = {}) ⇒ Archive
constructor
A new instance of Archive.
Constructor Details
#initialize(url, options = {}) ⇒ Archive
Returns a new instance of Archive.
283 284 285 286 287 288 289 290 291 |
# File 'lib/fpm/fry/source/archive.rb', line 283 def initialize( url, = {} ) @url = URI(url) @cache_class = guess_cache_class(@url) @logger = .fetch(:logger){ Cabin::Channel.get } @checksum = [:checksum] @checksum_algorithm = guess_checksum_algorithm([:checksum]) @file_map = [:file_map] @to = [:to] end |
Instance Attribute Details
#checksum ⇒ Object (readonly)
Returns the value of attribute checksum.
276 277 278 |
# File 'lib/fpm/fry/source/archive.rb', line 276 def checksum @checksum end |
#checksum_algorithm ⇒ Object (readonly)
Returns the value of attribute checksum_algorithm.
276 277 278 |
# File 'lib/fpm/fry/source/archive.rb', line 276 def checksum_algorithm @checksum_algorithm end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
276 277 278 |
# File 'lib/fpm/fry/source/archive.rb', line 276 def data @data end |
#file_map ⇒ Object (readonly)
Returns the value of attribute file_map.
276 277 278 |
# File 'lib/fpm/fry/source/archive.rb', line 276 def file_map @file_map end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
276 277 278 |
# File 'lib/fpm/fry/source/archive.rb', line 276 def logger @logger end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
276 277 278 |
# File 'lib/fpm/fry/source/archive.rb', line 276 def to @to end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
276 277 278 |
# File 'lib/fpm/fry/source/archive.rb', line 276 def url @url end |
Class Method Details
.aliases ⇒ Object
36 37 38 |
# File 'lib/fpm/fry/source/archive.rb', line 36 def self.aliases [:package,:http] end |
.guess(url) ⇒ nil, Numeric
Guesses if the given url is an archive.
50 51 52 |
# File 'lib/fpm/fry/source/archive.rb', line 50 def self.guess( url ) Source::guess_regex(REGEX, url) end |
.name ⇒ :archive
32 33 34 |
# File 'lib/fpm/fry/source/archive.rb', line 32 def self.name :package end |
Instance Method Details
#build_cache(tempdir) ⇒ TarCache, ...
Creates a cache.
301 302 303 |
# File 'lib/fpm/fry/source/archive.rb', line 301 def build_cache(tempdir) @cache_class.new(self, tempdir) end |