Permalink
Browse files

Deprecated Whois::Answer::Part#response.

  • Loading branch information...
1 parent 2903cd9 commit 6e963ee5b327f34525ec51ae862baff9db9d94e8 @weppos committed Sep 21, 2010
View
@@ -1,6 +1,11 @@
= Changelog
+== master
+
+* CHANGED: Deprecated Whois::Answer::Part#response.
+
+
== Release 1.3.5
* SERVER: Updated the .so TLD definition (#36).
View
@@ -82,7 +82,7 @@ def eql?(other)
# String:: The content of this answer.
#
def content
- @content ||= parts.map(&:response).join("\n")
+ @content ||= parts.map(&:body).join("\n")
end
@@ -206,7 +206,7 @@ def part
# That said, the only constraints about this method is to return the data to be parsed as string.
#
def content
- part.response
+ part.body
end
View
@@ -23,13 +23,33 @@ class Answer
#
# = Part
#
- # A single <tt>Whois::Answer</tt> fragment. For instance,
- # in case of thin server, a <tt>Whois::Answer</tt> may be composed by
- # one or more parts corresponding to all responses
+ # A single <tt>Whois::Answer</tt> fragment. For instance,
+ # in case of thin server, a <tt>Whois::Answer</tt> may be composed by
+ # one or more parts corresponding to all responses
# returned by the WHOIS servers.
#
- class Part < SuperStruct.new(:response, :host)
+ # A <tt>Part</tt> is composed by the following attributes:
+ #
+ # * body - The body containing the whois output.
+ # * host - The host which returned the body.
+ #
+ class Part < SuperStruct.new(:body, :host)
+
+ def response=(value) # :nodoc:
+ Whois.deprecate \
+ "Whois::Answer::Part#response= is deprecated " \
+ "and will be removed in Whois 1.5. Use Whois::Answer::Part#body=."
+ self.body = value
+ end
+
+ def response # :nodoc:
+ Whois.deprecate \
+ "Whois::Answer::Part#response is deprecated " \
+ "and will be removed in Whois 1.5. Use Whois::Answer::Part#body."
+ self.body
+ end
+
end
end
-end
+end
@@ -21,7 +21,7 @@ def test_initialize_should_require_part
def test_content
parser = @klass.new(@part)
- assert_equal @part.response, parser.content
+ assert_equal @part.body, parser.content
end
def test_content_for_scanner
@@ -0,0 +1,59 @@
+require 'test_helper'
+
+class Whois::Answer::PartTest < Test::Unit::TestCase
+
+ def setup
+ @klass = Whois::Answer::Part
+ end
+
+ def test_initialize_with_empty_values
+ instance = @klass.new
+ assert_instance_of @klass, instance
+ assert_equal nil, instance.body
+
+ instance = @klass.new({})
+ assert_instance_of @klass, instance
+ assert_equal nil, instance.body
+ end
+
+ def test_initialize_with_params
+ instance = @klass.new("This is a WHOIS record.", "whois.example.test")
+
+ assert_equal "This is a WHOIS record.", instance.body
+ assert_equal "whois.example.test", instance.host
+ end
+
+ def test_initialize_with_hash
+ instance = @klass.new(:body => "This is a WHOIS record.", :host => "whois.example.test")
+
+ assert_equal "This is a WHOIS record.", instance.body
+ assert_equal "whois.example.test", instance.host
+ end
+
+ def test_initialize_with_block
+ instance = @klass.new do |c|
+ c.body = "This is a WHOIS record."
+ c.host = "whois.example.test"
+ end
+
+ assert_equal "This is a WHOIS record.", instance.body
+ assert_equal "whois.example.test", instance.host
+ end
+
+
+ def test_deprecated_response_setter
+ instance = @klass.new(:host => "whois.example.test")
+ instance.response = "This is a WHOIS record."
+
+ assert_equal "This is a WHOIS record.", instance.body
+ assert_equal "whois.example.test", instance.host
+ end
+
+ def test_deprecated_response_getter
+ instance = @klass.new(:body => "This is a WHOIS record.", :host => "whois.example.test")
+
+ assert_equal "This is a WHOIS record.", instance.response
+ assert_equal "whois.example.test", instance.host
+ end
+
+end

0 comments on commit 6e963ee

Please sign in to comment.