Module: Noteman::Config
- Included in:
- Display, Note, NoteManager
- Defined in:
- lib/noteman/config.rb
Constant Summary collapse
- CONFIG_NAME =
".notemanrc"
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/noteman/config.rb', line 8 def config @config end |
Instance Method Details
#home_config ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/noteman/config.rb', line 31 def home_config if Dir.respond_to?('home') File.join(Dir.home, CONFIG_NAME) else File.join(File.("~"), CONFIG_NAME) end end |
#read_from_file ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/noteman/config.rb', line 39 def read_from_file c = {} dir = Dir.pwd while(dir != '/') if File.exists? File.join(dir, CONFIG_NAME) c = YAML.load_file(File.join(dir, CONFIG_NAME)).deep_merge!(c) end dir = File.dirname(dir) end if c.empty? && File.exists?(home_config) c = YAML.load_file(home_config) end c end |