class Bog::Profile
Constants
- UNWANTED_ENTRIES
Attributes
configurations[RW]
path[R]
profile_name[R]
Public Class Methods
current()
click to toggle source
# File lib/bog/profile.rb, line 45 def self.current Bog::Profile.find(File.basename(File.readlink(File.expand_path('~/.bog/current')))) end
find(profile)
click to toggle source
# File lib/bog/profile.rb, line 22 def self.find(profile) if Dir.entries(File.expand_path('~/.bog/profiles')).include?(profile.to_s) return Bog::Profile.load(profile) else raise Bog::Profile::Exception::ProfileNotFound end end
load(profile)
click to toggle source
# File lib/bog/profile.rb, line 30 def self.load(profile) configurations = Dir.entries(profile_root(profile)).delete_if {|e| Bog::Profile::UNWANTED_ENTRIES.include?(e)} return Bog::Profile.new({:configurations => configurations, :profile_name => profile, :path => profile_root(profile)}) end
new(options)
click to toggle source
# File lib/bog/profile.rb, line 11 def initialize(options) @configurations = options[:configurations] @profile_name = options[:profile_name] @path = options[:path] end
switch_to(profile)
click to toggle source
# File lib/bog/profile.rb, line 17 def self.switch_to(profile) target_profile = self.find(profile) target_profile.make_current end
Private Class Methods
profile_root(profile)
click to toggle source
# File lib/bog/profile.rb, line 55 def self.profile_root(profile) return Pathname.new(File.expand_path("~/.bog/profiles/#{profile.to_s}")) end
Public Instance Methods
make_current()
click to toggle source
# File lib/bog/profile.rb, line 35 def make_current current_status_file = File.expand_path('~/.bog/current') symlink(profile_root, current_status_file,) end
make_default()
click to toggle source
# File lib/bog/profile.rb, line 40 def make_default puts "Making #{self.profile_name} default profile" File.write(File.expand_path('~/.bog/default'), self.profile_name) end
Private Instance Methods
profile_root()
click to toggle source
# File lib/bog/profile.rb, line 51 def profile_root return Pathname.new(File.expand_path("~/.bog/profiles/#{@profile_name.to_s}")) end
symlink(target, linkfile)
click to toggle source
# File lib/bog/profile.rb, line 59 def symlink(target, linkfile) File.unlink(linkfile) if File.exists?(linkfile) File.symlink(target, linkfile) end