Class: Puppet::FileBucket::File
Constant Summary
Constants included
from Indirector
Indirector::BadNameRegexp
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Indirector
configure_routes, indirects
Constructor Details
#initialize(contents, options = {}) ⇒ File
Returns a new instance of File.
16
17
18
19
20
21
22
|
# File 'lib/vendor/puppet/file_bucket/file.rb', line 16
def initialize(contents, options = {})
raise ArgumentError.new("contents must be a String, got a #{contents.class}") unless contents.is_a?(String)
@contents = contents
@bucket_path = options.delete(:bucket_path)
raise ArgumentError.new("Unknown option(s): #{options.keys.join(', ')}") unless options.empty?
end
|
Instance Attribute Details
#bucket_path ⇒ Object
Returns the value of attribute bucket_path.
14
15
16
|
# File 'lib/vendor/puppet/file_bucket/file.rb', line 14
def bucket_path
@bucket_path
end
|
Returns the value of attribute contents.
13
14
15
|
# File 'lib/vendor/puppet/file_bucket/file.rb', line 13
def contents
@contents
end
|
Class Method Details
.from_pson(pson) ⇒ Object
52
53
54
|
# File 'lib/vendor/puppet/file_bucket/file.rb', line 52
def self.from_pson(pson)
self.new(pson["contents"])
end
|
.from_s(contents) ⇒ Object
44
45
46
|
# File 'lib/vendor/puppet/file_bucket/file.rb', line 44
def self.from_s(contents)
self.new(contents)
end
|
Instance Method Details
28
29
30
|
# File 'lib/vendor/puppet/file_bucket/file.rb', line 28
def checksum
"{#{checksum_type}}#{checksum_data}"
end
|
#checksum_data ⇒ Object
32
33
34
|
# File 'lib/vendor/puppet/file_bucket/file.rb', line 32
def checksum_data
@checksum_data ||= Digest::MD5.hexdigest(contents)
end
|
#checksum_type ⇒ Object
24
25
26
|
# File 'lib/vendor/puppet/file_bucket/file.rb', line 24
def checksum_type
'md5'
end
|
40
41
42
|
# File 'lib/vendor/puppet/file_bucket/file.rb', line 40
def name
"#{checksum_type}/#{checksum_data}"
end
|
48
49
50
|
# File 'lib/vendor/puppet/file_bucket/file.rb', line 48
def to_pson
{ "contents" => contents }.to_pson
end
|
36
37
38
|
# File 'lib/vendor/puppet/file_bucket/file.rb', line 36
def to_s
contents
end
|