Class: Reissue::FragmentHandler
- Inherits:
-
Object
- Object
- Reissue::FragmentHandler
- 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
Direct Known Subclasses
DirectoryFragmentHandler, GitFragmentHandler, NullFragmentHandler
Defined Under Namespace
Classes: GitFragmentHandler
Class Method Summary collapse
-
.for(fragment_option, valid_sections: nil, tag_pattern: nil) ⇒ FragmentHandler
Factory method to create the appropriate handler for the given option.
Instance Method Summary collapse
-
#clear ⇒ Object
Clear fragments from the configured source.
-
#read ⇒ Hash
Read fragments from the configured source.
Class Method Details
.for(fragment_option, valid_sections: nil, tag_pattern: nil) ⇒ FragmentHandler
Factory method to create the appropriate handler for the given option
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" = {} [:valid_sections] = valid_sections if valid_sections DirectoryFragmentHandler.new(fragment_option, **) 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
#clear ⇒ Object
Clear fragments from the configured source
17 18 19 |
# File 'lib/reissue/fragment_handler.rb', line 17 def clear raise NotImplementedError, "Subclasses must implement #clear" end |
#read ⇒ Hash
Read fragments from the configured source
10 11 12 |
# File 'lib/reissue/fragment_handler.rb', line 10 def read raise NotImplementedError, "Subclasses must implement #read" end |