Class: Ruku::Storage

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

Direct Known Subclasses

SimpleStorage, YAMLStorage

Constant Summary collapse

FILE_NAME =
'.ruku-boxes'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ Storage

Returns a new instance of Storage.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ruku/storage.rb', line 6

def initialize(path=nil)
  @storage_path = path
  if not @storage_path
    home = ENV['HOME']
    home = ENV['USERPROFILE'] if not home
    if !home && (ENV['HOMEDRIVE'] && ENV['HOMEPATH'])
      home = File.join(ENV['HOMEDRIVE'], ENV['HOMEPATH'])
    end
    home = File.expand_path('~') if not home
    home = 'C:/' if !home && RUBY_PLATFORM =~ /mswin|mingw/

    raise "Could not find user HOME directory" if not home

    @storage_path = File.join(home, FILE_NAME)
  end
end

Instance Attribute Details

#storage_pathObject

Returns the value of attribute storage_path.



4
5
6
# File 'lib/ruku/storage.rb', line 4

def storage_path
  @storage_path
end