Class: Bonchi::GlobalConfig
- Inherits:
-
Object
- Object
- Bonchi::GlobalConfig
- Defined in:
- lib/bonchi/global_config.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ GlobalConfig
constructor
A new instance of GlobalConfig.
- #worktree_root ⇒ Object
Constructor Details
#initialize ⇒ GlobalConfig
Returns a new instance of GlobalConfig.
6 7 8 9 10 11 12 13 |
# File 'lib/bonchi/global_config.rb', line 6 def initialize @path = self.class.config_path @data = if File.exist?(@path) YAML.safe_load_file(@path) || {} else {} end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
15 16 17 |
# File 'lib/bonchi/global_config.rb', line 15 def data @data end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
15 16 17 |
# File 'lib/bonchi/global_config.rb', line 15 def path @path end |
Class Method Details
.config_path ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bonchi/global_config.rb', line 23 def self.config_path xdg = ENV["XDG_CONFIG_HOME"] if xdg && !xdg.empty? dir = File.join(xdg, "bonchi") FileUtils.mkdir_p(dir) File.join(dir, "config.yml") else File.("~/.bonchi.yml") end end |
Instance Method Details
#worktree_root ⇒ Object
17 18 19 20 21 |
# File 'lib/bonchi/global_config.rb', line 17 def worktree_root ENV.fetch("WORKTREE_ROOT") { @data["worktree_root"] || File.join(Dir.home, "dev", "worktrees") } end |