Sha256: 3a31810ef8d542d125a949ba73e96fcec5fed84d80e9f19078d48893e865a322

Contents?: true

Size: 523 Bytes

Versions: 9

Compression:

Stored size: 523 Bytes

Contents

module Morale
  module Storage
    
    attr_accessor :location
    
    def delete
      FileUtils.rm_f(location)
    end
    
    def read
      File.exists?(location) and File.read(location)
    end
    
    def write(data)
      FileUtils.mkdir_p(File.dirname(location))
      f = File.open(location, 'w')
      f.puts data
      f.close
      set_permissions
    end
    
    private
    
    def set_permissions
      FileUtils.chmod 0700, File.dirname(location)
      FileUtils.chmod 0600, location
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
morale-client-1.0.3 lib/morale/storage.rb
morale-client-1.0.2 lib/morale/storage.rb
morale-client-1.0.1 lib/morale/storage.rb
morale-client-1.0.0 lib/morale/storage.rb
morale-client-0.0.1 lib/morale/storage.rb
morale-1.0.0 lib/morale/storage.rb
morale-0.1.3 lib/morale/storage.rb
morale-0.1.2 lib/morale/storage.rb
morale-0.1.1 lib/morale/storage.rb