Class: Puppet::FileBucket::File::StringContents

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/file_bucket/file.rb

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ StringContents

Returns a new instance of StringContents.



106
107
108
# File 'lib/puppet/file_bucket/file.rb', line 106

def initialize(content)
  @contents = content;
end

Instance Method Details

#checksum_data(base_method) ⇒ Object



123
124
125
126
# File 'lib/puppet/file_bucket/file.rb', line 123

def checksum_data(base_method)
  Puppet.info("Computing checksum on string")
  Puppet::Util::Checksums.method(base_method).call(@contents)
end

#sizeObject



119
120
121
# File 'lib/puppet/file_bucket/file.rb', line 119

def size
  @contents.size
end

#stream(&block) ⇒ Object



110
111
112
113
114
115
116
117
# File 'lib/puppet/file_bucket/file.rb', line 110

def stream(&block)
  s = StringIO.new(@contents)
  begin
    block.call(s)
  ensure
    s.close
  end
end

#to_sObject



128
129
130
131
132
# File 'lib/puppet/file_bucket/file.rb', line 128

def to_s
  # This is not so horrible as for FileContent, but still possible to mutate the content that the
  # checksum is based on... so semi horrible...
  return @contents;
end