Issue #19303 has been reported by henk (Hendrik Jäger).
----------------------------------------
Feature #19303: Resolv::IPv4::Regex variant without anchors
https://bugs.ruby-lang.org/issues/19303
* Author: henk (Hendrik Jäger)
* Status: Open
* Priority: Normal
----------------------------------------
``` ruby
require 'resolv'
p "match this IP: 10.0.0.1"[/match this IP: (#{Resolv::IPv4::Regex})/, 1]
```
This returns 'nil' because Resolv::IPv4::Regex is anchored with \A and \z.
I would like to have a variant of Resolv::IPv4::Regex available that is not anchored so that code would return '10.0.0.1'.
--
https://bugs.ruby-lang.org/
Issue #14919 has been updated by noraj (Alexandre ZANNI).
Yes a grapheme can be composed of several code points.
An example is variant selector:
```ruby
irb(main):001:0> a = "\u2665\n\u2764\n\u2665\ufe0f\n\u2764\ufe0f"
=> "♥\n❤\n♥️\n❤️"
irb(main):002:0> puts a
♥
❤
♥️
❤️
=> nil
irb(main):003:0> a.chars
=> ["♥", "\n", "❤", "\n", "♥", "️", "\n", "❤", "️"]
```
But fortunately, in Ruby, string indices are already mapping characters and not graphemes. So has Martin highlighted, `String#[]=` already cover all use cases I can think of.
```ruby
irb(main):007:0> r = "I \u2665 Ruby!"
=> "I ♥ Ruby!"
irb(main):009:0> r[2] = "\u2764\ufe0f"
=> "❤️"
irb(main):010:0> r
=> "I ❤️ Ruby!"
```
The only thing I could think of `String#byteinsert` would be to directly mess with UTF-8 encoding to forge invalid encoding on purpose. But such a use case is rare and advanced and so can maybe be handled with pack and unpack rather than creating a new byteinsert method?
```
irb(main):014:0> r.unpack1('a*')
=> "I \xE2\x9D\xA4\xEF\xB8\x8F Ruby!"
```
@aycabta Maybe you could give me a handy example of the usage of `String#byteinsert` I can't think of?
----------------------------------------
Feature #14919: Add String#byteinsert
https://bugs.ruby-lang.org/issues/14919#change-100956
* Author: aycabta (aycabta .)
* Status: Open
* Priority: Normal
----------------------------------------
It's important for multibyte String editing. Unicode grapheme characters sometimes have plural code points. In text editing, software sometimes should add a new code point to an existing grapheme character. String#byteinsert is important for it.
I implemented by pure Ruby in my code.
https://github.com/aycabta/reline/blob/b17e5fd61092adfd7e87d576301e4e19a4d9…
--
https://bugs.ruby-lang.org/
Issue #16991 has been updated by zverok (Victor Shepelev).
Status changed from Open to Closed
Implemented in Ruby 3.0
----------------------------------------
Feature #16991: Sets: add Set#join
https://bugs.ruby-lang.org/issues/16991#change-100928
* Author: marcandre (Marc-Andre Lafortune)
* Status: Closed
* Priority: Normal
----------------------------------------
I'd like to add `#join` to `Set`:
```ruby
# Now:
Set[1, 2, 3].join('x') # => NoMethodError
# After
Set[1, 2, 3].join('x') # => "1x2x3"
```
I'd make this join never recursive. (I've never wanted to use the recursivity of `Array#join`, but it may very well just be my particular experience)
Reminder: Why there is no `Enumerable#join`: https://bugs.ruby-lang.org/issues/1893
--
https://bugs.ruby-lang.org/
Issue #16995 has been updated by zverok (Victor Shepelev).
Status changed from Open to Closed
Implemented in Ruby 3.0:
```ruby
Set[1] <=> Set[1, 2]
# => -1
[Set[1], Set[1, 2]].sort
# => [#<Set: {1}>, #<Set: {1, 2}>]
```
----------------------------------------
Feature #16995: Sets: <=> should be specialized
https://bugs.ruby-lang.org/issues/16995#change-100927
* Author: marcandre (Marc-Andre Lafortune)
* Status: Closed
* Priority: Normal
----------------------------------------
This is quite minor, but `Set#<=>` should be refined.
Reminder: `Set` defines `<`, `>`, etc. as inclusion, but does not have a corresponding `<=>`:
```ruby
Set[1] < Set[1, 2] # => true
Set[1] <=> Set[1, 2] # => nil, should be -1
Set[1] <=> Set[2] # => nil, ok, not orderable
```
The official stated reason for `Set` to *not* implement is that some sets are not comparable. That is exactly what `nil` result type is for IMO. Sets are partically ordered and `<=>` should reflect that. https://en.wikipedia.org/wiki/Partially_ordered_set
```ruby
Set[1] < Set[1, 2] # => true
[Set[1], Set[1, 2]].sort # => ArgumentError, should be [Set[1], Set[1, 2]]
[Set[1], Set[2]].sort # => ArgumentError, ok, can't be ordered
```
This is *exactly the same* idea as `Class`, which correctly refines `<=>`:
```ruby
Array < Enumerable # => true
Array <=> Enumerable # => -1, ok
[Array, Enumerable].sort # => [Array, Enumerable]
[Array, String].sort # => ArgumentError (comparison of Class with Class failed), ok
```
--
https://bugs.ruby-lang.org/
Issue #3591 has been updated by e8c (Viktor Reznov).
e8c (Viktor Reznov) wrote in #note-20:
> Two solutions:
3rd:
```ruby
def count_digits(n) = n.digits.count { n.modulo(_1).zero? }
```
----------------------------------------
Feature #3591: Adding Numeric#divisor? (Have working implementation)
https://bugs.ruby-lang.org/issues/3591#change-100926
* Author: duckinator (Marie Markwell)
* Status: Rejected
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 2.6
----------------------------------------
=begin
On the 'duckinator' branch of my fork of ruby on github, I have added Numeric#divisor?:
num.divisor?(other)
is the same as:
(num % other == 0)
Example usage:
4.divisor?(2) #=> true
1.divisor?(2) #=> false
2.4.divisor?(1.2) #=> true
2.4.divisor?(1.3) #=> false
126.divisor?(9) #=> true
I think this would be a very nice feature to add, and would make code using the old (num % other == 0) method much cleaner and easier to understand.
There is a unified diff of it: http://gist.github.com/raw/484144/07b1a6e696cd9301e658ccbc8f90dfcd4d4ef3f1/…
The original commits can be seen here:
http://github.com/RockerMONO/ruby/commit/f7959f964cb0bf38418904ccb5643db6b6… -- First attempt, only worked with Integers
http://github.com/RockerMONO/ruby/commit/12376a6bb1c3ffbd4b470850dd758e2dcd… -- Second attempt, should work with anything derived from Numeric that can be used as (num % other == 0)
=end
--
https://bugs.ruby-lang.org/
Issue #3591 has been updated by e8c (Viktor Reznov).
matz (Yukihiro Matsumoto) wrote in #note-19:
> Is it more useful than `n % m == 0`?
Yes, statement `n .has_divisor? m` (or `m .divisor_of? n`) has 3 parts instead of 5, and gives a direct answer to the question.
The "problem": https://leetcode.com/problems/count-the-digits-that-divide-a-number/
Two solutions:
```ruby
def count_digits(n) = n.digits.count { n % _1 == 0 }
def count_digits(n) = n.digits.count { _1.divisor_of?(n) }
```
The first is shorter, but the second is clearer.
----------------------------------------
Feature #3591: Adding Numeric#divisor? (Have working implementation)
https://bugs.ruby-lang.org/issues/3591#change-100925
* Author: duckinator (Marie Markwell)
* Status: Rejected
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 2.6
----------------------------------------
=begin
On the 'duckinator' branch of my fork of ruby on github, I have added Numeric#divisor?:
num.divisor?(other)
is the same as:
(num % other == 0)
Example usage:
4.divisor?(2) #=> true
1.divisor?(2) #=> false
2.4.divisor?(1.2) #=> true
2.4.divisor?(1.3) #=> false
126.divisor?(9) #=> true
I think this would be a very nice feature to add, and would make code using the old (num % other == 0) method much cleaner and easier to understand.
There is a unified diff of it: http://gist.github.com/raw/484144/07b1a6e696cd9301e658ccbc8f90dfcd4d4ef3f1/…
The original commits can be seen here:
http://github.com/RockerMONO/ruby/commit/f7959f964cb0bf38418904ccb5643db6b6… -- First attempt, only worked with Integers
http://github.com/RockerMONO/ruby/commit/12376a6bb1c3ffbd4b470850dd758e2dcd… -- Second attempt, should work with anything derived from Numeric that can be used as (num % other == 0)
=end
--
https://bugs.ruby-lang.org/
Issue #19285 has been reported by zzak (Zak Scott).
----------------------------------------
Bug #19285: (docs.rlo) Split stdlib and core documents
https://bugs.ruby-lang.org/issues/19285
* Author: zzak (Zak Scott)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
It seems we merge all of the docs for stdlib and core into one for docs.ruby-lang.org, this creates weirdness like [Kernel](https://docs.ruby-lang.org/en/master/Kernel.html) which includes monkey patches for rubygems for example.
> RubyGems adds the gem method to allow activation of specific gem versions and overrides the require method on Kernel to make gems appear as if they live on the $LOAD_PATH. See the documentation of these methods for further detail.
--
https://bugs.ruby-lang.org/