Project

General

Profile

Actions

Feature #4788

closed

resolv.rb refactoring

Added by metanest (Makoto Kishimoto) over 13 years ago. Updated over 10 years ago.

Status:
Closed
Target version:
[ruby-dev:43587]

Description

このようなモンキーパッチが(私のコードではありませんが)
https://github.com/ioquatix/rubydns/blob/master/lib/rubydns/resolv.rb
#3835[ruby-core:32407] )の結果、動かなくなっていたのでパッチを検討していたわけですが、
結論としてresolv.rbに以下のようなリファクタリングを施すのがいいのではないかと考えました。
パッチを添付します。


diff --git a/lib/resolv.rb b/lib/resolv.rb
index 1e18893..e9c2432 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -491,6 +491,12 @@ class Resolv
# #getresource for argument details.

 def each_resource(name, typeclass, &proc)
  •  each_resource_(name, typeclass) {|reply, reply_name|
    
  •    extract_resources(reply, reply_name, typeclass, &proc)
    
  •  }
    
  • end
  • def each_resource_(name, typeclass)
    lazy_initialize
    requester = make_udp_requester
    senders = {}
    @@ -517,7 +523,7 @@ class Resolv
    # response will not fit in an untruncated UDP packet.
    redo
    else
  •          extract_resources(reply, reply_name, typeclass, &proc)
    
  •          yield(reply, reply_name)
           end
           return
         when RCode::NXDomain
    

Files

resolv_rb_patch.txt (823 Bytes) resolv_rb_patch.txt metanest (Makoto Kishimoto), 05/27/2011 05:01 PM
resolv_rb_patch.txt (823 Bytes) resolv_rb_patch.txt method name updated metanest (Makoto Kishimoto), 07/14/2011 03:46 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0