Class: Reissue::FragmentHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/reissue/fragment_handler.rb,
lib/reissue/fragment_handler/git_fragment_handler.rb

Overview

Base class for handling fragment reading from various sources

Defined Under Namespace

Classes: GitFragmentHandler

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for(fragment_option, valid_sections: nil, tag_pattern: nil) ⇒ FragmentHandler

Factory method to create the appropriate handler for the given option

Parameters:

  • fragment_option (nil, String, Symbol)

    The fragment configuration

  • valid_sections (Array<String>, nil) (defaults to: nil)

    List of valid section names (for directory handler)

  • tag_pattern (Regexp, nil) (defaults to: nil)

    Optional regex pattern for matching version tags (for git handler)

Returns:

Raises:

  • (ArgumentError)

    If the option is not supported



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/reissue/fragment_handler.rb', line 28

def self.for(fragment_option, valid_sections: nil, tag_pattern: nil)
  case fragment_option
  when nil
    require_relative "fragment_handler/null_fragment_handler"
    NullFragmentHandler.new
  when String
    require_relative "fragment_handler/directory_fragment_handler"
    options = {}
    options[:valid_sections] = valid_sections if valid_sections
    DirectoryFragmentHandler.new(fragment_option, **options)
  when :git
    require_relative "fragment_handler/git_fragment_handler"
    GitFragmentHandler.new(tag_pattern: tag_pattern)
  else
    raise ArgumentError, "Invalid fragment option: #{fragment_option.inspect}"
  end
end

Instance Method Details

#clearObject

Clear fragments from the configured source

Raises:

  • (NotImplementedError)

    Must be implemented by subclasses



17
18
19
# File 'lib/reissue/fragment_handler.rb', line 17

def clear
  raise NotImplementedError, "Subclasses must implement #clear"
end

#readHash

Read fragments from the configured source

Returns:

  • (Hash)

    A hash of changelog entries organized by category

Raises:

  • (NotImplementedError)

    Must be implemented by subclasses



10
11
12
# File 'lib/reissue/fragment_handler.rb', line 10

def read
  raise NotImplementedError, "Subclasses must implement #read"
end