Class: Pj::Config
- Inherits:
-
Object
- Object
- Pj::Config
- Defined in:
- lib/pj/config.rb
Class Method Summary collapse
Instance Method Summary collapse
- #config_file_name ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load_config ⇒ Object
- #projects ⇒ Object
- #repo_dir(name) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
19 20 21 |
# File 'lib/pj/config.rb', line 19 def initialize @config = load_config end |
Class Method Details
.instance ⇒ Object
6 7 8 |
# File 'lib/pj/config.rb', line 6 def instance @instance ||= new end |
.projects ⇒ Object
14 15 16 |
# File 'lib/pj/config.rb', line 14 def projects instance.projects end |
.repo_dir(name) ⇒ Object
10 11 12 |
# File 'lib/pj/config.rb', line 10 def repo_dir(name) instance.repo_dir name end |
Instance Method Details
#config_file_name ⇒ Object
37 38 39 |
# File 'lib/pj/config.rb', line 37 def config_file_name File.join ENV["HOME"], "pj.json" end |
#load_config ⇒ Object
33 34 35 |
# File 'lib/pj/config.rb', line 33 def load_config JSON.load(File.read(config_file_name)) end |
#projects ⇒ Object
29 30 31 |
# File 'lib/pj/config.rb', line 29 def projects @config["repository"].keys end |
#repo_dir(name) ⇒ Object
23 24 25 26 27 |
# File 'lib/pj/config.rb', line 23 def repo_dir(name) return nil unless @config.key?("repository") repo = @config["repository"].fetch(name, nil) File. repo end |