Teckel::Operation::Resultrailway methods no longer capture block into variable- Internal housekeeping
- Add ruby 4.0 to CI
- Allow bundler 4 in development
- Internal housekeeping
- Add ruby 3.4 and 'head' to CI
- Ruby < 3 won't run mutation test
- moved to standard.rb for linting and formatting
- removed usage of
forwardablein favor of explicit delegation methods - renamed internal
Teckel::Config.fortoget_or_set - renamed internal
Teckel::Operation::Config.get_set_constructortoget_or_set_constructor - fixed specs that test backtrace outputs on ruby 3.4
- Documentation now uses modern (Ruby 3.4) output syntax. (
{foo: 1}is now printed as is, instead of{:foo => 1}
-
Add mutation testing (currently about 80% covered)
-
Breaking:
Teckel::Operation::Resultno longer converts thesuccessfulvalue to a boolean. When using the default result implementation, nothing changes for you. When you manually pass anything else into it,succesful?will return this value. Thefailureandsuccessmethods work on the "Truthy" value ofsuccessfulresult = Result.new(some_value, 42) result.successful? # => 42
-
Change:
freezeing anOperationorChainwill also freeze their internal config (input, output, steps, etc.)
Internal:
- Some refactoring to cover mutations
- Extracted creating the runable
Operationinstance into a new, publicrunable(settings = UNDEFINED)method. Mainly to reduce code duplication but this also makes testing, stubbing and mocking easier.
- Breaking:
Teckel::Chainwill not be required by default. require manually if neededrequire "teckel/chain"[GH-24] - Breaking: Internally,
Teckel::Operation::Runnerinstead of:successand:failurenow only uses:haltas it's throw-catch symbol. [GH-26] - Add: Using the default
Teckel::Operation::Runner,input_constructorandresult_constructorwill be executed within the context of the operation instance. This allows forinput_constructorto callfail!andsuccess!without evercalling the operation. [GH-26]
- Breaking: Operations return values will be ignored. [GH-21]
- You'll need to use
success!orfailure! success!andfailure!are now implemented on theRunner, which makes it easier to change their behavior (including the one above).
- You'll need to use
-
Fix: calling chain with settings and no input [GH-14]
-
Add: Default settings for Operation and Chains [GH-17], [GH-18]
class MyOperation include Teckel::Operation settings Struct.new(:logger) # If your settings class can cope with no input and you want to make sure # `settings` gets initialized and set. # settings will be #<struct logger=nil> default_settings! # settings will be #<struct logger=MyGlobalLogger> default_settings!(MyGlobalLogger) # settings will be #<struct logger=#<Logger:<...>> default_settings! -> { settings.new(Logger.new("/tmp/my.log")) } end class Chain include Teckel::Chain # set or overwrite operation settings default_settings!(a: MyOtherLogger) step :a, MyOperation end
Internal:
- Move operation and chain config dsl methods into own module [GH-15]
- Code simplifications [GH-16]
-
Moving verbose examples from API docs into github pages
-
#finalize!no longer freezes the entire Operation or Chain class, only it's settings. [GH-13] -
Add simple support for using Base classes. [GH-10] Removes global configuration
Teckel::Config.default_constructorclass ApplicationOperation include Teckel::Operation # you won't be able to overwrite any configuration in child classes, # so take care which you want to declare result! settings Struct.new(:logger) input_constructor :new error Struct.new(:status, :messages) def log(message) return unless settings&.logger logger << message end # you cannot call `finalize!` on partially declared Operations end
-
Add support for setting your own Result objects. [GH-9]
- They should include and implement
Teckel::Resultwhich is needed byChain. Chain::StepFailuregot replaced withChain::Result.- the
Teckel::Operation::Resultsmodule was removed. To let Operation use the default Result object, use the new helperresult!instead.
- They should include and implement
-
Add "settings"/dependency injection to Operation and Chains. [GH-7]
MyOperation.with(logger: STDOUT).call(params) MyChain.with(some_step: { logger: STDOUT }).call(params)
-
[GH-5] Add support for ruby 2.7 pattern matching on Operation and Chain results. Both, array and hash notations are supported:
case MyOperation.call(params) in [false, value] # handle failure in [true, value] # handle success end case MyChain.call(params) in { success: false, step: :foo, value: value } # handle foo failure in [success: false, step: :bar, value: value } # handle bar failure in { success: true, value: value } # handle success end
-
Fix setting a config twice to raise an error
finalize!'ing a Chain will also finalize all it's Operations- Changed attribute naming of
StepFailure:.operationwill now give the operation class of the step - was.stepbefore.stepwill now give the name of the step (which Operation failed) - was.step_namebefore
- Around Hooks for Chains
finalize!- freezing Chains and Operations, to prevent further changes
- Operations check their config and raise if any is missing
- Initial release