Class: Bruh::Core

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

Overview

Main entry point for the Bruh library

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Core

Initialize with configuration



18
19
20
# File 'lib/bruh.rb', line 18

def initialize(config = {})
  @config = config
end

Instance Method Details

#release(version = nil, options = {}) ⇒ Object

Release a new version



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/bruh.rb', line 23

def release(version = nil, options = {})
  # This is a wrapper around the CLI functionality
  # Useful for programmatic access
  current_dir = Dir.pwd

  # Find cabal file
  cabal_file = find_cabal_file(current_dir)
  return false unless cabal_file

  cabal = Cabal.new(cabal_file)
  current_version = cabal.version

  # Determine new version
  new_version = version || increment_version(current_version)

  # Update version in cabal file
  cabal.update_version(new_version)

  # Update changelog
  if File.exist?('CHANGELOG.md')
    interactive = options.fetch(:interactive, true)
    Changelog.update(new_version, current_dir, interactive: interactive)
  end

  # Handle the rest of the release process based on options
  true
end