Class: JennCad::ProfileLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/jenncad/profile_loader.rb

Instance Method Summary collapse

Constructor Details

#initializeProfileLoader

Returns a new instance of ProfileLoader.



3
4
5
# File 'lib/jenncad/profile_loader.rb', line 3

def initialize
  load_profile
end

Instance Method Details

#check_profileObject



24
25
26
27
28
# File 'lib/jenncad/profile_loader.rb', line 24

def check_profile
  unless defined?($jenncad_profile)
    load_defaults
  end
end

#load_defaultsObject



30
31
32
# File 'lib/jenncad/profile_loader.rb', line 30

def load_defaults
  $jenncad_profile = JennCad::DefaultProfile.new
end

#load_profileObject



15
16
17
18
19
20
21
22
# File 'lib/jenncad/profile_loader.rb', line 15

def load_profile
  if File.exists?(profile_path)
    require profile_path
    check_profile
  else
    load_defaults
  end
end

#profile_dirObject



7
8
9
# File 'lib/jenncad/profile_loader.rb', line 7

def profile_dir
  File.expand_path(["~", ".config", "jenncad"].join("/"))
end

#profile_pathObject



11
12
13
# File 'lib/jenncad/profile_loader.rb', line 11

def profile_path
  [profile_dir, "profile.rb"].join("/")
end