Class: Puppet::FileBucket::File
Defined Under Namespace
Modules: IndirectionHooks
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Indirector
indirects
Constructor Details
#initialize(contents, options = {}) ⇒ File
Returns a new instance of File.
17
18
19
20
21
22
23
|
# File 'lib/puppet/file_bucket/file.rb', line 17
def initialize( contents, options = {} )
raise ArgumentError if !contents.is_a?(String)
@contents = contents
@bucket_path = options.delete(:bucket_path)
raise ArgumentError if options != {}
end
|
Instance Attribute Details
#bucket_path ⇒ Object
Returns the value of attribute bucket_path.
15
16
17
|
# File 'lib/puppet/file_bucket/file.rb', line 15
def bucket_path
@bucket_path
end
|
Returns the value of attribute contents.
14
15
16
|
# File 'lib/puppet/file_bucket/file.rb', line 14
def contents
@contents
end
|
Class Method Details
.from_pson(pson) ⇒ Object
53
54
55
|
# File 'lib/puppet/file_bucket/file.rb', line 53
def self.from_pson( pson )
self.new( pson["contents"] )
end
|
.from_s(contents) ⇒ Object
45
46
47
|
# File 'lib/puppet/file_bucket/file.rb', line 45
def self.from_s( contents )
self.new( contents )
end
|
Instance Method Details
29
30
31
|
# File 'lib/puppet/file_bucket/file.rb', line 29
def checksum
"{#{checksum_type}}#{checksum_data}"
end
|
#checksum_data ⇒ Object
33
34
35
|
# File 'lib/puppet/file_bucket/file.rb', line 33
def checksum_data
@checksum_data ||= Digest::MD5.hexdigest(contents)
end
|
#checksum_type ⇒ Object
25
26
27
|
# File 'lib/puppet/file_bucket/file.rb', line 25
def checksum_type
'md5'
end
|
41
42
43
|
# File 'lib/puppet/file_bucket/file.rb', line 41
def name
"#{checksum_type}/#{checksum_data}"
end
|
49
50
51
|
# File 'lib/puppet/file_bucket/file.rb', line 49
def to_pson
{ "contents" => contents }.to_pson
end
|
37
38
39
|
# File 'lib/puppet/file_bucket/file.rb', line 37
def to_s
contents
end
|