Releases: yippee-fun/literal
1.8.1
Highlights
Just a quick non-breaking change to show prop type signatures in Ruby LSP hover and auto-complete cards. Enjoy!
PRs
- Show prop type signature in Ruby LSP by @joeldrapper in #330
Full Changelog: 1.8.0...1.8.1
1.8.0
Highlights
- New RubyLSP indexing enhancement allows RubyLSP to auto-complete instance variables based on property definitions.
Literal::DataandLiteral::Structnow supportto_hash- Improved generation of predicate names from
Literal::Enummember constant names - The default proc on properties is now evaluated in the context of the new instance being initialised
- The
_JSONDatatype now takes parameters to limit the type, e.g._JSONData(Array) _Notcan now take multiple parameters and then wraps a union of those parameters, e.g._Not(_Union(*your_types))- A new type
_Patterntakes a regular expression and a block which is yielded the capture params as positional arguments and the named captures as keyword arguments. The type matches if the regular expression matches and the block returns truthy. - A new type
_Unit(T)matches if the value is exactly the same object as theTparameter. - Minor performance improvements
PRs
- feat: Better predicates support for SCREAMING_ENUM by @ixti in #317
- Allow defaults to reference methods inside class by @rickychilcott in #320
- fix: Align defaults with generated code by @ixti in #319
- feat: Make data structs implicitly Hash coercible by @ixti in #318
- Implements
#reversein Literal::Array by @hslzr in #297 - Implements
#reverse!in Literal::Array by @hslzr in #298 - Ruby LSP extension by @joeldrapper in #323
New Contributors
- @rickychilcott made their first contribution in #320
Full Changelog: 1.7.1...1.8.0
1.7.1
Highlights
Quick fix for a bug related to our migration to Zeitwerk.
What's Changed
- Fix Rails loading bug by @joeldrapper in #313
Full Changelog: 1.7.0...1.7.1
1.7.0
Highlights
New _Predicate type
We added a new _Predicate type which essentially combines a proc with a description. You can use it like this:
_Predicate("Starts with 'Hello'") { it.start_with?("Hello") }after_initialize can now be privately scoped
private def after_initialize
# do stuff here
end[Experimental] Literal::Value and Literal::Delegator classes
Literal::Value and Literal::Delegator are new abstractions for single-value objects. Hereβs an example of Literal::Value.
class EmailAddress < Literal::Value(String)
delegate :length
def domain
value.split("@").last
end
endLiteral::Delegator is similar except it delegates all missing methods to the underlying value. Weβll post more documentation soon.
PRs
- The
propmethod should return its name so it can be chained with other macros by @joeldrapper in #292 - Add
_Predicatetype by @joeldrapper in #290 - feat: Allow private-scoped after_initialize hooks by @ixti in #301
- Switch to Zeitwerk for code loading by @joeldrapper in #305
- Value objects by @joeldrapper in #293
- Literal branded types by @joeldrapper in #303
- Simplify the subtype method by @joeldrapper in #307
- Make JRuby builds experimental by @joeldrapper in #310
- Improve interface type compaisons by @joeldrapper in #308
New Contributors
Full Changelog: 1.6.0...1.7.0
1.6.0
Whatβs new
- Fix data structure
==equality by @joeldrapper in #278 - Optimise primitive unions by @joeldrapper in #280
- fix enum type error by @Vagab in #285
- add
typeby @Vagab in #286 - Flatten constraints by @joeldrapper in #287
Full Changelog: 1.5.0...1.6.0
1.5.0
Whatβs changed
- Make Rails EnumType handle serializing pre-serialized values by @joeldrapper in #256
- Literal::Enum#to_s by @joeldrapper in #257
- Update README.md by @danielmyasnikov in #258
- Remove the option to disable checks by @joeldrapper in #259
- Switch to assert-style tests by @joeldrapper in #260
- Fix typo by @visini in #262
- Allow enum coercion from symbol by @joeldrapper in #261
- Literal::Array(Literal::Tuple)#transpose by @joeldrapper in #263
- Literal array transpose with array by @joeldrapper in #264
Literal::Array(T)coercion by @joeldrapper in #267- Literal::Array#zip by @joeldrapper in #268
- Make enums ordered by @joeldrapper in #269
- Literal Array #sort_by! by @hslzr in #272
- Literal Array #each_index by @hslzr in #270
- Literal Array #take_while by @hslzr in #271
- Fix issue with constraint allocations by @joeldrapper in #273
- Fix error when using non-ActiveRecord::Base on ActiveRecord::Relation by @stephannv in #274
- Fixing Rubocop and JRuby CI by @stephannv in #275
- Adding _Date, _Date?, _Time, and _Time? to Literal::Types by @albertico in #277
New Contributors
- @danielmyasnikov made their first contribution in #258
- @visini made their first contribution in #262
- @stephannv made their first contribution in #274
- @albertico made their first contribution in #277
Full Changelog: 1.4.0...1.5.0
1.4.0
Whatβs Changed
- Fixed an issue that meant you couldnβt have a property named
property. - Fixed an issue when subclassing
Literal::Dataclasses. Previously if you defined a property in the subclass, you would lose all the properties in the parent class. Literal::Enum#to_hnow yields the member when passed a block. When called without a block, it now returns a Hash from member to value.Literal::Enumobjects must be unique by value.Literal::Datano longer duplicates and freezes its properties β this caused compatibility issues with certain objects. We cannot considerLiteral::Datato be deeply frozen going forward.- Various improvements to
Literal::Array, which is still experimental and incomplete. - Introduced
Literal::Tuple, which is still experimental and incomplete.Literal::Array#productnow returns aLiteral::Tuplein some situations.
Full Changelog: 1.3.0...1.4.0
1.3.0
Weβve tagged this as a minor update, which means it could include breaking changes. However, in this case, these changes are very unlikely to be breaking for you. Some error messages and inspect output will be different, if you depended on that.
Whatβs Changed
- Fixed an issue that occurred when creating a property called
propertywithprop. - Improved error output for the
_Maptype. - New
_Deferredtype now makes it possible to define recursive self-referencing types. - Simplified some equivalent types βΒ for example
_Callablenow returns_Interface(:call),_Not(_Not(true))is now justtrue. - All built in types are now comparable via
Literal.subtype?(a, of: b). For now, consider this method private β however it will be used to make the upcomingLiteral::Array,Literal::HashandLiteral::Setobjects faster. - Various improvements to
Literal::Array, which is still experimental - Various improvements to
Literal::Flags, which is still experimental
New Contributors
- @alvitovitch made their first contribution in #231
Full Changelog: 1.2.0...1.3.0
1.2.0
What's Changed
- [BREAKING]
Literal::Datano longer supports#[]to be consistent with RubyβsData - [FIX] Fixed an issue with
_Hash?(K, V)and_Integer?(T) - Various changes to experimental features:
Literal::Flags,Literal::Array,Literal::Set,Literal::Hash - Improved error messages for
_JSONData,_Map(T),_Set(T), and_Union(*T)
New Contributors
- @phillipspc made their first contribution in #141
- @hslzr made their first contribution in #219
- @christopher-b made their first contribution in #143
- @f-mer made their first contribution in #227
Full Changelog: 1.1.0...1.2.0
1.1.0
What's Changed
- Better nested type errors β @segiddins in #132
- Experimental bit flags object β @joeldrapper in #99
Full Changelog: 1.0.0...1.1.0