Class: Bog::Profile
- Inherits:
-
Object
- Object
- Bog::Profile
- Defined in:
- lib/bog/profile.rb,
lib/bog/profile/exception.rb
Defined Under Namespace
Classes: Exception
Constant Summary collapse
- UNWANTED_ENTRIES =
%w( . .. )
Instance Attribute Summary collapse
-
#configurations ⇒ Object
Returns the value of attribute configurations.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#profile_name ⇒ Object
readonly
Returns the value of attribute profile_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ Profile
constructor
A new instance of Profile.
- #make_current ⇒ Object
Constructor Details
#initialize(options) ⇒ Profile
Returns a new instance of Profile.
11 12 13 14 15 |
# File 'lib/bog/profile.rb', line 11 def initialize() @configurations = [:configurations] @profile_name = [:profile_name] @path = [:path] end |
Instance Attribute Details
#configurations ⇒ Object
Returns the value of attribute configurations.
6 7 8 |
# File 'lib/bog/profile.rb', line 6 def configurations @configurations end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/bog/profile.rb', line 7 def path @path end |
#profile_name ⇒ Object (readonly)
Returns the value of attribute profile_name.
7 8 9 |
# File 'lib/bog/profile.rb', line 7 def profile_name @profile_name end |
Class Method Details
.find(profile) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/bog/profile.rb', line 22 def self.find(profile) if Dir.entries(File.('~/.bog/profiles')).include?(profile.to_s) return Bog::Profile.load(profile) else raise Bog::Profile::Exception::ProfileNotFound end end |
.load(profile) ⇒ Object
30 31 32 33 |
# 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 |
.switch_to(profile) ⇒ Object
17 18 19 20 |
# File 'lib/bog/profile.rb', line 17 def self.switch_to(profile) target_profile = self.find(profile) target_profile.make_current end |
Instance Method Details
#make_current ⇒ Object
35 36 37 38 |
# File 'lib/bog/profile.rb', line 35 def make_current current_status_file = File.('~/.bog/current') symlink(profile_root, current_status_file,) end |