Documentation for a newer release is available. View Latest

Ruby

Ruby 2.7

Fedora 32 provides Ruby 2.7 version. With this major update from Ruby 2.6, Fedora becomes the superior Ruby development platform.

Changes since Ruby 2.6:

Ruby 2.7 comes with several new features and performance improvements.

Performance improvements

  • JIT [Experimental]

  • Fiber’s cache strategy is changed and fiber creation is speeded up.

  • Module#name, true.to_s, false.to_s, and nil.to_s now always return a frozen String. The returned String is always the same for a given object. [Experimental]

  • The performance of Monitor and MonitorMixin is improved.

  • The performance of CGI.escapeHTML is improved.

  • Per-call-site method cache, which has been there since around 1.9, was improved: cache hit rate raised from 89% to 94%.

  • RubyVM::InstructionSequence#to_binary method generates compiled binary. The binary size is reduced.

Other notable changes

  • Some standard libraries are updated.

    • Bundler 2.1.2

    • RubyGems 3.1.2

    • Racc 1.4.15

    • CSV 3.1.2

    • REXML 3.2.3

    • RSS 0.2.8

    • StringScanner 1.0.3

    • Some other libraries that have no original version are also updated.

  • The following libraries are no longer bundled gems. Install corresponding gems to use these features.

    • CMath (cmath gem)

    • Scanf (scanf gem)

    • Shell (shell gem)

    • Synchronizer (sync gem)

    • ThreadsWait (thwait gem)

    • E2MM (e2mmap gem)

  • profile.rb was removed from standard library.

  • Promote stdlib to default gems

    • The following default gems were published on rubygems.org

      • benchmark

      • cgi

      • delegate

      • getoptlong

      • net-pop

      • net-smtp

      • open3

      • pstore

      • singleton

    • The following default gems were only promoted at ruby-core, but not yet published on rubygems.org.

      • monitor

      • observer

      • timeout

      • tracer

      • uri

      • yaml

  • Proc.new and proc with no block in a method called with a block is warned now.

  • lambda with no block in a method called with a block raises an exception.

  • Update Unicode version and Emoji version from 11.0.0 to 12.0.0.

  • Update Unicode version to 12.1.0, adding support for U+32FF SQUARE ERA NAME REIWA.

  • Date.jisx0301, Date#jisx0301, and Date.parse support the new Japanese era.

  • Require compilers to support C99.

Detailed changes

Pattern Matching [Experimental]

Pattern matching, a widely used feature in functional programming languages, is introduced as an experimental feature. It can traverse a given object and assign it’s value if it matches a pattern.

require "json"

json = <<END
{
  "name": "Alice",
  "age": 30,
  "children": [{ "name": "Bob", "age": 2 }]
}
END

case JSON.parse(json, symbolize_names: true)
in {name: "Alice", children: [{name: "Bob", age: age}]}
  p age #=> 2
end

REPL improvement

irb, the bundled interactive environment (REPL; Read-Eval-Print-Loop), now supports multi-line editing. It is powered by reline, a readline -compatible library implemented in pure Ruby. It also provides rdoc integration. In irb you can display the reference for a given class, module, or method.

Compaction GC

This release introduces Compaction GC which can defragment a fragmented memory space.

Some multi-threaded Ruby programs may cause memory fragmentation, leading to high memory usage and degraded speed.

The GC.compact method is introduced for compacting the heap. This function compacts live objects in the heap so that fewer pages may be used, and the heap may be more CoW (copy-on-write) friendly.

Separation of positional and keyword arguments

Automatic conversion of keyword arguments and positional arguments is deprecated, and conversion will be removed in Ruby 3.

Cambios
  • When a method call passes a Hash at the last argument, and when it passes no keywords, and when the called method accepts keywords, a warning is emitted. To continue treating the hash as keywords, add a double splat operator to avoid the warning and ensure correct behavior in Ruby 3.

        def foo(key: 42); end; foo({key: 42})   # warned
        def foo(**kw);    end; foo({key: 42})   # warned
        def foo(key: 42); end; foo(**{key: 42}) # OK
        def foo(**kw);    end; foo(**{key: 42}) # OK
  • When a method call passes keywords to a method that accepts keywords, but it does not pass enough required positional arguments, the keywords are treated as a final required positional argument, and a warning is emitted. Pass the argument as a hash instead of keywords to avoid the warning and ensure correct behavior in Ruby 3.

        def foo(h, **kw); end; foo(key: 42)      # warned
        def foo(h, key: 42); end; foo(key: 42)   # warned
        def foo(h, **kw); end; foo({key: 42})    # OK
        def foo(h, key: 42); end; foo({key: 42}) # OK
  • When a method accepts specific keywords but not a keyword splat, and a hash or keywords splat is passed to the method that includes both Symbol and non-Symbol keys, the hash will continue to be split, and a warning will be emitted. You will need to update the calling code to pass separate hashes to ensure correct behavior in Ruby 3.

        def foo(h={}, key: 42); end; foo("key" => 43, key: 42)   # warned
        def foo(h={}, key: 42); end; foo({"key" => 43, key: 42}) # warned
        def foo(h={}, key: 42); end; foo({"key" => 43}, key: 42) # OK
  • If a method does not accept keywords, and is called with keywords, the keywords are still treated as a positional hash, with no warning. This behavior will continue to work in Ruby 3.

        def foo(opt={});  end; foo( key: 42 )   # OK
  • Non-symbols are allowed as keyword argument keys if the method accepts arbitrary keywords.

        def foo(**kw); p kw; end; foo("str" => 1) #=> {"str"=>1}
  • **nil is allowed in method definitions to explicitly mark that the method accepts no keywords. Calling such a method with keywords will result in an ArgumentError.

        def foo(h, **nil); end; foo(key: 1)       # ArgumentError
        def foo(h, **nil); end; foo(**{key: 1})   # ArgumentError
        def foo(h, **nil); end; foo("str" => 1)   # ArgumentError
        def foo(h, **nil); end; foo({key: 1})     # OK
        def foo(h, **nil); end; foo({"str" => 1}) # OK
  • Passing an empty keyword splat to a method that does not accept keywords no longer passes an empty hash, unless the empty hash is necessary for a required parameter, in which case a warning will be emitted. Remove the double splat to continue passing a positional hash.

        h = {}; def foo(*a) a end; foo(**h) # []
        h = {}; def foo(a) a end; foo(**h)  # {} and warning
        h = {}; def foo(*a) a end; foo(h)   # [{}]
        h = {}; def foo(a) a end; foo(h)    # {}

If you want to disable the deprecation warnings, please use a command-line argument -W:no-deprecated or add Warning[:deprecated] = false to your code.

See the upstream release announcement for more detailed information about this release.

Jekyll 4.0

The Jekyll static page generator and its plug-ins have been updated to version 4.0.0. This version includes the following changes compared to version 3.8:

  • Significant performance improvements

  • Cleanups and bug fixes

  • Other minor changes incompatible with the previous release

For more information about Jekyll 4.0.0, see https://jekyllrb.com/news/2019/08/20/jekyll-4-0-0-released/.