Skip to content

Releases: yippee-fun/literal

1.8.1

06 Jun 11:28
417b16c

Choose a tag to compare

Highlights

Just a quick non-breaking change to show prop type signatures in Ruby LSP hover and auto-complete cards. Enjoy!

452277894-fe2eaf50-6635-48da-b148-732ecc856f66

PRs

Full Changelog: 1.8.0...1.8.1

1.8.0

23 May 15:29
700ce79

Choose a tag to compare

Highlights

  • New RubyLSP indexing enhancement allows RubyLSP to auto-complete instance variables based on property definitions.
  • Literal::Data and Literal::Struct now support to_hash
  • Improved generation of predicate names from Literal::Enum member constant names
  • The default proc on properties is now evaluated in the context of the new instance being initialised
  • The _JSONData type now takes parameters to limit the type, e.g. _JSONData(Array)
  • _Not can now take multiple parameters and then wraps a union of those parameters, e.g. _Not(_Union(*your_types))
  • A new type _Pattern takes 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 the T parameter.
  • 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 #reverse in Literal::Array by @hslzr in #297
  • Implements #reverse! in Literal::Array by @hslzr in #298
  • Ruby LSP extension by @joeldrapper in #323

New Contributors

Full Changelog: 1.7.1...1.8.0

1.7.1

15 Apr 23:34
6739fe2

Choose a tag to compare

Highlights

Quick fix for a bug related to our migration to Zeitwerk.

What's Changed

Full Changelog: 1.7.0...1.7.1

1.7.0

15 Apr 17:08
21c577b

Choose a tag to compare

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
end

Literal::Delegator is similar except it delegates all missing methods to the underlying value. We’ll post more documentation soon.

PRs

New Contributors

  • @ixti made their first contribution in #301

Full Changelog: 1.6.0...1.7.0

1.6.0

10 Mar 10:27

Choose a tag to compare

What’s new

Full Changelog: 1.5.0...1.6.0

1.5.0

17 Jan 11:15

Choose a tag to compare

What’s changed

New Contributors

Full Changelog: 1.4.0...1.5.0

1.4.0

10 Dec 14:00

Choose a tag to compare

What’s Changed

  • Fixed an issue that meant you couldn’t have a property named property.
  • Fixed an issue when subclassing Literal::Data classes. Previously if you defined a property in the subclass, you would lose all the properties in the parent class.
  • Literal::Enum#to_h now yields the member when passed a block. When called without a block, it now returns a Hash from member to value.
  • Literal::Enum objects must be unique by value.
  • Literal::Data no longer duplicates and freezes its properties β€” this caused compatibility issues with certain objects. We cannot consider Literal::Data to 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#product now returns a Literal::Tuple in some situations.

Full Changelog: 1.3.0...1.4.0

1.3.0

29 Nov 11:51

Choose a tag to compare

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 property with prop.
  • Improved error output for the _Map type.
  • New _Deferred type now makes it possible to define recursive self-referencing types.
  • Simplified some equivalent types β€”Β for example _Callable now returns _Interface(:call), _Not(_Not(true)) is now just true.
  • 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 upcoming Literal::Array, Literal::Hash and Literal::Set objects faster.
  • Various improvements to Literal::Array, which is still experimental
  • Various improvements to Literal::Flags, which is still experimental

New Contributors

Full Changelog: 1.2.0...1.3.0

1.2.0

22 Nov 14:28

Choose a tag to compare

What's Changed

  • [BREAKING] Literal::Data no longer supports #[] to be consistent with Ruby’s Data
  • [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

Full Changelog: 1.1.0...1.2.0

1.1.0

07 Nov 12:26

Choose a tag to compare

What's Changed

Full Changelog: 1.0.0...1.1.0