Sha256: 769df0318170b169e8587ff8d9a5a184565b1cf7eb4821281f66d2dfa21c232d

Contents?: true

Size: 527 Bytes

Versions: 9

Compression:

Stored size: 527 Bytes

Contents

module MTX
  class InputCache
    class << self
      def put(key, content)
        File.open(file_pathname(key), File::CREAT | File::WRONLY | File::TRUNC) { |file| file.write content }
      end
    
      def get(key)
        if content = File.read(file_pathname(key))
          return nil if content.blank?
          content
        end
      rescue
        nil
      end
    
      protected
    
      def file_pathname(key)
        File.join(Dir::tmpdir, "#{key.to_s.gsub(/[^\w]/, '')}.entry")
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
schubert-minglr-1.3.0 lib/minglr/mtx/input_cache.rb
schubert-minglr-1.3.1 lib/minglr/mtx/input_cache.rb
schubert-minglr-1.3.11 lib/minglr/mtx/input_cache.rb
schubert-minglr-1.3.2 lib/minglr/mtx/input_cache.rb
schubert-minglr-1.3.3 lib/minglr/mtx/input_cache.rb
schubert-minglr-1.3.5 lib/minglr/mtx/input_cache.rb
schubert-minglr-1.3.8 lib/minglr/mtx/input_cache.rb
schubert-minglr-1.3.9 lib/minglr/mtx/input_cache.rb
minglr-1.3.11 lib/minglr/mtx/input_cache.rb