Class: Shaf::Upgrade::Package
- Inherits:
-
Object
- Object
- Shaf::Upgrade::Package
show all
- Includes:
- Comparable
- Defined in:
- lib/shaf/upgrade/package.rb
Defined Under Namespace
Classes: BadChecksumError, ManifestNotFoundError, MissingFileError, UpgradeError, VersionConflictError, VersionNotFoundError
Constant Summary
collapse
- UPGRADE_FILES_PATH =
File.join(Utils.gem_root, 'upgrades').freeze
- MANIFEST_FILENAME =
'manifest'.freeze
- IGNORE_FILE_PATTERNS =
[/.rej\z/, /.orig\z/]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(version, manifest = nil, files = {}) ⇒ Package
Returns a new instance of Package.
59
60
61
62
63
|
# File 'lib/shaf/upgrade/package.rb', line 59
def initialize(version, manifest = nil, files = {})
@version = Version.new(version)
@manifest = manifest
@files = files
end
|
Instance Attribute Details
#manifest ⇒ Object
Returns the value of attribute manifest.
57
58
59
|
# File 'lib/shaf/upgrade/package.rb', line 57
def manifest
@manifest
end
|
#version ⇒ Object
Returns the value of attribute version.
57
58
59
|
# File 'lib/shaf/upgrade/package.rb', line 57
def version
@version
end
|
Class Method Details
.all ⇒ Object
30
31
32
|
# File 'lib/shaf/upgrade/package.rb', line 30
def all
target_versions.map(&method(:new))
end
|
.load(version) ⇒ Object
34
35
36
37
38
|
# File 'lib/shaf/upgrade/package.rb', line 34
def load(version)
v = strip_suffix(version)
raise VersionNotFoundError unless target_versions.include? v
new(v).tap(&:load)
end
|
Instance Method Details
#<=>(other) ⇒ Object
77
78
79
80
|
# File 'lib/shaf/upgrade/package.rb', line 77
def <=>(other)
version = other.is_a?(String) ? other : other.version
@version <=> version
end
|
#apply(dir = nil) ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/shaf/upgrade/package.rb', line 82
def apply(dir = nil)
puts "\n ## Applying changes for Shaf version: #{version} ##"
FT.transaction do
result = [
apply_patches(dir),
apply_drops(dir),
apply_additions,
apply_substitutes(dir),
print_messages,
]
raise UpgradeError, 'Upgrade failed' unless result.all?
end
true
end
|
#load ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/shaf/upgrade/package.rb', line 65
def load
File.open(tarball, 'rb') do |file|
Zlib::GzipReader.wrap(file) do |gz|
Gem::Package::TarReader.new(gz) do |tar|
tar.each(&method(:add_tar_entry))
end
end
end
validate
self
end
|
#to_s ⇒ Object
99
100
101
102
103
|
# File 'lib/shaf/upgrade/package.rb', line 99
def to_s
str = "Shaf::Upgrade::Package for version #{version}"
return str if manifest.nil?
"#{str} (#{manifest.stats_str})"
end
|