Class: Bonchi::Config
Constant Summary collapse
- KNOWN_KEYS =
%w[copy ports replace pre_setup setup].freeze
Instance Attribute Summary collapse
-
#copy ⇒ Object
readonly
Returns the value of attribute copy.
-
#ports ⇒ Object
readonly
Returns the value of attribute ports.
-
#pre_setup ⇒ Object
readonly
Returns the value of attribute pre_setup.
-
#replace ⇒ Object
readonly
Returns the value of attribute replace.
-
#setup ⇒ Object
readonly
Returns the value of attribute setup.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(path) ⇒ Config
Returns a new instance of Config.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bonchi/config.rb', line 11 def initialize(path) data = YAML.load_file(path) unknown = data.keys - KNOWN_KEYS unknown.each { |k| warn "#{color(:yellow)}Warning:#{reset} unknown key '#{k}' in .worktree.yml, ignoring" } @copy = Array(data["copy"]) @ports = Array(data["ports"]) @replace = data["replace"] || {} @pre_setup = Array(data["pre_setup"]) @setup = data["setup"] || "bin/setup" validate! end |
Instance Attribute Details
#copy ⇒ Object (readonly)
Returns the value of attribute copy.
9 10 11 |
# File 'lib/bonchi/config.rb', line 9 def copy @copy end |
#ports ⇒ Object (readonly)
Returns the value of attribute ports.
9 10 11 |
# File 'lib/bonchi/config.rb', line 9 def ports @ports end |
#pre_setup ⇒ Object (readonly)
Returns the value of attribute pre_setup.
9 10 11 |
# File 'lib/bonchi/config.rb', line 9 def pre_setup @pre_setup end |
#replace ⇒ Object (readonly)
Returns the value of attribute replace.
9 10 11 |
# File 'lib/bonchi/config.rb', line 9 def replace @replace end |
#setup ⇒ Object (readonly)
Returns the value of attribute setup.
9 10 11 |
# File 'lib/bonchi/config.rb', line 9 def setup @setup end |
Class Method Details
.from_main_worktree ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/bonchi/config.rb', line 26 def self.from_main_worktree main = Git.main_worktree path = File.join(main, ".worktree.yml") return nil unless File.exist?(path) new(path) end |