Sha256: 10e2f1e70cec4341cf4d9b2c9dc8e6bfc194209fd8ab73d00bf3e67a4e45fdf4

Contents?: true

Size: 840 Bytes

Versions: 1

Compression:

Stored size: 840 Bytes

Contents

require 'service.rb'

class PermaspaceApp<Service
  provides :permaspace
  def initialize(cluster,options)
    super(cluster,options,:permaspace)
  end
  def store(name,what)
    mid=id(name)
    if name!=""
      f=File.open(File.join(getAppDataWritePath,mid),"w")

      f.print what
      f.close
      return true
    end
    false
  end
  def load(name)
    mid=id(name)
    if mid!=""
      getAppDataPaths.each{|path|
        fname=File.join(path,mid)
        if File.exists?(fname)
          f=File.open(fname)
          what=f.read
          f.close
          return what
        end
      }
    end
    nil
  end
  
  def rm(name)
    mid=id(name)
    fname=File.join(getAppDataWritePath,mid)
    if File.exists?(fname)
      File.rm_f(fname)
    end
  end
  
  private 
  def id(name)
    name.gsub(/[^a-zA-Z0-9_]/,'')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appswarm-0.0.1 apps/permaspace/permaspace.rb