Class: Changit::ConfigReader
- Inherits:
-
Object
- Object
- Changit::ConfigReader
- Defined in:
- lib/changit/config_reader.rb
Constant Summary collapse
- DEFAULT_SEARCH_PATH =
"#{Dir.pwd}/.gitconfig".freeze
Instance Attribute Summary collapse
-
#search_path ⇒ Object
readonly
Returns the value of attribute search_path.
Instance Method Summary collapse
-
#initialize(search_path: DEFAULT_SEARCH_PATH) ⇒ ConfigReader
constructor
A new instance of ConfigReader.
- #read ⇒ Object
Constructor Details
#initialize(search_path: DEFAULT_SEARCH_PATH) ⇒ ConfigReader
Returns a new instance of ConfigReader.
7 8 9 10 11 |
# File 'lib/changit/config_reader.rb', line 7 def initialize(search_path: DEFAULT_SEARCH_PATH) @search_path = search_path freeze end |
Instance Attribute Details
#search_path ⇒ Object (readonly)
Returns the value of attribute search_path.
5 6 7 |
# File 'lib/changit/config_reader.rb', line 5 def search_path @search_path end |
Instance Method Details
#read ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/changit/config_reader.rb', line 13 def read search_result = Dir.glob(@search_path) if search_result.empty? fail "File #{@search_path} not found." else File.read(search_result.first) end end |