Project

General

Profile

Actions

Bug #5305

closed

YAML::DBM#update、#replace のコメントの間違いを修正する

Added by sho-h (Sho Hashimoto) over 12 years ago. Updated over 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.4dev (2011-09-19 trunk 33297) [x86_64-linux]
Backport:
[ruby-dev:44485]

Description

YAML::DBM#update、#replace のコメントに each メソッドや each_pair
メソッドがあれば引数として指定できる旨の記述がありますが、実際には
keys.each しているため、正しくないようです。

Updated by ayumin (Ayumu AIZAWA) over 12 years ago

  • ruby -v changed from ruby 1.9.4dev (2011-09-10 trunk 33240) [x86_64-linux] to -

Hi Guys,

The comments of YAML::DBM#update and #replace says it requires only
'each and each_pair', but they are using 'keys.each' actually.

I think the comment should be modified, so I hope someone provide a draft.

Following is the original comment of YAML#update and #replace:
#update:
"Updates the database with multiple values from the specified object.
Takes any object which implements the each_pair method, including Hash
and DBM objects. Returns +self+."

#replace:
"Replaces the contents of the database with the contents of the
specified object.
Takes any object which implements the each_pair method, including Hash and
DBM objects."

Regards

Ayumu AIZAWA

Updated by ayumin (Ayumu AIZAWA) over 12 years ago

  • Assignee set to ayumin (Ayumu AIZAWA)
  • Target version set to 2.0.0
  • ruby -v changed from - to ruby 1.9.4dev (2011-09-19 trunk 33297) [x86_64-linux]

I think, YAML::DBM#update be able to rewrite without #keys.

--- lib/yaml/dbm.rb
+++ lib/yaml/dbm.rb
@@ -185,8 +185,8 @@ class DBM < ::DBM
#
# Returns +self+.
def update( hsh )

  •    hsh.keys.each do |k|
    
  •        self.store( k, hsh.fetch( k ) )
    
  •    hsh.each_pair do |k,v|
    
  •        self.store( k, v )
       end
       self
    
    end

But there are no test for YAML::DBM, so I'm writing test for these now.
After my work, this issue would be closed.

Actions #3

Updated by ayumin (Ayumu AIZAWA) over 12 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r33329.
Sho, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


Actions

Also available in: Atom PDF

Like0
Like0Like0Like0