summaryrefslogtreecommitdiff
path: root/doc/NEWS-2.0.0
blob: 9ad72543175d45075e8bfd018262ad37063aa338 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
# -*- rdoc -*-

= NEWS for Ruby 2.0.0

This document is a list of user visible feature changes made between
releases except for bug fixes.

Note that each entry is kept so brief that no reason behind or
reference information is supplied with.  For a full list of changes
with all sufficient information, see the ChangeLog file.

== Changes since the 1.9.3 release

=== Language changes

* Added keyword arguments.

* Added %i and %I for symbol list creation (similar to %w and %W).

* Default source encoding is changed to UTF-8. (was US-ASCII)

* No warning for unused variables starting with '_'

=== Core classes updates (outstanding ones only)

* ARGF
  * added method:
    * added ARGF#codepoints and ARGF#each_codepoint, like the corresponding
      methods for IO.

* Array
  * added method:
    * added Array#bsearch for binary search.
  * incompatible changes:
    * random parameter of Array#shuffle! and Array#sample now
      will be called with one argument, maximum value.
    * when given Range arguments, Array#values_at now returns nil for each
      value that is out-of-range.

* Enumerable
  * added method:
    * added Enumerable#lazy method for lazy enumeration.

* Enumerator
  * added method:
    * added Enumerator#size for lazy size evaluation.
  * extended method:
    * Enumerator.new accept an argument for lazy size evaluation.
  * new class Enumerator::Lazy for lazy enumeration

* ENV
  * aliased method:
    * ENV.to_h is a new alias for ENV.to_hash

* Fiber
  * incompatible changes:
    * Fiber#resume cannot resume a fiber which invokes "Fiber#transfer".

* File
  * extended method:
    * File.fnmatch? now expands braces in the pattern if
      File::FNM_EXTGLOB option is given.

* GC
  * improvements:
    * introduced the bitmap marking which suppresses to copy a memory page
      with Copy-on-Write.
    * introduced the non-recursive marking which avoids unexpected stack overflow.

* GC::Profiler
  * added method:
    * added GC::Profiler.raw_data which returns raw profile data for GC.

* Hash
  * added method:
    * added Hash#to_h as explicit conversion method, like Array#to_a.
  * extended method:
    * Hash#default_proc= can be passed nil to clear the default proc.

* IO
  * deprecated methods:
    * IO#lines, #bytes, #chars and #codepoints are deprecated.

