Class: RightPublish::Profile
- Inherits:
-
Object
- Object
- RightPublish::Profile
- Includes:
- Singleton
- Defined in:
- lib/right_publish/profile.rb
Constant Summary collapse
- USER_PROFILE_DIR =
Location where per-user profiles are stored
File.('~/.right_publish/profiles')
- DEFAULT_VERBOSE =
false
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Class Method Summary collapse
Instance Method Summary collapse
-
#load(path) ⇒ true
Load a YML profile from disk.
- #register_section(section_key, section_options) ⇒ Object
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
10 11 12 |
# File 'lib/right_publish/profile.rb', line 10 def settings @settings end |
Class Method Details
.config ⇒ Object
13 14 15 |
# File 'lib/right_publish/profile.rb', line 13 def self.config() return Profile.instance.settings end |
.log(s, level = :info) ⇒ Object
17 18 19 |
# File 'lib/right_publish/profile.rb', line 17 def self.log(s, level=:info) puts(s) if Profile.config[:verbose] || level != :debug end |
Instance Method Details
#load(path) ⇒ true
Load a YML profile from disk. Profiles can be identified by their path on disk, or by the name of a YML file located in USER_PROFILE_DIR (without YML extension).
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/right_publish/profile.rb', line 34 def load(path) if File.exists?(path) @settings ||= Profile.symbolize_profile(YAML.load_file(path)) validate_profile elsif (path = File.join(USER_PROFILE_DIR, "#{path}.yml")) && File.exists?(path) @settings ||= Profile.symbolize_profile(YAML.load_file(path)) validate_profile else raise LoadError, "Missing profile '#{path}'" end true rescue LoadError raise rescue Exception => e raise LoadError, "Cannot load profile '#{path}' - #{e}" end |
#register_section(section_key, section_options) ⇒ Object
52 53 54 55 |
# File 'lib/right_publish/profile.rb', line 52 def register_section(section_key, ) @config_map ||= {} @config_map[section_key] ||= end |