# File lib/puppet/file_bucket/file.rb, line 52 def self.from_pson(pson) self.new(pson["contents"]) end
# File lib/puppet/file_bucket/file.rb, line 44 def self.from_s(contents) self.new(contents) end
# File lib/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
# File lib/puppet/file_bucket/file.rb, line 28 def checksum "{#{checksum_type}}#{checksum_data}" end
# File lib/puppet/file_bucket/file.rb, line 32 def checksum_data @checksum_data ||= Digest::MD5.hexdigest(contents) end
# File lib/puppet/file_bucket/file.rb, line 24 def checksum_type 'md5' end
# File lib/puppet/file_bucket/file.rb, line 40 def name "#{checksum_type}/#{checksum_data}" end
# File lib/puppet/file_bucket/file.rb, line 48 def to_pson { "contents" => contents }.to_pson end
# File lib/puppet/file_bucket/file.rb, line 36 def to_s contents end