1# -*- rdoc -*- 2 3= NEWS for Ruby 2.5.0 4 5This document is a list of user visible feature changes made between 6releases except for bug fixes. 7 8Note that each entry is kept so brief that no reason behind or 9reference information is supplied with. For a full list of changes 10with all sufficient information, see the ChangeLog file or Redmine 11(e.g. <tt>https://bugs.ruby-lang.org/issues/$FEATURE_OR_BUG_NUMBER</tt>) 12 13== Changes since the 2.4.0 release 14 15=== Language changes 16 17* Top-level constant look-up is removed. [Feature #11547] 18 19* rescue/else/ensure are allowed inside do/end blocks. [Feature #12906] 20 21* refinements take place in string interpolations. [Feature #13812] 22 23=== Core classes updates (outstanding ones only) 24 25* Array 26 27 * New methods: 28 29 * Array#append [Feature #12746] 30 * Array#prepend [Feature #12746] 31 32* Data 33 34 * Is deprecated. It was a base class for C extensions, and it's not 35 necessary to expose in Ruby level. [Feature #3072] 36 37* Exception 38 39 * New methods: 40 41 * Exception#full_message to retrieve a String expression of an exception, 42 formatted in the same way in which Ruby prints out an uncaught 43 exception. [Feature #14141] [experimental] 44 45* Dir 46 47 * Dir.glob provides new optional keyword argument, +:base+ . [Feature #13056] 48 * Dir.chdir (without block arg), Dir.open, Dir.new, Dir.mkdir, Dir.rmdir, 49 Dir.empty? releases GVL 50 51 * New methods: 52 53 * Dir.children [Feature #11302] 54 * Dir.each_child [Feature #11302] 55 56* Enumerable 57 58 * Enumerable#any?, Enumerable#all?, Enumerable#none? and Enumerable#one? 59 accept a pattern argument. [Feature #11286] 60 61* File 62 63 * File.open accepts +:newline+ option to imply text mode. [Bug #13350] 64 * File#path raises an IOError for files opened with 65 File::Constants::TMPFILE option. [Feature #13568] 66 * File.stat, File.exist? and other <code>rb_stat()</code>-using methods 67 release GVL. [Bug #13941] 68 * File.rename releases GVL. [Feature #13951] 69 * File::Stat#atime, File::Stat#mtime and File::Stat#ctime support fractional 70 second timestamps on Windows 8 and later. [Feature #13726] 71 * File::Stat#ino and File.indentical? support ReFS 128bit ino on Windows 8.1 72 and later. [Feature #13731] 73 * File.readable?, File.readable_real?, File.writable?, File.writable_real?, 74 File.executable?, File.executable_real?, File.mkfifo, File.readlink, 75 File.truncate, File#truncate, File.chmod, File.lchmod, File.chown, 76 File.lchown, File.unlink, File.utime, File.lstat release GVL 77 78 * New method: 79 80 * File.lutime [Feature #4052] 81 82* Hash 83 84 * New methods: 85 86 * Hash#transform_keys [Feature #13583] 87 * Hash#transform_keys! [Feature #13583] 88 * Hash#slice [Feature #8499] 89 90* IO 91 92 * IO.copy_stream tries copy offload with copy_file_range(2) [Feature #13867] 93 94 * New methods: 95 96 * IO#pread [Feature #4532] 97 * IO#pwrite [Feature #4532] 98 * IO#write accepts multiple arguments [Feature #9323] 99 100* IOError 101 102 * IO#close might raise an error with message "stream closed", 103 but it is refined to "stream closed in another thread". The new message 104 is more clear for user. [Bug #13405] 105 106* Integer 107 108 * Integer#round, Integer#floor, Integer#ceil and Integer#truncate always 109 return an Integer. [Bug #13420] 110 * Integer#pow accepts modulo argument for calculating modular 111 exponentiation. [Feature #12508] [Feature #11003] 112 113 * New methods: 114 115 * Integer#allbits?, Integer#anybits?, Integer#nobits? [Feature #12753] 116 * Integer.sqrt [Feature #13219] 117 118* Kernel 119 120 * Kernel#yield_self [Feature #6721] 121 * Kernel#pp [Feature #14123] 122 * Kernel#warn(..., uplevel:n) [Feature #12882] 123 124* Method 125 126 * New methods: 127 128 * Method#=== that invokes Method#call, as same as Proc#=== [Feature #14142] 129 130* Module 131 132 * Module#attr, Module#attr_accessor, Module#attr_reader and Module#attr_writer 133 become public. [Feature #14132] 134 * Module#define_method, Module#alias_method, Module#undef_method and 135 Module#remove_method become public. [Feature #14133] 136 137* Numeric 138 139 * Numeric#step no longer hides errors from coerce method when 140 given a step value which cannot be compared with #> to 0. [Feature #7688] 141 * Numerical comparison operators (<,<=,>=,>) no longer hide exceptions 142 from #coerce method internally. Return nil in #coerce if the coercion is 143 impossible. [Feature #7688] 144 145* Process 146 147 * Precision of Process.times is improved if getrusage(2) exists. [Feature #11952] 148 149 * New method: 150 151 * Process.last_status as an alias of $? [Feature #14043] 152 153* Range 154 * Range#initialize no longer hides exceptions when comparing begin and 155 end with #<=> and raise a "bad value for range" ArgumentError 156 but instead lets the exception from the #<=> call go through. [Feature #7688] 157 158* Regexp 159 160 * Update to Onigmo 6.1.3-669ac9997619954c298da971fcfacccf36909d05. 161 162 * Support absence operator https://github.com/k-takata/Onigmo/issues/82 163 164 * Support new 5 emoji-related Unicode character properties 165 166* RubyVM::InstructionSequence 167 168 * New method: 169 170 * RubyVM::InstructionSequence#each_child 171 * RubyVM::InstructionSequence#trace_points 172 173* String 174 175 * <code>String#-@</code> deduplicates unfrozen strings. Already-frozen 176 strings remain unchanged for compatibility. [Feature #13077] 177 * <code>-"literal"</code> (<code>String#-@</code>) optimized to return the same object 178 (same as <code>"literal".freeze</code> in Ruby 2.1+) [Feature #13295] 179 * String#casecmp and String#casecmp? return nil for non-string arguments 180 instead of raising a TypeError. [Bug #13312] 181 * String#start_with? accepts a regexp [Feature #13712] 182 183 * New methods: 184 185 * String#delete_prefix, String#delete_prefix! [Feature #12694] 186 * String#delete_suffix, String#delete_suffix! [Feature #13665] 187 * String#each_grapheme_cluster and String#grapheme_clusters to 188 enumerate grapheme clusters [Feature #13780] 189 * String#undump to unescape String#dump'ed string [Feature #12275] 190 191* Struct 192 193 * Struct.new takes `keyword_init: true` option to initialize members 194 with keyword arguments. [Feature #11925] 195 196* Regexp/String: Update Unicode version from 9.0.0 to 10.0.0 [Feature #13685] 197 198* Thread 199 200 * Description set by Thread#name= is now visible on Windows 10. 201 202 * New method: 203 * Thread#fetch [Feature #13009] 204 205 * The default of Thread.report_on_exception is now true, 206 showing unhandled exceptions terminating threads on $stderr. [Feature #14143] 207 208* Time 209 210 * Time.at receives 3rd argument which specifies the unit of 2nd argument. [Feature #13919] 211 212* KeyError 213 214 * New methods: 215 216 * KeyError#receiver [Feature #12063] 217 * KeyError#key [Feature #12063] 218 219* FrozenError 220 221 * New exception class. [Feature #13224] 222 223=== Stdlib updates (outstanding ones only) 224 225* BigDecimal 226 227 * Update to BigDecimal 1.3.4 228 229 * The following features are added: 230 231 * BigDecimal::VERSION 232 233 * The following features have been deprecated, 234 and are planned to be removed in the version 1.4.0: 235 236 * BigDecimal.new 237 238 * BigDecimal.ver 239 240 * BigDecimal#clone and #dup now do not make a new instance, 241 but returns the receiver itself. 242 243* Coverage 244 245 * Support branch coverage and method coverage measurement. [Feature #13901] 246 Branch coverage tells you which branches are executed, and which not. 247 Method coverage tells you which methods are invoked, and which not. 248 By running a test suite with this new feature, you can know which branches 249 and methods are executed by a test, and evaluate total coverage of a test 250 suite more strictly. 251 252 You can specify the measuring target by an option to `Coverage.start`: 253 254 Coverage.start(lines: true, branches: true, methods: true) 255 256 After some Ruby files are loaded, you can use `Coverage.result` to get 257 the coverage result: 258 259 Coverage.result 260 #=> { "/path/to/file.rb"=> 261 # { :lines => [1, 2, 0, nil, ...], 262 # :branches => 263 # { [:if, 0, 2, 1, 6, 4] => 264 # { [:then, 1, 3, 2, 3, 8] => 0, 265 # [:else, 2, 5, 2, 5, 8] => 2 266 # } 267 # }, 268 # :methods => { 269 # [Object, :foo, 1, 0, 7, 3] => 2 270 # } 271 # } 272 # } 273 274 The result type of line coverage is not changed; it is just an array that 275 contains numbers, which means the count that each line was executed, 276 or `nil`s, which means that the line is not relevant. 277 278 The result type of branch coverage is: 279 280 { (jump base) => { (jump target) => (counter) } } 281 282 where jump base and targets have the format 283 284 [type, unique-id, start lineno, start column, end lineno, end column] 285 286 For example, `[:if, 0, 2, 1, 6, 4]` reads an `if` statement that ranges from 287 line 2 and column 1, to line 6 and column 4. `[:then, 1, 3, 2, 3, 8]` reads 288 a `then` clause that ranges from line 3 and column 2, to line 3 and column 8. 289 Note that lineno starts from 1, and that columnno starts from 0. So, the 290 above example shows a branch from the `if` to the `then` was never executed, 291 and a branch from the `if` to the `else` was executed twice. 292 293 The result type of method coverage is: 294 295 { (method key) => (counter) } 296 297 where method key has the format 298 299 [class, method-name, start lineno, start column, end lineno, end column] 300 301 For example, `[Object, :foo, 1, 0, 7, 3]` reads `Object#foo` that ranges from 302 line 1 and column 0, to line 7 and column 3. The above example shows this 303 `Object#foo` was invoked twice. 304 305 Note: To keep compatibility, passing no option to `Coverage.start` will measure 306 only line coverage, and `Coverage.result` will return the old format: 307 308 Coverage.result 309 #=> { "/path/to/file.rb"=> [1, 2, 0, nil, ...] } 310 311* DRb 312 313 * ACL::ACLEntry.new no longer suppresses IPAddr::InvalidPrefixError. 314 315* ERB 316 317 * Add ERB#result_with_hash to render a template with local variables passed 318 with a Hash object. [Feature #8631] 319 320 * Default template file encoding is changed from ASCII-8BIT to UTF-8 in erb 321 command. [Bug #14095] 322 323 * Carriage returns are changed to be trimmed properly if trim_mode is specified 324 and used. Duplicated newlines will be removed on Windows. [Bug #5339] [Bug #11464] 325 326* IPAddr 327 328 * IPAddr no longer accepts invalid address mask. [Bug #13399] 329 * IPAddr#ipv4_compat and IPAddr#ipv4_compat? are marked for deprecation. [Bug #13769] 330 331 * New methods: 332 333 * IPAddr#prefix 334 * IPAddr#loopback? 335 * IPAddr#private? [Feature #11666] 336 * IPAddr#link_local? [Feature #10912] 337 338* IRB 339 340 * Print backtrace and error message in reverse order [Feature #8661] [experimental] 341 * `binding.irb` automatically requires irb and runs [Bug #13099] [experimental] 342 * `binding.irb` on its start shows source around the line where it was called [Feature #14124] 343 344* Matrix 345 346 * New methods: 347 348 * Matrix.combine and Matrix#combine [Feature #10903] 349 * Matrix#hadamard_product and Matrix#entrywise_product 350 351* Net::HTTP 352 353 * Net::HTTP.new supports no_proxy parameter [Feature #11195] 354 * Net::HTTP#min_version and Net::HTTP#max_version [Feature #9450] 355 * Add more HTTP status classes 356 * Net::HTTP::STATUS_CODES is added as HTTP Status Code Repository [Misc #12935] 357 * Net::HTTP#proxy_user and Net::HTTP#proxy_pass reflect http_proxy environment 358 variable if the system's environment variable is multiuser safe. [Bug #12921] 359 360* open-uri 361 * URI.open method defined as an alias to open-uri's Kernel.open. 362 open-uri's Kernel.open will be deprecated in future. 363 364* OpenSSL 365 366 * Updated Ruby/OpenSSL from version 2.0 to 2.1. Changes are noted in 367 "Version 2.1.0" section in ext/openssl/History.md. 368 369* Pathname 370 371 * New method: 372 373 * Pathname#glob [Feature #7360] 374 375* Psych 376 377 * Update to Psych 3.0.2. 378 379 * Convert fallback option to a keyword argument 380 https://github.com/ruby/psych/pull/342 381 * Add :symbolize_names option to Psych.load, Psych.safe_load like JSON.parse 382 https://github.com/ruby/psych/pull/333, https://github.com/ruby/psych/pull/337 383 * Add Psych::Handler#event_location 384 https://github.com/ruby/psych/pull/326 385 * Make frozen string literal = true 386 https://github.com/ruby/psych/pull/320 387 * Preserve time zone offset when deserializing times 388 https://github.com/ruby/psych/pull/316 389 * Remove deprecated method aliases for syck gem 390 https://github.com/ruby/psych/pull/312 391 392* RbConfig 393 394 * RbConfig::LIMITS is added to provide the limits of C types. 395 This is available when rbconfig/sizeof is loaded. 396 397* Ripper 398 399 * Ripper::EXPR_BEG and so on for Ripper#state. 400 401 * New method: 402 403 * Ripper#state to tell the state of scanner. [Feature #13686] 404 405* RDoc 406 407 * Update to RDoc 6.0.1. 408 409 * Replace IRB based lexer with Ripper. 410 * https://github.com/ruby/rdoc/pull/512 411 * This much improves the speed of generating documents. 412 * It also facilitates supporting new syntax in the future. 413 * Support many new syntaxes of Ruby from the past few years. 414 * Use "frozen_string_literal: true". 415 Performance survey: https://gist.github.com/aycabta/abdfaa75ea8a6877eeb734e942e73800 416 * Support did_you_mean. 417 418* Rubygems 419 420 * Update to Rubygems 2.7.3. 421 * http://blog.rubygems.org/2017/11/28/2.7.3-released.html 422 * http://blog.rubygems.org/2017/11/08/2.7.2-released.html 423 * http://blog.rubygems.org/2017/11/03/2.7.1-released.html 424 * http://blog.rubygems.org/2017/11/01/2.7.0-released.html 425 * http://blog.rubygems.org/2017/10/09/2.6.14-released.html 426 * http://blog.rubygems.org/2017/08/27/2.6.13-released.html 427 428* SecureRandom 429 430 * New method: 431 432 * SecureRandom.alphanumeric 433 434* Set 435 436 * New methods: 437 438 * Set#to_s as alias to #inspect [Feature #13676] 439 * Set#=== as alias to #include? [Feature #13801] 440 * Set#reset [Feature #6589] 441 442* StringIO 443 444 * StringIO#write accepts multiple arguments 445 446* StringScanner 447 448 * New methods: 449 450 * StringScanner#size, StringScanner#captures, StringScanner#values_at [Feature #836] 451 452* URI 453 454 * Relative path operations no longer collapse consecutive slashes to a single slash. [Bug #8352] 455 456* WEBrick 457 458 * Add Server Name Indication (SNI) support [Feature #13729] 459 * support Proc objects as body responses [Feature #855] 460 * released as a RubyGem [Feature #13173] 461 * avoid unintended behavior from Kernel#open [Misc #14216] 462 463* Zlib 464 465 * Zlib::GzipWriter#write accepts multiple arguments 466 467=== Compatibility issues (excluding feature bug fixes) 468 469* Socket 470 471 * BasicSocket#read_nonblock and BasicSocket#write_nonblock no 472 longer set the O_NONBLOCK file description flag as side effect 473 (on Linux only) [Feature #13362] 474 475* Random 476 477 * Random.raw_seed renamed to become Random.urandom. It is now 478 applicable to non-seeding purposes due to [Bug #9569]. 479 480* Socket 481 482 * Socket::Ifaddr#vhid is added [Feature #13803] 483 484* ConditionVariable, Queue and SizedQueue reimplemented for speed. 485 They no longer subclass Struct. [Feature #13552] 486 487=== Stdlib compatibility issues (excluding feature bug fixes) 488 489* Gemification 490 491 * Promote following standard libraries to default gems. 492 * cmath 493 * csv 494 * date 495 * dbm 496 * etc 497 * fcntl 498 * fiddle 499 * fileutils 500 * gdbm 501 * ipaddr 502 * scanf 503 * sdbm 504 * stringio 505 * strscan 506 * webrick 507 * zlib 508 509* Logger 510 511 * Logger.new("| command") had been working to open a command 512 unintentionally. It was prohibited, and now Logger#initialize 513 treats a String argument only as a filename, as its specification. [Bug #14212] 514 515* Net::HTTP 516 517 * Net::HTTP#start now passes :ENV to p_addr by default. [Bug #13351] 518 To avoid this, pass nil explicitly. 519 520* mathn.rb 521 522 * Removed from stdlib. [Feature #10169] 523 524* Rubygems 525 526 * Removed "ubygems.rb" file from stdlib. It's needless since Ruby 1.9. 527 528=== C API updates 529 530=== Supported platform changes 531 532* Drop support of NaCl platform 533 534 * https://bugs.chromium.org/p/chromium/issues/detail?id=239656#c160 535 536=== Implementation improvements 537 538* (This might not be a "user visible feature change" but) Hash class's 539 hash function is now SipHash13. [Feature #13017] 540 541* SecureRandom now prefers OS-provided sources than OpenSSL. [Bug #9569] 542 543* Mutex rewritten to be smaller and faster [Feature #13517] 544 545* Performance of block passing using block parameters is improved by 546 lazy Proc allocation [Feature #14045] 547 548* Dynamic instrumentation for TracePoint hooks instead of using "trace" 549 instruction to avoid overhead [Feature #14104] 550 551* ERB now generates code from a template twice as fast as Ruby 2.4 552 553=== Miscellaneous changes 554 555* Print backtrace and error message in reverse order if $stderr is unchanged 556 and a tty. [Feature #8661] [experimental] 557 558* Print error message in bold/underlined text if $stderr is unchanged and a 559 tty. [Feature #14140] [experimental] 560 561* configure option --with-ext now mandates its arguments. So for 562 instance if you run ./configure --with-ext=openssl,+ then the 563 openssl library is guaranteed compiled, otherwise the build fails 564 abnormally. 565 566 Note however to always add the ",+" at the end of the argument. 567 Otherwise nothing but openssl are built. [Feature #13302] 568