Class: PEBuild::Archive
- Inherits:
-
Object
- Object
- PEBuild::Archive
- Includes:
- Idempotent
- Defined in:
- lib/pe_build/archive.rb
Overview
Represents a packed Puppet Enterprise archive
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
-
#filename ⇒ String
The filename.
-
#series ⇒ String
The release series of PE.
-
#version ⇒ String
The version of Puppet Enterprise.
Instance Method Summary collapse
- #exist? ⇒ Boolean
- #fetch(str) ⇒ Object
-
#initialize(filename, env) ⇒ Archive
constructor
A new instance of Archive.
- #installer_dir ⇒ Object
- #source_uri(base_uri) ⇒ Object
- #to_s ⇒ Object
- #unpack_to(fs_dir) ⇒ Object
Methods included from Idempotent
Constructor Details
#initialize(filename, env) ⇒ Archive
Returns a new instance of Archive.
43 44 45 46 47 48 49 50 |
# File 'lib/pe_build/archive.rb', line 43 def initialize(filename, env) @filename = filename @env = env @archive_dir = PEBuild.archive_directory(@env) @logger = Log4r::Logger.new('vagrant::pe_build::archive') end |
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
39 40 41 |
# File 'lib/pe_build/archive.rb', line 39 def env @env end |
#filename ⇒ String
Returns The filename. Thing.
37 38 39 |
# File 'lib/pe_build/archive.rb', line 37 def filename @filename end |
#series ⇒ String
Returns The release series of PE. Completely optional and
currently has no effect other than being an interpolation token
available for use in download_root
.
33 34 35 |
# File 'lib/pe_build/archive.rb', line 33 def series @series end |
#version ⇒ String
Returns The version of Puppet Enterprise.
28 29 30 |
# File 'lib/pe_build/archive.rb', line 28 def version @version end |
Instance Method Details
#exist? ⇒ Boolean
89 90 91 |
# File 'lib/pe_build/archive.rb', line 89 def exist? File.exist? archive_path end |
#fetch(str) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/pe_build/archive.rb', line 53 def fetch(str) return if self.exist? if str.nil? @env.ui.error "Cannot fetch installer #{versioned_path @filename}; no download source available." @env.ui.error "" @env.ui.error "Installers available for use:" collection = PEBuild::ArchiveCollection.new(@archive_dir, @env) collection.display raise PEBuild::ArchiveNoInstallerSource, :filename => versioned_path(@filename) end uri = source_uri(str) dst = File.join(@archive_dir, versioned_path(@filename)) PEBuild::Transfer.copy(uri, dst) end |
#installer_dir ⇒ Object
102 103 104 |
# File 'lib/pe_build/archive.rb', line 102 def installer_dir versioned_path(@filename).gsub(/.tar(?:\.gz)?/, '') end |
#source_uri(base_uri) ⇒ Object
98 99 100 |
# File 'lib/pe_build/archive.rb', line 98 def source_uri(base_uri) URI.parse(versioned_path("#{base_uri.to_s}/#{@filename}")) end |
#to_s ⇒ Object
93 94 95 |
# File 'lib/pe_build/archive.rb', line 93 def to_s versioned_path(@filename) end |
#unpack_to(fs_dir) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/pe_build/archive.rb', line 74 def unpack_to(fs_dir) unless exist? raise PEBuild::ArchiveMissing, :filename => @filename end archive = PEBuild::Unpack.generate(archive_path, fs_dir) begin idempotent(archive.creates, "Unpacked archive #{versioned_path filename}") do archive.unpack end rescue Zlib::GzipFile::Error => e raise PEBuild::ArchiveUnreadable, :filename => @filename, :message => e. end end |