Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../opt/alt/ruby22/lib64/ruby/2.2.0
File: pstore.rb
# = PStore -- Transactional File Storage for Ruby Objects
[0] Fix | Delete
#
[1] Fix | Delete
# pstore.rb -
[2] Fix | Delete
# originally by matz
[3] Fix | Delete
# documentation by Kev Jackson and James Edward Gray II
[4] Fix | Delete
# improved by Hongli Lai
[5] Fix | Delete
#
[6] Fix | Delete
# See PStore for documentation.
[7] Fix | Delete
[8] Fix | Delete
require "digest/md5"
[9] Fix | Delete
[10] Fix | Delete
#
[11] Fix | Delete
# PStore implements a file based persistence mechanism based on a Hash. User
[12] Fix | Delete
# code can store hierarchies of Ruby objects (values) into the data store file
[13] Fix | Delete
# by name (keys). An object hierarchy may be just a single object. User code
[14] Fix | Delete
# may later read values back from the data store or even update data, as needed.
[15] Fix | Delete
#
[16] Fix | Delete
# The transactional behavior ensures that any changes succeed or fail together.
[17] Fix | Delete
# This can be used to ensure that the data store is not left in a transitory
[18] Fix | Delete
# state, where some values were updated but others were not.
[19] Fix | Delete
#
[20] Fix | Delete
# Behind the scenes, Ruby objects are stored to the data store file with
[21] Fix | Delete
# Marshal. That carries the usual limitations. Proc objects cannot be
[22] Fix | Delete
# marshalled, for example.
[23] Fix | Delete
#
[24] Fix | Delete
# == Usage example:
[25] Fix | Delete
#
[26] Fix | Delete
# require "pstore"
[27] Fix | Delete
#
[28] Fix | Delete
# # a mock wiki object...
[29] Fix | Delete
# class WikiPage
[30] Fix | Delete
# def initialize( page_name, author, contents )
[31] Fix | Delete
# @page_name = page_name
[32] Fix | Delete
# @revisions = Array.new
[33] Fix | Delete
#
[34] Fix | Delete
# add_revision(author, contents)
[35] Fix | Delete
# end
[36] Fix | Delete
#
[37] Fix | Delete
# attr_reader :page_name
[38] Fix | Delete
#
[39] Fix | Delete
# def add_revision( author, contents )
[40] Fix | Delete
# @revisions << { :created => Time.now,
[41] Fix | Delete
# :author => author,
[42] Fix | Delete
# :contents => contents }
[43] Fix | Delete
# end
[44] Fix | Delete
#
[45] Fix | Delete
# def wiki_page_references
[46] Fix | Delete
# [@page_name] + @revisions.last[:contents].scan(/\b(?:[A-Z]+[a-z]+){2,}/)
[47] Fix | Delete
# end
[48] Fix | Delete
#
[49] Fix | Delete
# # ...
[50] Fix | Delete
# end
[51] Fix | Delete
#
[52] Fix | Delete
# # create a new page...
[53] Fix | Delete
# home_page = WikiPage.new( "HomePage", "James Edward Gray II",
[54] Fix | Delete
# "A page about the JoysOfDocumentation..." )
[55] Fix | Delete
#
[56] Fix | Delete
# # then we want to update page data and the index together, or not at all...
[57] Fix | Delete
# wiki = PStore.new("wiki_pages.pstore")
[58] Fix | Delete
# wiki.transaction do # begin transaction; do all of this or none of it
[59] Fix | Delete
# # store page...
[60] Fix | Delete
# wiki[home_page.page_name] = home_page
[61] Fix | Delete
# # ensure that an index has been created...
[62] Fix | Delete
# wiki[:wiki_index] ||= Array.new
[63] Fix | Delete
# # update wiki index...
[64] Fix | Delete
# wiki[:wiki_index].push(*home_page.wiki_page_references)
[65] Fix | Delete
# end # commit changes to wiki data store file
[66] Fix | Delete
#
[67] Fix | Delete
# ### Some time later... ###
[68] Fix | Delete
#
[69] Fix | Delete
# # read wiki data...
[70] Fix | Delete
# wiki.transaction(true) do # begin read-only transaction, no changes allowed
[71] Fix | Delete
# wiki.roots.each do |data_root_name|
[72] Fix | Delete
# p data_root_name
[73] Fix | Delete
# p wiki[data_root_name]
[74] Fix | Delete
# end
[75] Fix | Delete
# end
[76] Fix | Delete
#
[77] Fix | Delete
# == Transaction modes
[78] Fix | Delete
#
[79] Fix | Delete
# By default, file integrity is only ensured as long as the operating system
[80] Fix | Delete
# (and the underlying hardware) doesn't raise any unexpected I/O errors. If an
[81] Fix | Delete
# I/O error occurs while PStore is writing to its file, then the file will
[82] Fix | Delete
# become corrupted.
[83] Fix | Delete
#
[84] Fix | Delete
# You can prevent this by setting <em>pstore.ultra_safe = true</em>.
[85] Fix | Delete
# However, this results in a minor performance loss, and only works on platforms
[86] Fix | Delete
# that support atomic file renames. Please consult the documentation for
[87] Fix | Delete
# +ultra_safe+ for details.
[88] Fix | Delete
#
[89] Fix | Delete
# Needless to say, if you're storing valuable data with PStore, then you should
[90] Fix | Delete
# backup the PStore files from time to time.
[91] Fix | Delete
class PStore
[92] Fix | Delete
RDWR_ACCESS = {mode: IO::RDWR | IO::CREAT | IO::BINARY, encoding: Encoding::ASCII_8BIT}.freeze
[93] Fix | Delete
RD_ACCESS = {mode: IO::RDONLY | IO::BINARY, encoding: Encoding::ASCII_8BIT}.freeze
[94] Fix | Delete
WR_ACCESS = {mode: IO::WRONLY | IO::CREAT | IO::TRUNC | IO::BINARY, encoding: Encoding::ASCII_8BIT}.freeze
[95] Fix | Delete
[96] Fix | Delete
# The error type thrown by all PStore methods.
[97] Fix | Delete
class Error < StandardError
[98] Fix | Delete
end
[99] Fix | Delete
[100] Fix | Delete
# Whether PStore should do its best to prevent file corruptions, even when under
[101] Fix | Delete
# unlikely-to-occur error conditions such as out-of-space conditions and other
[102] Fix | Delete
# unusual OS filesystem errors. Setting this flag comes at the price in the form
[103] Fix | Delete
# of a performance loss.
[104] Fix | Delete
#
[105] Fix | Delete
# This flag only has effect on platforms on which file renames are atomic (e.g.
[106] Fix | Delete
# all POSIX platforms: Linux, MacOS X, FreeBSD, etc). The default value is false.
[107] Fix | Delete
attr_accessor :ultra_safe
[108] Fix | Delete
[109] Fix | Delete
#
[110] Fix | Delete
# To construct a PStore object, pass in the _file_ path where you would like
[111] Fix | Delete
# the data to be stored.
[112] Fix | Delete
#
[113] Fix | Delete
# PStore objects are always reentrant. But if _thread_safe_ is set to true,
[114] Fix | Delete
# then it will become thread-safe at the cost of a minor performance hit.
[115] Fix | Delete
#
[116] Fix | Delete
def initialize(file, thread_safe = false)
[117] Fix | Delete
dir = File::dirname(file)
[118] Fix | Delete
unless File::directory? dir
[119] Fix | Delete
raise PStore::Error, format("directory %s does not exist", dir)
[120] Fix | Delete
end
[121] Fix | Delete
if File::exist? file and not File::readable? file
[122] Fix | Delete
raise PStore::Error, format("file %s not readable", file)
[123] Fix | Delete
end
[124] Fix | Delete
@filename = file
[125] Fix | Delete
@abort = false
[126] Fix | Delete
@ultra_safe = false
[127] Fix | Delete
@thread_safe = thread_safe
[128] Fix | Delete
@lock = Mutex.new
[129] Fix | Delete
end
[130] Fix | Delete
[131] Fix | Delete
# Raises PStore::Error if the calling code is not in a PStore#transaction.
[132] Fix | Delete
def in_transaction
[133] Fix | Delete
raise PStore::Error, "not in transaction" unless @lock.locked?
[134] Fix | Delete
end
[135] Fix | Delete
#
[136] Fix | Delete
# Raises PStore::Error if the calling code is not in a PStore#transaction or
[137] Fix | Delete
# if the code is in a read-only PStore#transaction.
[138] Fix | Delete
#
[139] Fix | Delete
def in_transaction_wr
[140] Fix | Delete
in_transaction
[141] Fix | Delete
raise PStore::Error, "in read-only transaction" if @rdonly
[142] Fix | Delete
end
[143] Fix | Delete
private :in_transaction, :in_transaction_wr
[144] Fix | Delete
[145] Fix | Delete
#
[146] Fix | Delete
# Retrieves a value from the PStore file data, by _name_. The hierarchy of
[147] Fix | Delete
# Ruby objects stored under that root _name_ will be returned.
[148] Fix | Delete
#
[149] Fix | Delete
# *WARNING*: This method is only valid in a PStore#transaction. It will
[150] Fix | Delete
# raise PStore::Error if called at any other time.
[151] Fix | Delete
#
[152] Fix | Delete
def [](name)
[153] Fix | Delete
in_transaction
[154] Fix | Delete
@table[name]
[155] Fix | Delete
end
[156] Fix | Delete
#
[157] Fix | Delete
# This method is just like PStore#[], save that you may also provide a
[158] Fix | Delete
# _default_ value for the object. In the event the specified _name_ is not
[159] Fix | Delete
# found in the data store, your _default_ will be returned instead. If you do
[160] Fix | Delete
# not specify a default, PStore::Error will be raised if the object is not
[161] Fix | Delete
# found.
[162] Fix | Delete
#
[163] Fix | Delete
# *WARNING*: This method is only valid in a PStore#transaction. It will
[164] Fix | Delete
# raise PStore::Error if called at any other time.
[165] Fix | Delete
#
[166] Fix | Delete
def fetch(name, default=PStore::Error)
[167] Fix | Delete
in_transaction
[168] Fix | Delete
unless @table.key? name
[169] Fix | Delete
if default == PStore::Error
[170] Fix | Delete
raise PStore::Error, format("undefined root name `%s'", name)
[171] Fix | Delete
else
[172] Fix | Delete
return default
[173] Fix | Delete
end
[174] Fix | Delete
end
[175] Fix | Delete
@table[name]
[176] Fix | Delete
end
[177] Fix | Delete
#
[178] Fix | Delete
# Stores an individual Ruby object or a hierarchy of Ruby objects in the data
[179] Fix | Delete
# store file under the root _name_. Assigning to a _name_ already in the data
[180] Fix | Delete
# store clobbers the old data.
[181] Fix | Delete
#
[182] Fix | Delete
# == Example:
[183] Fix | Delete
#
[184] Fix | Delete
# require "pstore"
[185] Fix | Delete
#
[186] Fix | Delete
# store = PStore.new("data_file.pstore")
[187] Fix | Delete
# store.transaction do # begin transaction
[188] Fix | Delete
# # load some data into the store...
[189] Fix | Delete
# store[:single_object] = "My data..."
[190] Fix | Delete
# store[:obj_heirarchy] = { "Kev Jackson" => ["rational.rb", "pstore.rb"],
[191] Fix | Delete
# "James Gray" => ["erb.rb", "pstore.rb"] }
[192] Fix | Delete
# end # commit changes to data store file
[193] Fix | Delete
#
[194] Fix | Delete
# *WARNING*: This method is only valid in a PStore#transaction and it cannot
[195] Fix | Delete
# be read-only. It will raise PStore::Error if called at any other time.
[196] Fix | Delete
#
[197] Fix | Delete
def []=(name, value)
[198] Fix | Delete
in_transaction_wr
[199] Fix | Delete
@table[name] = value
[200] Fix | Delete
end
[201] Fix | Delete
#
[202] Fix | Delete
# Removes an object hierarchy from the data store, by _name_.
[203] Fix | Delete
#
[204] Fix | Delete
# *WARNING*: This method is only valid in a PStore#transaction and it cannot
[205] Fix | Delete
# be read-only. It will raise PStore::Error if called at any other time.
[206] Fix | Delete
#
[207] Fix | Delete
def delete(name)
[208] Fix | Delete
in_transaction_wr
[209] Fix | Delete
@table.delete name
[210] Fix | Delete
end
[211] Fix | Delete
[212] Fix | Delete
#
[213] Fix | Delete
# Returns the names of all object hierarchies currently in the store.
[214] Fix | Delete
#
[215] Fix | Delete
# *WARNING*: This method is only valid in a PStore#transaction. It will
[216] Fix | Delete
# raise PStore::Error if called at any other time.
[217] Fix | Delete
#
[218] Fix | Delete
def roots
[219] Fix | Delete
in_transaction
[220] Fix | Delete
@table.keys
[221] Fix | Delete
end
[222] Fix | Delete
#
[223] Fix | Delete
# Returns true if the supplied _name_ is currently in the data store.
[224] Fix | Delete
#
[225] Fix | Delete
# *WARNING*: This method is only valid in a PStore#transaction. It will
[226] Fix | Delete
# raise PStore::Error if called at any other time.
[227] Fix | Delete
#
[228] Fix | Delete
def root?(name)
[229] Fix | Delete
in_transaction
[230] Fix | Delete
@table.key? name
[231] Fix | Delete
end
[232] Fix | Delete
# Returns the path to the data store file.
[233] Fix | Delete
def path
[234] Fix | Delete
@filename
[235] Fix | Delete
end
[236] Fix | Delete
[237] Fix | Delete
#
[238] Fix | Delete
# Ends the current PStore#transaction, committing any changes to the data
[239] Fix | Delete
# store immediately.
[240] Fix | Delete
#
[241] Fix | Delete
# == Example:
[242] Fix | Delete
#
[243] Fix | Delete
# require "pstore"
[244] Fix | Delete
#
[245] Fix | Delete
# store = PStore.new("data_file.pstore")
[246] Fix | Delete
# store.transaction do # begin transaction
[247] Fix | Delete
# # load some data into the store...
[248] Fix | Delete
# store[:one] = 1
[249] Fix | Delete
# store[:two] = 2
[250] Fix | Delete
#
[251] Fix | Delete
# store.commit # end transaction here, committing changes
[252] Fix | Delete
#
[253] Fix | Delete
# store[:three] = 3 # this change is never reached
[254] Fix | Delete
# end
[255] Fix | Delete
#
[256] Fix | Delete
# *WARNING*: This method is only valid in a PStore#transaction. It will
[257] Fix | Delete
# raise PStore::Error if called at any other time.
[258] Fix | Delete
#
[259] Fix | Delete
def commit
[260] Fix | Delete
in_transaction
[261] Fix | Delete
@abort = false
[262] Fix | Delete
throw :pstore_abort_transaction
[263] Fix | Delete
end
[264] Fix | Delete
#
[265] Fix | Delete
# Ends the current PStore#transaction, discarding any changes to the data
[266] Fix | Delete
# store.
[267] Fix | Delete
#
[268] Fix | Delete
# == Example:
[269] Fix | Delete
#
[270] Fix | Delete
# require "pstore"
[271] Fix | Delete
#
[272] Fix | Delete
# store = PStore.new("data_file.pstore")
[273] Fix | Delete
# store.transaction do # begin transaction
[274] Fix | Delete
# store[:one] = 1 # this change is not applied, see below...
[275] Fix | Delete
# store[:two] = 2 # this change is not applied, see below...
[276] Fix | Delete
#
[277] Fix | Delete
# store.abort # end transaction here, discard all changes
[278] Fix | Delete
#
[279] Fix | Delete
# store[:three] = 3 # this change is never reached
[280] Fix | Delete
# end
[281] Fix | Delete
#
[282] Fix | Delete
# *WARNING*: This method is only valid in a PStore#transaction. It will
[283] Fix | Delete
# raise PStore::Error if called at any other time.
[284] Fix | Delete
#
[285] Fix | Delete
def abort
[286] Fix | Delete
in_transaction
[287] Fix | Delete
@abort = true
[288] Fix | Delete
throw :pstore_abort_transaction
[289] Fix | Delete
end
[290] Fix | Delete
[291] Fix | Delete
#
[292] Fix | Delete
# Opens a new transaction for the data store. Code executed inside a block
[293] Fix | Delete
# passed to this method may read and write data to and from the data store
[294] Fix | Delete
# file.
[295] Fix | Delete
#
[296] Fix | Delete
# At the end of the block, changes are committed to the data store
[297] Fix | Delete
# automatically. You may exit the transaction early with a call to either
[298] Fix | Delete
# PStore#commit or PStore#abort. See those methods for details about how
[299] Fix | Delete
# changes are handled. Raising an uncaught Exception in the block is
[300] Fix | Delete
# equivalent to calling PStore#abort.
[301] Fix | Delete
#
[302] Fix | Delete
# If _read_only_ is set to +true+, you will only be allowed to read from the
[303] Fix | Delete
# data store during the transaction and any attempts to change the data will
[304] Fix | Delete
# raise a PStore::Error.
[305] Fix | Delete
#
[306] Fix | Delete
# Note that PStore does not support nested transactions.
[307] Fix | Delete
#
[308] Fix | Delete
def transaction(read_only = false) # :yields: pstore
[309] Fix | Delete
value = nil
[310] Fix | Delete
if !@thread_safe
[311] Fix | Delete
raise PStore::Error, "nested transaction" unless @lock.try_lock
[312] Fix | Delete
else
[313] Fix | Delete
begin
[314] Fix | Delete
@lock.lock
[315] Fix | Delete
rescue ThreadError
[316] Fix | Delete
raise PStore::Error, "nested transaction"
[317] Fix | Delete
end
[318] Fix | Delete
end
[319] Fix | Delete
begin
[320] Fix | Delete
@rdonly = read_only
[321] Fix | Delete
@abort = false
[322] Fix | Delete
file = open_and_lock_file(@filename, read_only)
[323] Fix | Delete
if file
[324] Fix | Delete
begin
[325] Fix | Delete
@table, checksum, original_data_size = load_data(file, read_only)
[326] Fix | Delete
[327] Fix | Delete
catch(:pstore_abort_transaction) do
[328] Fix | Delete
value = yield(self)
[329] Fix | Delete
end
[330] Fix | Delete
[331] Fix | Delete
if !@abort && !read_only
[332] Fix | Delete
save_data(checksum, original_data_size, file)
[333] Fix | Delete
end
[334] Fix | Delete
ensure
[335] Fix | Delete
file.close if !file.closed?
[336] Fix | Delete
end
[337] Fix | Delete
else
[338] Fix | Delete
# This can only occur if read_only == true.
[339] Fix | Delete
@table = {}
[340] Fix | Delete
catch(:pstore_abort_transaction) do
[341] Fix | Delete
value = yield(self)
[342] Fix | Delete
end
[343] Fix | Delete
end
[344] Fix | Delete
ensure
[345] Fix | Delete
@lock.unlock
[346] Fix | Delete
end
[347] Fix | Delete
value
[348] Fix | Delete
end
[349] Fix | Delete
[350] Fix | Delete
private
[351] Fix | Delete
# Constant for relieving Ruby's garbage collector.
[352] Fix | Delete
EMPTY_STRING = ""
[353] Fix | Delete
EMPTY_MARSHAL_DATA = Marshal.dump({})
[354] Fix | Delete
EMPTY_MARSHAL_CHECKSUM = Digest::MD5.digest(EMPTY_MARSHAL_DATA)
[355] Fix | Delete
[356] Fix | Delete
#
[357] Fix | Delete
# Open the specified filename (either in read-only mode or in
[358] Fix | Delete
# read-write mode) and lock it for reading or writing.
[359] Fix | Delete
#
[360] Fix | Delete
# The opened File object will be returned. If _read_only_ is true,
[361] Fix | Delete
# and the file does not exist, then nil will be returned.
[362] Fix | Delete
#
[363] Fix | Delete
# All exceptions are propagated.
[364] Fix | Delete
#
[365] Fix | Delete
def open_and_lock_file(filename, read_only)
[366] Fix | Delete
if read_only
[367] Fix | Delete
begin
[368] Fix | Delete
file = File.new(filename, RD_ACCESS)
[369] Fix | Delete
begin
[370] Fix | Delete
file.flock(File::LOCK_SH)
[371] Fix | Delete
return file
[372] Fix | Delete
rescue
[373] Fix | Delete
file.close
[374] Fix | Delete
raise
[375] Fix | Delete
end
[376] Fix | Delete
rescue Errno::ENOENT
[377] Fix | Delete
return nil
[378] Fix | Delete
end
[379] Fix | Delete
else
[380] Fix | Delete
file = File.new(filename, RDWR_ACCESS)
[381] Fix | Delete
file.flock(File::LOCK_EX)
[382] Fix | Delete
return file
[383] Fix | Delete
end
[384] Fix | Delete
end
[385] Fix | Delete
[386] Fix | Delete
# Load the given PStore file.
[387] Fix | Delete
# If +read_only+ is true, the unmarshalled Hash will be returned.
[388] Fix | Delete
# If +read_only+ is false, a 3-tuple will be returned: the unmarshalled
[389] Fix | Delete
# Hash, an MD5 checksum of the data, and the size of the data.
[390] Fix | Delete
def load_data(file, read_only)
[391] Fix | Delete
if read_only
[392] Fix | Delete
begin
[393] Fix | Delete
table = load(file)
[394] Fix | Delete
raise Error, "PStore file seems to be corrupted." unless table.is_a?(Hash)
[395] Fix | Delete
rescue EOFError
[396] Fix | Delete
# This seems to be a newly-created file.
[397] Fix | Delete
table = {}
[398] Fix | Delete
end
[399] Fix | Delete
table
[400] Fix | Delete
else
[401] Fix | Delete
data = file.read
[402] Fix | Delete
if data.empty?
[403] Fix | Delete
# This seems to be a newly-created file.
[404] Fix | Delete
table = {}
[405] Fix | Delete
checksum = empty_marshal_checksum
[406] Fix | Delete
size = empty_marshal_data.bytesize
[407] Fix | Delete
else
[408] Fix | Delete
table = load(data)
[409] Fix | Delete
checksum = Digest::MD5.digest(data)
[410] Fix | Delete
size = data.bytesize
[411] Fix | Delete
raise Error, "PStore file seems to be corrupted." unless table.is_a?(Hash)
[412] Fix | Delete
end
[413] Fix | Delete
data.replace(EMPTY_STRING)
[414] Fix | Delete
[table, checksum, size]
[415] Fix | Delete
end
[416] Fix | Delete
end
[417] Fix | Delete
[418] Fix | Delete
def on_windows?
[419] Fix | Delete
is_windows = RUBY_PLATFORM =~ /mswin|mingw|bccwin|wince/
[420] Fix | Delete
self.class.__send__(:define_method, :on_windows?) do
[421] Fix | Delete
is_windows
[422] Fix | Delete
end
[423] Fix | Delete
is_windows
[424] Fix | Delete
end
[425] Fix | Delete
[426] Fix | Delete
def save_data(original_checksum, original_file_size, file)
[427] Fix | Delete
new_data = dump(@table)
[428] Fix | Delete
[429] Fix | Delete
if new_data.bytesize != original_file_size || Digest::MD5.digest(new_data) != original_checksum
[430] Fix | Delete
if @ultra_safe && !on_windows?
[431] Fix | Delete
# Windows doesn't support atomic file renames.
[432] Fix | Delete
save_data_with_atomic_file_rename_strategy(new_data, file)
[433] Fix | Delete
else
[434] Fix | Delete
save_data_with_fast_strategy(new_data, file)
[435] Fix | Delete
end
[436] Fix | Delete
end
[437] Fix | Delete
[438] Fix | Delete
new_data.replace(EMPTY_STRING)
[439] Fix | Delete
end
[440] Fix | Delete
[441] Fix | Delete
def save_data_with_atomic_file_rename_strategy(data, file)
[442] Fix | Delete
temp_filename = "#{@filename}.tmp.#{Process.pid}.#{rand 1000000}"
[443] Fix | Delete
temp_file = File.new(temp_filename, WR_ACCESS)
[444] Fix | Delete
begin
[445] Fix | Delete
temp_file.flock(File::LOCK_EX)
[446] Fix | Delete
temp_file.write(data)
[447] Fix | Delete
temp_file.flush
[448] Fix | Delete
File.rename(temp_filename, @filename)
[449] Fix | Delete
rescue
[450] Fix | Delete
File.unlink(temp_file) rescue nil
[451] Fix | Delete
raise
[452] Fix | Delete
ensure
[453] Fix | Delete
temp_file.close
[454] Fix | Delete
end
[455] Fix | Delete
end
[456] Fix | Delete
[457] Fix | Delete
def save_data_with_fast_strategy(data, file)
[458] Fix | Delete
file.rewind
[459] Fix | Delete
file.write(data)
[460] Fix | Delete
file.truncate(data.bytesize)
[461] Fix | Delete
end
[462] Fix | Delete
[463] Fix | Delete
[464] Fix | Delete
# This method is just a wrapped around Marshal.dump
[465] Fix | Delete
# to allow subclass overriding used in YAML::Store.
[466] Fix | Delete
def dump(table) # :nodoc:
[467] Fix | Delete
Marshal::dump(table)
[468] Fix | Delete
end
[469] Fix | Delete
[470] Fix | Delete
# This method is just a wrapped around Marshal.load.
[471] Fix | Delete
# to allow subclass overriding used in YAML::Store.
[472] Fix | Delete
def load(content) # :nodoc:
[473] Fix | Delete
Marshal::load(content)
[474] Fix | Delete
end
[475] Fix | Delete
[476] Fix | Delete
def empty_marshal_data
[477] Fix | Delete
EMPTY_MARSHAL_DATA
[478] Fix | Delete
end
[479] Fix | Delete
def empty_marshal_checksum
[480] Fix | Delete
EMPTY_MARSHAL_CHECKSUM
[481] Fix | Delete
end
[482] Fix | Delete
end
[483] Fix | Delete
[484] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function