Class: Bosh::Cli::Versions::LocalVersionStorage
- Inherits:
-
Object
- Object
- Bosh::Cli::Versions::LocalVersionStorage
show all
- Defined in:
- lib/cli/versions/local_version_storage.rb
Defined Under Namespace
Classes: Sha1MismatchError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(storage_dir, name_prefix = nil) ⇒ LocalVersionStorage
Returns a new instance of LocalVersionStorage.
8
9
10
11
|
# File 'lib/cli/versions/local_version_storage.rb', line 8
def initialize(storage_dir, name_prefix=nil)
@storage_dir = storage_dir
@name_prefix = name_prefix
end
|
Instance Attribute Details
#storage_dir ⇒ Object
Returns the value of attribute storage_dir.
6
7
8
|
# File 'lib/cli/versions/local_version_storage.rb', line 6
def storage_dir
@storage_dir
end
|
Instance Method Details
#file_path(version) ⇒ Object
36
37
38
39
|
# File 'lib/cli/versions/local_version_storage.rb', line 36
def file_path(version)
name = @name_prefix.blank? ? "#{version}.tgz" : "#{@name_prefix}-#{version}.tgz"
File.join(@storage_dir, name)
end
|
#get_file(version) ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/cli/versions/local_version_storage.rb', line 23
def get_file(version)
destination = file_path(version)
unless File.exist?(destination)
raise "Trying to retrieve non-existant file `#{destination}' for version `#{version}'"
end
File.expand_path(destination)
end
|
#has_file?(version) ⇒ Boolean
32
33
34
|
# File 'lib/cli/versions/local_version_storage.rb', line 32
def has_file?(version)
File.exists?(file_path(version))
end
|
#put_file(version, src_file_path) ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/cli/versions/local_version_storage.rb', line 13
def put_file(version, src_file_path)
destination = file_path(version)
unless File.exist?(src_file_path)
raise "Trying to store non-existant file `#{src_file_path}' for version `#{version}'"
end
FileUtils.cp(src_file_path, destination, :preserve => true)
File.expand_path(destination)
end
|