Class: ConfigRC::RcFileProvider
- Inherits:
-
BaseProvider
- Object
- BaseProvider
- ConfigRC::RcFileProvider
- Defined in:
- lib/config-rc/rc_file.rb
Overview
Configuration stored in a file
Instance Method Summary collapse
-
#initialize(prefix) ⇒ RcFileProvider
constructor
A new instance of RcFileProvider.
- #map ⇒ Object
Methods inherited from BaseProvider
Constructor Details
#initialize(prefix) ⇒ RcFileProvider
Returns a new instance of RcFileProvider.
6 7 8 |
# File 'lib/config-rc/rc_file.rb', line 6 def initialize(prefix) @path = File.(File.join('~', ".#{prefix}rc")) end |
Instance Method Details
#map ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/config-rc/rc_file.rb', line 10 def map props = {} File.open(@path).select{|line| not line =~ /^[ \t]*(#.+)*$/}.each do |line| k, v = line.chomp.split('=', 2) props[k] = v end if File.exist?(@path) props end |