Class: Yomikomu::FlatFileStorage

Inherits:
BasicStorage show all
Defined in:
lib/yomikomu.rb

Direct Known Subclasses

FlatFileGZStorage

Instance Method Summary collapse

Methods inherited from BasicStorage

#compile_and_store_iseq, #extra_data, #load_iseq

Constructor Details

#initializeFlatFileStorage

Returns a new instance of FlatFileStorage.



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/yomikomu.rb', line 276

def initialize
  super
  require 'fileutils'

  @updated = false

  if File.exist?(index_path)
    open(index_path, 'rb'){|f| @index = Marshal.load(f)}
  else
    @index = {}
    open(data_path, 'w'){} # touch
  end

  @data_file = open(data_path, 'a+b')

  at_exit{
    if @updated
      open(index_path, 'wb'){|f| Marshal.dump(@index, f)}
      Yomikomu.info{'FlatFile: update'}
    end
  }
end

Instance Method Details

#data_pathObject



272
273
274
# File 'lib/yomikomu.rb', line 272

def data_path
  Yomikomu.prefix + 'ff_data'
end

#index_pathObject



268
269
270
# File 'lib/yomikomu.rb', line 268

def index_path
  Yomikomu.prefix + 'ff_index'
end

#remove_compiled_iseq(fname) ⇒ Object



299
300
301
# File 'lib/yomikomu.rb', line 299

def remove_compiled_iseq fname
  raise 'unsupported'
end