* Kernel
  * added method:
    * added Kernel#Hash conversion method like Array() or Float().
    * added Kernel#__dir__ which returns the absolute path of the
      directory of the file from which this method is called.
    * added Kernel#caller_locations which returns an array of
      frame information objects.
  * extended method:
    * Kernel#warn accepts multiple args in like puts.
    * Kernel#caller accepts second optional argument `n' which specify
      required caller size.
    * Kernel#to_enum and enum_for accept a block for lazy size evaluation.
  * incompatible changes:
    * system() and exec() closes non-standard file descriptors
      (The default of :close_others option is changed to true by default.)
    * respond_to? against a protected method now returns false unless
      the second argument is true.
    * __callee__ has returned to the original behavior, and now
      returns the called name but not the original name in an
      aliased method.
    * Kernel#inspect does not call #to_s anymore
      (it used to call redefined #to_s).

* LoadError
  * added method:
    * added LoadError#path method to return the file name that could not be
      loaded.

* Module
  * added method:
    * added Module#prepend which is similar to Module#include,
      however a method in the prepended module overrides the
      corresponding method in the prepending module.
    * added Module.prepended and Module.prepend_features, similar
      to included and append_features.
    * added Module#refine, which extends a class or module locally.
      [experimental]
  * extended method:
    * Module#define_method accepts a UnboundMethod from a Module.
    * Module#const_get accepts a qualified constant string, e.g.
      Object.const_get("Foo::Bar::Baz")

* Mutex
  * added method:
    * added Mutex#owned? which returns the mutex is held by current
      thread or not. [experimental]
  * incompatible changes:
    * Mutex#lock, Mutex#unlock, Mutex#try_lock, Mutex#synchronize
      and Mutex#sleep are no longer allowed to be used from trap handler
      and raise a ThreadError in such case.
    * Mutex#sleep may spurious wakeup. Check after wakeup.

* NilClass
  * added method:
    * added nil.to_h which returns {}

* ObjectSpace::WeakMap
  * new low level class to hold weak references to objects.

* Proc
  * incompatible change:
    * removed Proc#== and #eql? so two procs are == only when they are
      the same object.

* Process
  * added method:
    * added getsid for getting session id (unix only).

* Range
  * added method:
    * added Range#size for lazy size evaluation.
    * added Range#bsearch for binary search.

* RubyVM (MRI specific)
  * added RubyVM::InstructionSequence.of to get the instruction sequence
    from a method or a block.
  * added RubyVM::InstructionSequence#path, #absolute_path, #label,
    #base_label and #first_lineno to retrieve information from where
    the instruction sequence was defined.
  * added Environment variables to specify stack usage:
    * RUBY_THREAD_VM_STACK_SIZE: vm stack size used at thread creation.
      default: 128KB (32bit CPU) or 256KB (64bit CPU).
    * RUBY_THREAD_MACHINE_STACK_SIZE: machine stack size used at thread
      creation. default: 512KB or 1024KB.
    * RUBY_FIBER_VM_STACK_SIZE: vm stack size used at fiber creation.
      default: 64KB or 128KB.
    * RUBY_FIBER_MACHINE_STACK_SIZE: machine stack size used at fiber
      creation. default: 256KB or 512KB.
    These variables are checked only at launched time.
  * added constant DEFAULT_PARAMS to get above default parameters.

* Signal
  * added method:
    * added Signal.signame which returns signal name

  * incompatible changes:
    * Signal.trap raises ArgumentError when :SEGV, :BUS, :ILL, :FPE, :VTALRM
      are specified.

* String
  * added method:
    * added String#b returning a copied string whose encoding is ASCII-8BIT.
  * change return value:
    * String#lines now returns an array instead of an enumerator.
    * String#chars now returns an array instead of an enumerator.
    * String#codepoints now returns an array instead of an enumerator.
    * String#bytes now returns an array instead of an enumerator.

* Struct
  * added method:
    * added Struct#to_h returning values with keys corresponding to the
      instance variable names.

* Thread
  * added method:
    * added Thread#thread_variable_get for getting thread local variables
      (these are different than Fiber local variables).
    * added Thread#thread_variable_set for setting thread local variables.
    * added Thread#thread_variables for getting a list of the thread local
      variable keys.
    * added Thread#thread_variable? for testing to see if a particular thread
      variable has been set.
    * added Thread.handle_interrupt as well as instance and singleton methods
      pending_interrupt? for asynchronous handling of exceptions
    * added Thread#backtrace_locations which returns similar information of
      Kernel#caller_locations.
  * new class Thread::Backtrace::Location to hold backtrace location
    information. These are returned by Thread#backtrace_locations and
    Kernel#caller_locations.
  * incompatible changes:
    * Thread#join and Thread#value now raises a ThreadError if target thread
      is the current or main thread.

* Time
  * change return value:
    * Time#to_s now returns US-ASCII encoding instead of BINARY.

* TracePoint
  * new class. This class is replacement of set_trace_func.
    Easy to use and efficient implementation.

* toplevel
  * added method:
    * added main.define_method which defines a global function.
    * added main.using, which imports refinements into the current file or
      eval string. [experimental]

=== Core classes compatibility issues (excluding feature bug fixes)

* Array#values_at

  See above.

* String#lines
* String#chars
* String#codepoints
* String#bytes

  These methods no longer return an Enumerator, although passing a
  block is still supported for backwards compatibility.

  Code like str.lines.with_index(1) { |line, lineno| ... } no longer
  works because str.lines returns an array.  Replace lines with
  each_line in such cases.

* IO#lines
* IO#chars
* IO#codepoints
* IO#bytes
* ARGF#lines
* ARGF#chars
* ARGF#bytes
* StringIO#lines
* StringIO#chars
* StringIO#codepoints
* StringIO#bytes
* Zlib::GzipReader#lines
* Zlib::GzipReader#bytes

  These methods are deprecated in favor of each_line, each_byte,
  each_char and each_codepoint.

* Proc#==
* Proc#eql?

  These methods were removed. Two procs are == only when they are
  the same object.

* Fixnum
* Bignum
* Float

  Fixnums, Bignums and Floats are frozen.

* Signal.trap

  See above.

* Merge Onigmo.
  https://github.com/k-takata/Onigmo

* The :close_others option is true by default for system() and exec().
  Also, the close-on-exec flag is set by default for all new file descriptors.
  This means file descriptors doesn't inherit to spawned process unless
  explicitly requested such as system(..., fd=>fd).

* Kernel#respond_to? against a protected method now returns false
  unless the second argument is true.

* Kernel#respond_to_missing?
* Kernel#initialize_clone
* Kernel#initialize_dup

  These methods are now private.

* Thread#join, Thread#value

  See above.

* Mutex#lock, Mutex#unlock, Mutex#try_lock, Mutex#synchronize and Mutex#sleep

  See above.

=== Stdlib updates (outstanding ones only)

* cgi
  * Add HTML5 tag maker.
  * CGI#header has been renamed to CGI#http_header and
    aliased to CGI#header.
  * When HTML5 tagmaker called, overwrite CGI#header,
    CGI#header function is to create a <header> element.

* CSV
  * Removed CSV::dump and CSV::load to protect users from dangerous
    serialization vulnerability

* iconv
  * Iconv has been removed. Use String#encode instead.

* io/console
  * new methods:
    * added IO#cooked which sets the terminal to cooked mode within the given block.
    * added IO#cooked! which sets the terminal to cooked.
  * extended method:
    * IO#raw, IO#raw!, and IO#getch accept keyword arguments, :min and :time.

* io/wait
  * new features:
    * added IO#wait_writable method.
    * added IO#wait_readable method as alias of IO#wait.

* json
  * updated to 1.7.7.

* net/http
  * new features:
    * Proxies are now automatically detected from the http_proxy environment
      variable.  See Net::HTTP::new for details.
    * gzip and deflate compression are now requested for all requests by
      default.  See Net::HTTP for details.
    * SSL sessions are now reused across connections for a single instance.
      This speeds up connection by using a previously negotiated session.
    * Requests may be created from a URI which sets the request_uri and host
      header of the request (but does not change the host connected to).
    * Responses contain the URI requested which allows easier implementation of
      redirect following.
  * new methods:
    * Net::HTTP#local_host
    * Net::HTTP#local_host=
    * Net::HTTP#local_port
    * Net::HTTP#local_port=
  * extended method:
    * Net::HTTP#connect uses local_host and local_port if specified.

* net/imap
  * new methods:
    * Net::IMAP.default_port
    * Net::IMAP.default_imap_port
    * Net::IMAP.default_tls_port
    * Net::IMAP.default_ssl_port
    * Net::IMAP.default_imaps_port

* objspace
  * new method:
    * ObjectSpace.reachable_objects_from(obj)

* openssl
  * Consistently raise an error when trying to encode nil values. All instances
    of OpenSSL::ASN1::Primitive now raise TypeError when calling to_der on an
    instance whose value is nil. All instances of OpenSSL::ASN1::Constructive
    raise NoMethodError in the same case. Constructing such values is still
    permitted.
  * TLS 1.1 & 1.2 support by setting OpenSSL::SSL::SSLContext#ssl_version to
    :TLSv1_2, :TLSv1_2_server, :TLSv1_2_client or :TLSv1_1, :TLSv1_1_server
    :TLSv1_1_client. The version being effectively used can be queried
    with OpenSSL::SSL#ssl_version. Furthermore, it is also possible to
    blacklist the new TLS versions with OpenSSL::SSL:OP_NO_TLSv1_1 and
    OpenSSL::SSL::OP_NO_TLSv1_2.
  * Added OpenSSL::SSL::SSLContext#renegotiation_cb. A user-defined callback
    may be set which gets called whenever a new handshake is negotiated. This
    also allows to programmatically decline (client) renegotiation attempts.
  * Support for "0/n" splitting of records as BEAST mitigation via
    OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS.
  * The default options for OpenSSL::SSL::SSLContext have changed to
    OpenSSL::SSL::OP_ALL & ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS
    instead of OpenSSL::SSL::OP_ALL only. This enables the countermeasure for
    the BEAST attack by default.
  * OpenSSL requires passwords for decrypting PEM-encoded files to be at least
    four characters long. This led to awkward situations where an export with
    a password with fewer than four characters was possible, but accessing the
    file afterwards failed. OpenSSL::PKey::RSA, OpenSSL::PKey::DSA and
    OpenSSL::PKey::EC therefore now enforce the same check when exporting a
    private key to PEM with a password - it has to be at least four characters
    long.
  * SSL/TLS support for the Next Protocol Negotiation extension. Supported
    with OpenSSL 1.0.1 and higher.
  * OpenSSL::OPENSSL_FIPS allows client applications to detect whether OpenSSL
    is FIPS-enabled. OpenSSL.fips_mode= allows turning on and off FIPS mode
    manually in order to adapt to situations where FIPS mode would be an
    explicit requirement.
  * Authenticated Encryption with Associated Data (AEAD) is supported via
    Cipher#auth_data= and Cipher#auth_tag/Cipher#auth_tag=.
    Currently (OpenSSL 1.0.1c), only GCM mode is supported.

* ostruct
  * new methods:
    * OpenStruct#[], []=
    * OpenStruct#each_pair
    * OpenStruct#eql?
    * OpenStruct#hash
    * OpenStruct#to_h converts the struct to a hash.
  * extended method:
    * OpenStruct.new also accepts an OpenStruct / Struct.

* pathname
  * extended method:
    * Pathname#find returns an enumerator if no block is given.

* rake
  * rake has been updated to version 0.9.5.

    This version is backwards-compatible with previous rake versions and
    contains many bug fixes.

    See
    http://rake.rubyforge.org/doc/release_notes/rake-0_9_5_rdoc.html for a list
    of changes in rake 0.9.3, 0.9.4 and 0.9.5.

* RDoc
  * RDoc has been updated to version 4.0

    This version is largely backwards-compatible with previous rdoc versions.
    The most notable change is an update to the ri data format (ri data must
    be regenerated for gems shared across rdoc versions).  Further API changes
    are internal and won't affect most users.

    Notable changes include:

    * Page support for ri.  Try `ri ruby:` for a list of pages in ruby or
      `ri ruby:syntax/literals` for the syntax documentation for literals.

      This also works for gems such as `ri rspec:README` for the rspec gem's
      README file.
    * Markdown support.  See ri RDoc::Markdown for details.

    See https://github.com/rdoc/rdoc/blob/master/History.rdoc for a full list
    of changes in rdoc 4.0.

* resolv
  * new methods:
    * Resolv::DNS#timeouts=
    * Resolv::DNS::Config#timeouts=

* rexml
  * REXML::Document#write supports Hash arguments.
  * REXML::Document#write supports new :encoding option. It changes
    XML document encoding. Without :encoding option, encoding in
    XML declaration is used for XML document encoding.

* RubyGems
  * Updated to 2.0.0

    RubyGems 2.0.0 features the following improvements:

    * Improved support for default gems shipping with ruby 2.0.0+
    * A gem can have arbitrary metadata through Gem::Specification#metadata
    * `gem search` now defaults to --remote and is anchored like gem list.
    * Added --document to replace --rdoc and --ri.  Use --no-document to
      disable documentation, --document=rdoc to only generate rdoc.
    * Only ri-format documentation is generated by default.
    * `gem server` uses RDoc::Servlet from RDoc 4.0 to generate HTML
      documentation.

    For an expanded list of updates and bug fixes see:
    https://github.com/rubygems/rubygems/blob/master/History.txt

* shellwords
  * Shellwords#shellescape now stringifies the given object using to_s.
  * Shellwords#shelljoin accepts non-string objects in the given
    array, each of which is stringified using to_s.

* stringio
  * deprecated methods:
    * StringIO#lines, #bytes, #chars and #codepoints are deprecated.

* syslog
  * Added Syslog::Logger which provides a Logger API atop Syslog.
  * Syslog::Priority, Syslog::Level, Syslog::Option and Syslog::Macros
    are introduced for easy detection of available constants on a
    running system.

* tmpdir
  * incompatible changes:
    * Dir.mktmpdir uses FileUtils.remove_entry instead of
      FileUtils.remove_entry_secure.  This means that applications should not
      change the permission of the created temporary directory to make
      accessible from other users.

* yaml
  * Syck has been removed.  YAML now completely depends on libyaml being
    installed.
  * libyaml is now bundled with ruby, for cases where the library is not
    installed locally.

* zlib
  * Added streaming support for Zlib::Inflate and Zlib::Deflate.  This allows
    processing of a stream without the use of large amounts of memory.
  * Added support for the new deflate strategies Zlib::RLE and Zlib::FIXED.
  * Zlib streams are now processed without the GVL.  This allows gzip, zlib and
    deflate streams to be processed in parallel.
  * deprecated methods:
    * Zlib::GzipReader#lines and #bytes are deprecated.

=== Stdlib compatibility issues (excluding feature bug fixes)

* OpenStruct new methods can conflict with custom attributes named
  "each_pair", "eql?", "hash" or "to_h".

* Dir.mktmpdir in lib/tmpdir.rb

  See above.

=== C API updates

* NUM2SHORT() and NUM2USHORT() added. They are similar to NUM2INT, but short.

* rb_newobj_of() and NEWOBJ_OF() added. They create a new object of a given class.