Class: Workbush::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/workbush/config.rb

Overview

Handles loading and parsing .workbush.yml configuration files

Constant Summary collapse

DEFAULT_CONFIG_NAME =
".workbush.yml"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path: nil) ⇒ Config

Initialize a new Config instance

Parameters:

  • config_path (String, nil) (defaults to: nil)

    Optional path to config file



17
18
19
20
# File 'lib/workbush/config.rb', line 17

def initialize(config_path: nil)
  @config_path = config_path || find_config_file
  load_config
end

Instance Attribute Details

#copy_directoriesObject (readonly)

Returns the value of attribute copy_directories.



12
13
14
# File 'lib/workbush/config.rb', line 12

def copy_directories
  @copy_directories
end

#copy_filesObject (readonly)

Returns the value of attribute copy_files.



12
13
14
# File 'lib/workbush/config.rb', line 12

def copy_files
  @copy_files
end

#copy_patternsObject (readonly)

Returns the value of attribute copy_patterns.



12
13
14
# File 'lib/workbush/config.rb', line 12

def copy_patterns
  @copy_patterns
end

#post_create_commandsObject (readonly)

Returns the value of attribute post_create_commands.



12
13
14
# File 'lib/workbush/config.rb', line 12

def post_create_commands
  @post_create_commands
end

Class Method Details

.default_templateString

Generate a default configuration template

Returns:

  • (String)

    YAML template content



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/workbush/config.rb', line 32

def self.default_template
  <<~YAML
    # Files to copy (exact paths relative to worktree root)
    copy_files:
      - .env
      - .env.local
      - mise.local.toml
      - config/database.yml

    # Glob patterns for copying multiple files
    copy_patterns:
      - ".env.*"
      - "*.lock"

    # Directories to copy
    copy_directories:
      - node_modules
      - vendor/bundle

    # Commands to run after worktree creation
    post_create_commands:
      - mise trust
      - bundle install
      - yarn install
  YAML
end

Instance Method Details

#config_exists?Boolean

Check if a configuration file was found

Returns:

  • (Boolean)


25
26
27
# File 'lib/workbush/config.rb', line 25

def config_exists?
  !@config_path.nil? && File.exist?(@config_path)
end