Class: FPM::Fry::Source::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/fpm/fry/source/package.rb

Defined Under Namespace

Classes: Cache, PlainCache, RedirectError, TarCache, TarGzCache, ZipCache

Constant Summary collapse

REGEX =
%r!\Ahttps?:!
CACHE_CLASSES =
{
  '.tar' => TarCache,
  '.tar.gz' => TarGzCache,
  '.tgz' => TarGzCache,
  '.zip' => ZipCache,
  '.bin' => PlainCache,
  '.bundle' => PlainCache
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ Package

Returns a new instance of Package.



199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/fpm/fry/source/package.rb', line 199

def initialize( url, options = {} )
  @url = URI(url)
  @extension = options.fetch(:extension){
    CACHE_CLASSES.keys.find{|ext|
      @url.path.end_with?(ext)
    }
  }
  @logger = options.fetch(:logger){ Cabin::Channel.get }
  @checksum = options[:checksum]
  @checksum_algorithm = guess_checksum_algorithm(options[:checksum])
  @file_map = options.fetch(:file_map){ {'' => ''} }
end

Instance Attribute Details

#agentObject (readonly)

Returns the value of attribute agent.



197
198
199
# File 'lib/fpm/fry/source/package.rb', line 197

def agent
  @agent
end

#checksumObject (readonly)

Returns the value of attribute checksum.



197
198
199
# File 'lib/fpm/fry/source/package.rb', line 197

def checksum
  @checksum
end

#checksum_algorithmObject (readonly)

Returns the value of attribute checksum_algorithm.



197
198
199
# File 'lib/fpm/fry/source/package.rb', line 197

def checksum_algorithm
  @checksum_algorithm
end

#dataObject (readonly)

Returns the value of attribute data.



197
198
199
# File 'lib/fpm/fry/source/package.rb', line 197

def data
  @data
end

#extensionObject (readonly)

Returns the value of attribute extension.



197
198
199
# File 'lib/fpm/fry/source/package.rb', line 197

def extension
  @extension
end

#file_mapObject (readonly)

Returns the value of attribute file_map.



197
198
199
# File 'lib/fpm/fry/source/package.rb', line 197

def file_map
  @file_map
end

#loggerObject (readonly)

Returns the value of attribute logger.



197
198
199
# File 'lib/fpm/fry/source/package.rb', line 197

def logger
  @logger
end

#urlObject (readonly)

Returns the value of attribute url.



197
198
199
# File 'lib/fpm/fry/source/package.rb', line 197

def url
  @url
end

Class Method Details

.aliasesObject



16
17
18
# File 'lib/fpm/fry/source/package.rb', line 16

def self.aliases
  [:http]
end

.guess(url) ⇒ Object



20
21
22
# File 'lib/fpm/fry/source/package.rb', line 20

def self.guess( url )
  Source::guess_regex(REGEX, url)
end

.nameObject



12
13
14
# File 'lib/fpm/fry/source/package.rb', line 12

def self.name
  :package
end

Instance Method Details

#build_cache(tempdir) ⇒ Object



212
213
214
# File 'lib/fpm/fry/source/package.rb', line 212

def build_cache(tempdir)
  CACHE_CLASSES.fetch(extension).new(self, tempdir)
end