Class: Cline::Config
- Inherits:
-
Object
- Object
- Cline::Config
- Extended by:
- Forwardable
- Includes:
- Serializable::Dir
- Defined in:
- lib/cline/config.rb
Overview
Accesses all configuration of a Cline directory. Wraps for example the content of ~/.cline. The following properties can be used while opening a Config directory:
- include_project_config [Boolean] Do we include the project-specific objects as well in this
configuration? Defaults to
true.
Instance Attribute Summary
Attributes included from Serializable::Dir
Public API collapse
-
.global ⇒ Config
Get the global Cline config.
-
.main ⇒ Config
Get the main Cline config.
-
.project ⇒ Config
Get the project Cline config.
-
#==(other) ⇒ Boolean
Equality check.
-
#cli(**kwargs) ⇒ Cli
Return a Cli instance that uses this config.
-
#data(create: self.create) ⇒ Data
Get the data directory from this config.
-
#refresh! ⇒ Object
Refresh caches to reload data from disk.
-
#skills(create: self.create) ⇒ OverlayHash?
Get skills from this config.
Internal collapse
-
#initialize(include_project_config: true) ⇒ Config
constructor
Constructor.
Methods included from Serializable::Dir
included, #initialize_from_dir, #subpath
Constructor Details
#initialize(include_project_config: true) ⇒ Config
Constructor
89 90 91 |
# File 'lib/cline/config.rb', line 89 def initialize(include_project_config: true) @include_project_config = include_project_config end |
Class Method Details
.global ⇒ Config
Get the global Cline config
25 26 27 |
# File 'lib/cline/config.rb', line 25 def self.global @global ||= Config.open("#{Utils::Os.user_home_dir}/.cline", include_project_config: false) end |
Instance Method Details
#==(other) ⇒ Boolean
Equality check
64 65 66 67 68 |
# File 'lib/cline/config.rb', line 64 def ==(other) other.is_a?(Config) && other.skills == skills && other.data == data end |
#cli(**kwargs) ⇒ Cli
Return a Cli instance that uses this config
74 75 76 |
# File 'lib/cline/config.rb', line 74 def cli(**kwargs) Cli.new(config: dir, **kwargs) end |
#data(create: self.create) ⇒ Data
Get the data directory from this config
56 57 58 |
# File 'lib/cline/config.rb', line 56 def data(create: self.create) @data ||= Data.open(subpath('data'), create:) end |
#refresh! ⇒ Object
Refresh caches to reload data from disk.
79 80 81 82 |
# File 'lib/cline/config.rb', line 79 def refresh! @skills = nil @data = nil end |
#skills(create: self.create) ⇒ OverlayHash?
Get skills from this config
45 46 47 48 49 50 |
# File 'lib/cline/config.rb', line 45 def skills(create: self.create) @skills ||= begin skills_layers = ([Skills.open(subpath('skills'), create:)] + [project_config&.skills]).compact skills_layers.empty? ? nil : OverlayHash.new(*skills_layers) end end |