Class: Olib::App

Inherits:
Object
  • Object
show all
Defined in:
lib/Olib/storage/app_data.rb

Constant Summary collapse

FOLDER =
".olib"
APP_DIR =
File.join Dir.home, FOLDER

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.app_file(path) ⇒ Object


12
13
14
# File 'lib/Olib/storage/app_data.rb', line 12

def self.app_file(path)
  File.join APP_DIR, path
end

.open(file) ⇒ Object


16
17
18
# File 'lib/Olib/storage/app_data.rb', line 16

def self.open(file)
  File.open(app_file(file), 'a', &block)
end

.read(file, &block) ⇒ Object


26
27
28
29
30
# File 'lib/Olib/storage/app_data.rb', line 26

def self.read(file, &block)
  open(file) do |file|
    yield
  end
end

.write_json(file, data) ⇒ Object


20
21
22
23
24
# File 'lib/Olib/storage/app_data.rb', line 20

def self.write_json(file, data)
  open(file) do |f|
    JSON.dump(data)
  end
end

Instance Method Details

#APP_DIRObject

setup app dir


10
# File 'lib/Olib/storage/app_data.rb', line 10

FileUtils.mkdir_p APP_DIR