whois 3.2.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. data/CHANGELOG.md +20 -0
  2. data/lib/whois/core_ext.rb +3 -1
  3. data/lib/whois/core_ext/array/extract_options.rb +2 -2
  4. data/lib/whois/core_ext/array/wrap.rb +13 -16
  5. data/lib/whois/core_ext/object/blank.rb +105 -0
  6. data/lib/whois/record/contact.rb +14 -3
  7. data/lib/whois/record/parser/base_afilias.rb +3 -4
  8. data/lib/whois/record/parser/base_cocca.rb +14 -13
  9. data/lib/whois/record/parser/base_cocca2.rb +25 -32
  10. data/lib/whois/record/parser/base_shared2.rb +1 -1
  11. data/lib/whois/record/parser/base_shared3.rb +1 -1
  12. data/lib/whois/record/parser/base_whoisd.rb +5 -6
  13. data/lib/whois/record/parser/whois.aeda.net.ae.rb +6 -8
  14. data/lib/whois/record/parser/whois.ai.rb +6 -8
  15. data/lib/whois/record/parser/whois.ati.tn.rb +1 -1
  16. data/lib/whois/record/parser/whois.cctld.by.rb +0 -1
  17. data/lib/whois/record/parser/whois.centralnic.com.rb +2 -1
  18. data/lib/whois/record/parser/whois.cira.ca.rb +1 -1
  19. data/lib/whois/record/parser/whois.cnnic.cn.rb +1 -1
  20. data/lib/whois/record/parser/whois.comlaude.com.rb +1 -1
  21. data/lib/whois/record/parser/whois.denic.de.rb +1 -1
  22. data/lib/whois/record/parser/whois.domainregistry.ie.rb +1 -1
  23. data/lib/whois/record/parser/whois.dreamhost.com.rb +1 -1
  24. data/lib/whois/record/parser/whois.educause.edu.rb +1 -1
  25. data/lib/whois/record/parser/whois.enom.com.rb +1 -1
  26. data/lib/whois/record/parser/whois.gg.rb +4 -58
  27. data/lib/whois/record/parser/whois.godaddy.com.rb +1 -1
  28. data/lib/whois/record/parser/whois.iana.org.rb +1 -1
  29. data/lib/whois/record/parser/whois.ja.net.rb +6 -8
  30. data/lib/whois/record/parser/whois.je.rb +4 -58
  31. data/lib/whois/record/parser/whois.markmonitor.com.rb +1 -1
  32. data/lib/whois/record/parser/whois.networksolutions.com.rb +1 -1
  33. data/lib/whois/record/parser/whois.nic.am.rb +10 -11
  34. data/lib/whois/record/parser/whois.nic.as.rb +4 -44
  35. data/lib/whois/record/parser/whois.nic.asia.rb +1 -1
  36. data/lib/whois/record/parser/whois.nic.bo.rb +6 -8
  37. data/lib/whois/record/parser/whois.nic.cd.rb +4 -47
  38. data/lib/whois/record/parser/whois.nic.cz.rb +4 -4
  39. data/lib/whois/record/parser/whois.nic.fr.rb +1 -1
  40. data/lib/whois/record/parser/whois.nic.hn.rb +2 -3
  41. data/lib/whois/record/parser/whois.nic.hu.rb +1 -1
  42. data/lib/whois/record/parser/whois.nic.it.rb +1 -1
  43. data/lib/whois/record/parser/whois.nic.mg.rb +4 -64
  44. data/lib/whois/record/parser/whois.nic.sn.rb +1 -1
  45. data/lib/whois/record/parser/whois.nic.tr.rb +75 -8
  46. data/lib/whois/record/parser/whois.pnina.ps.rb +10 -58
  47. data/lib/whois/record/parser/whois.register.bg.rb +6 -8
  48. data/lib/whois/record/parser/whois.register.com.rb +1 -1
  49. data/lib/whois/record/parser/whois.rnids.rs.rb +1 -1
  50. data/lib/whois/record/parser/whois.smallregistry.net.rb +1 -1
  51. data/lib/whois/record/parser/whois.srs.net.nz.rb +1 -1
  52. data/lib/whois/record/parser/whois.sx.rb +1 -1
  53. data/lib/whois/record/parser/whois.tcinet.ru.rb +1 -1
  54. data/lib/whois/record/parser/whois.ua.rb +2 -2
  55. data/lib/whois/record/parser/whois.usp.ac.fj.rb +6 -8
  56. data/lib/whois/record/scanners/base_cocca2.rb +52 -0
  57. data/lib/whois/record/scanners/whois.ati.tn.rb +0 -2
  58. data/lib/whois/record/scanners/whois.audns.net.au.rb +0 -2
  59. data/lib/whois/record/scanners/whois.cctld.by.rb +5 -6
  60. data/lib/whois/record/scanners/whois.cira.ca.rb +0 -2
  61. data/lib/whois/record/scanners/whois.dns.hr.rb +0 -2
  62. data/lib/whois/record/scanners/whois.nc.rb +0 -2
  63. data/lib/whois/record/scanners/whois.registry.net.za.rb +20 -20
  64. data/lib/whois/record/scanners/whois.rnids.rs.rb +0 -2
  65. data/lib/whois/version.rb +1 -1
  66. data/whois.gemspec +3 -3
  67. metadata +4 -2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## Release 3.2.1
4
+
5
+ - NEW: Added full whois.nic.tr parser.
6
+
7
+ - CHANGED: Updated whois.nic.hn parsers to the new response format.
8
+
9
+ - CHANGED: Updated whois.nic.as parsers to the new response format.
10
+
11
+ - CHANGED: Updated whois.nic.mg parsers to the new response format.
12
+
13
+ - CHANGED: Updated whois.nic.cd parsers to the new response format.
14
+
15
+ - CHANGED: Updated whois.je parsers to the new response format.
16
+
17
+ - CHANGED: Updated whois.gg parsers to the new response format.
18
+
19
+ - CHANGED: Updated whois.pnina.ps parsers to the new response format.
20
+
21
+ - CHANGED: Deprecate Whois::Record::Contact::TYPE_ADMIN in favor of Whois::Record::Contact::TYPE_ADMINISTRATIVE
22
+
3
23
 
4
24
  ## Release 3.2.0
5
25
 
@@ -1,7 +1,9 @@
1
1
  if defined?(ActiveSupport::VERSION) && ActiveSupport::VERSION::MAJOR == 3
2
2
  require 'active_support/core_ext/array/wrap'
3
- require 'whois/core_ext/class/attribute'
3
+ require 'active_support/core_ext/class/attribute'
4
+ require 'active_support/core_ext/object/blank'
4
5
  else
5
6
  require 'whois/core_ext/array/wrap'
6
7
  require 'whois/core_ext/class/attribute'
8
+ require 'whois/core_ext/object/blank'
7
9
  end
@@ -17,8 +17,8 @@ class Array
17
17
  # args.extract_options!
18
18
  # end
19
19
  #
20
- # options(1, 2) # => {}
21
- # options(1, 2, :a => :b) # => {:a=>:b}
20
+ # options(1, 2) # => {}
21
+ # options(1, 2, a: :b) # => {:a=>:b}
22
22
  def extract_options!
23
23
  if last.is_a?(Hash) && last.extractable_options?
24
24
  pop
@@ -7,35 +7,32 @@ class Array
7
7
  # * Otherwise, if the argument responds to +to_ary+ it is invoked, and its result returned.
8
8
  # * Otherwise, returns an array with the argument as its single element.
9
9
  #
10
- # Array.wrap(nil) # => []
11
- # Array.wrap([1, 2, 3]) # => [1, 2, 3]
12
- # Array.wrap(0) # => [0]
10
+ # Array.wrap(nil) # => []
11
+ # Array.wrap([1, 2, 3]) # => [1, 2, 3]
12
+ # Array.wrap(0) # => [0]
13
13
  #
14
14
  # This method is similar in purpose to <tt>Kernel#Array</tt>, but there are some differences:
15
15
  #
16
16
  # * If the argument responds to +to_ary+ the method is invoked. <tt>Kernel#Array</tt>
17
- # moves on to try +to_a+ if the returned value is +nil+, but <tt>Array.wrap</tt> returns
18
- # such a +nil+ right away.
17
+ # moves on to try +to_a+ if the returned value is +nil+, but <tt>Array.wrap</tt> returns
18
+ # +nil+ right away.
19
19
  # * If the returned value from +to_ary+ is neither +nil+ nor an +Array+ object, <tt>Kernel#Array</tt>
20
- # raises an exception, while <tt>Array.wrap</tt> does not, it just returns the value.
21
- # * It does not call +to_a+ on the argument, though special-cases +nil+ to return an empty array.
20
+ # raises an exception, while <tt>Array.wrap</tt> does not, it just returns the value.
21
+ # * It does not call +to_a+ on the argument, but returns an empty array if argument is +nil+.
22
22
  #
23
- # The last point is particularly worth comparing for some enumerables:
23
+ # The second point is easily explained with some enumerables:
24
24
  #
25
- # Array(:foo => :bar) # => [[:foo, :bar]]
26
- # Array.wrap(:foo => :bar) # => [{:foo => :bar}]
27
- #
28
- # Array("foo\nbar") # => ["foo\n", "bar"], in Ruby 1.8
29
- # Array.wrap("foo\nbar") # => ["foo\nbar"]
25
+ # Array(foo: :bar) # => [[:foo, :bar]]
26
+ # Array.wrap(foo: :bar) # => [{:foo=>:bar}]
30
27
  #
31
28
  # There's also a related idiom that uses the splat operator:
32
29
  #
33
30
  # [*object]
34
31
  #
35
- # which returns <tt>[nil]</tt> for +nil+, and calls to <tt>Array(object)</tt> otherwise.
32
+ # which returns <tt>[]</tt> for +nil+, but calls to <tt>Array(object)</tt> otherwise.
36
33
  #
37
- # Thus, in this case the behavior is different for +nil+, and the differences with
38
- # <tt>Kernel#Array</tt> explained above apply to the rest of +object+s.
34
+ # The differences with <tt>Kernel#Array</tt> explained above
35
+ # apply to the rest of <tt>object</tt>s.
39
36
  def self.wrap(object)
40
37
  if object.nil?
41
38
  []
@@ -0,0 +1,105 @@
1
+ # encoding: utf-8
2
+
3
+ class Object
4
+ # An object is blank if it's false, empty, or a whitespace string.
5
+ # For example, '', ' ', +nil+, [], and {} are all blank.
6
+ #
7
+ # This simplifies:
8
+ #
9
+ # if address.nil? || address.empty?
10
+ #
11
+ # ...to:
12
+ #
13
+ # if address.blank?
14
+ def blank?
15
+ respond_to?(:empty?) ? empty? : !self
16
+ end
17
+
18
+ # An object is present if it's not <tt>blank?</tt>.
19
+ def present?
20
+ !blank?
21
+ end
22
+
23
+ # Returns object if it's <tt>present?</tt> otherwise returns +nil+.
24
+ # <tt>object.presence</tt> is equivalent to <tt>object.present? ? object : nil</tt>.
25
+ #
26
+ # This is handy for any representation of objects where blank is the same
27
+ # as not present at all. For example, this simplifies a common check for
28
+ # HTTP POST/query parameters:
29
+ #
30
+ # state = params[:state] if params[:state].present?
31
+ # country = params[:country] if params[:country].present?
32
+ # region = state || country || 'US'
33
+ #
34
+ # ...becomes:
35
+ #
36
+ # region = params[:state].presence || params[:country].presence || 'US'
37
+ def presence
38
+ self if present?
39
+ end
40
+ end
41
+
42
+ class NilClass
43
+ # +nil+ is blank:
44
+ #
45
+ # nil.blank? # => true
46
+ def blank?
47
+ true
48
+ end
49
+ end
50
+
51
+ class FalseClass
52
+ # +false+ is blank:
53
+ #
54
+ # false.blank? # => true
55
+ def blank?
56
+ true
57
+ end
58
+ end
59
+
60
+ class TrueClass
61
+ # +true+ is not blank:
62
+ #
63
+ # true.blank? # => false
64
+ def blank?
65
+ false
66
+ end
67
+ end
68
+
69
+ class Array
70
+ # An array is blank if it's empty:
71
+ #
72
+ # [].blank? # => true
73
+ # [1,2,3].blank? # => false
74
+ alias_method :blank?, :empty?
75
+ end
76
+
77
+ class Hash
78
+ # A hash is blank if it's empty:
79
+ #
80
+ # {}.blank? # => true
81
+ # { key: 'value' }.blank? # => false
82
+ alias_method :blank?, :empty?
83
+ end
84
+
85
+ class String
86
+ # A string is blank if it's empty or contains whitespaces only:
87
+ #
88
+ # ''.blank? # => true
89
+ # ' '.blank? # => true
90
+ # ' '.blank? # => true
91
+ # ' something here '.blank? # => false
92
+ def blank?
93
+ self !~ /[^[:space:]]/
94
+ end
95
+ end
96
+
97
+ class Numeric #:nodoc:
98
+ # No number is blank:
99
+ #
100
+ # 1.blank? # => false
101
+ # 0.blank? # => false
102
+ def blank?
103
+ false
104
+ end
105
+ end
@@ -44,9 +44,20 @@ module Whois
44
44
  :phone, :fax, :email, :url,
45
45
  :created_on, :updated_on)
46
46
 
47
- TYPE_REGISTRANT = 1
48
- TYPE_ADMIN = 2
49
- TYPE_TECHNICAL = 3
47
+ TYPE_REGISTRANT = 1
48
+ TYPE_ADMINISTRATIVE = 2
49
+ TYPE_TECHNICAL = 3
50
+
51
+
52
+ def self.const_missing(name)
53
+ case name
54
+ when :TYPE_ADMIN
55
+ Whois.deprecate("Whois::Record::Contact::TYPE_ADMIN is now Whois::Record::Contact::TYPE_ADMINISTRATIVE")
56
+ self.const_set(name, TYPE_ADMINISTRATIVE)
57
+ else
58
+ super
59
+ end
60
+ end
50
61
 
51
62
  end
52
63
 
@@ -76,9 +76,8 @@ module Whois
76
76
  Whois.bug!(ParserError, "Unknown registrar format `#{value}'")
77
77
 
78
78
  Record::Registrar.new(
79
- :id => parts[0],
80
- :name => parts[1],
81
- :organization => parts[1]
79
+ id: parts[0],
80
+ name: parts[1]
82
81
  )
83
82
  end
84
83
  end
@@ -88,7 +87,7 @@ module Whois
88
87
  end
89
88
 
90
89
  property_supported :admin_contacts do
91
- build_contact("Admin", Whois::Record::Contact::TYPE_ADMIN)
90
+ build_contact("Admin", Whois::Record::Contact::TYPE_ADMINISTRATIVE)
92
91
  end
93
92
 
94
93
  property_supported :technical_contacts do
@@ -19,6 +19,15 @@ module Whois
19
19
  # @abstract
20
20
  class BaseCocca < Base
21
21
 
22
+ class_attribute :status_mapping
23
+
24
+ self.status_mapping = {
25
+ "active" => :registered,
26
+ "delegated" => :registered,
27
+ "not registered" => :available,
28
+ }
29
+
30
+
22
31
  property_supported :domain do
23
32
  content_for_scanner =~ /Query:\s+(.+?)\n/
24
33
  $1 || Whois.bug!(ParserError, "Unable to parse domain.")
@@ -29,16 +38,8 @@ module Whois
29
38
 
30
39
  property_supported :status do
31
40
  if content_for_scanner =~ /Status:\s+(.+?)\n/
32
- case $1.downcase
33
- when "active"
34
- :registered
35
- when "delegated"
36
- :registered
37
- when "not registered"
38
- :available
39
- else
40
- Whois.bug!(ParserError, "Unknown status `#{$1}'.")
41
- end
41
+ status = $1.downcase
42
+ self.class.status_mapping[status] || Whois.bug!(ParserError, "Unknown status `#{status}'.")
42
43
  else
43
44
  Whois.bug!(ParserError, "Unable to parse status.")
44
45
  end
@@ -75,9 +76,9 @@ module Whois
75
76
  property_supported :registrar do
76
77
  if content_for_scanner =~ /Registrar Name: (.+)\n/
77
78
  Record::Registrar.new(
78
- :name => $1,
79
- :organization => nil,
80
- :url => content_for_scanner.slice(/Registration URL: (.+)\n/, 1)
79
+ name: $1,
80
+ organization: nil,
81
+ url: content_for_scanner.slice(/Registration URL: (.+)\n/, 1)
81
82
  )
82
83
  end
83
84
  end
@@ -8,6 +8,7 @@
8
8
 
9
9
 
10
10
  require 'whois/record/parser/base'
11
+ require 'whois/record/scanners/base_cocca2.rb'
11
12
 
12
13
 
13
14
  module Whois
@@ -18,28 +19,31 @@ module Whois
18
19
  #
19
20
  # @abstract
20
21
  class BaseCocca2 < Base
22
+ include Scanners::Scannable
23
+
24
+ self.scanner = Scanners::BaseCocca2
25
+
21
26
 
22
27
  property_supported :domain do
23
- content_for_scanner.slice(/Domain Name: (.+)\n/, 1)
28
+ node("Domain Name")
24
29
  end
25
30
 
26
31
  property_supported :domain_id do
27
- content_for_scanner.slice(/Domain ID: (.+)\n/, 1)
32
+ node("Domain ID")
28
33
  end
29
34
 
35
+
30
36
  # TODO: /pending delete/ => :redemption
31
37
  # TODO: /pending purge/ => :redemption
32
38
  property_supported :status do
33
- list = statuses
39
+ list = Array.wrap(node("Domain Status")).map(&:downcase)
34
40
  case
35
- when list.empty?
36
- Whois.bug!(ParserError, "Unable to parse status.")
37
- when list.include?("available")
38
- :available
39
- when list.include?("ok")
40
- :registered
41
- else
42
- Whois.bug!(ParserError, "Unknown status `#{list.join(", ")}'.")
41
+ when list.include?("available")
42
+ :available
43
+ when list.include?("ok")
44
+ :registered
45
+ else
46
+ Whois.bug!(ParserError, "Unknown status `#{list.join(", ")}'.")
43
47
  end
44
48
  end
45
49
 
@@ -53,48 +57,37 @@ module Whois
53
57
 
54
58
 
55
59
  property_supported :created_on do
56
- if content_for_scanner =~ /Creation Date: (.+?)\n/
57
- parse_time($1)
58
- end
60
+ node("Creation Date") { |value| parse_time(value) }
59
61
  end
60
62
 
61
63
  property_supported :updated_on do
62
- if content_for_scanner =~ /Updated Date: (.+?)\n/
63
- parse_time($1)
64
- end
64
+ node("Updated Date") { |value| parse_time(value) }
65
65
  end
66
66
 
67
67
  property_supported :expires_on do
68
- if content_for_scanner =~ /Registry Expiry Date: (.+?)\n/
69
- parse_time($1)
70
- end
68
+ node("Registry Expiry Date") { |value| parse_time(value) }
71
69
  end
72
70
 
73
71
 
74
72
  property_supported :registrar do
75
- if content_for_scanner =~ /Sponsoring Registrar: (.+?)\n/
73
+ if node("Sponsoring Registrar")
76
74
  Record::Registrar.new(
77
- :name => $1,
78
- :organization => nil,
79
- :url => content_for_scanner.slice(/Sponsoring Registrar URL: (.+)\n/, 1)
75
+ id: node("Sponsoring Registrar IANA ID").presence,
76
+ name: node("Sponsoring Registrar"),
77
+ url: node("Sponsoring Registrar URL").presence
80
78
  )
81
79
  end
82
80
  end
83
81
 
84
82
 
85
83
  property_supported :nameservers do
86
- content_for_scanner.scan(/Name Server: (.+)\n/).flatten.map do |name|
87
- Record::Nameserver.new(:name => name)
84
+ Array.wrap(node("Name Server")).map do |name|
85
+ Record::Nameserver.new(name: name)
88
86
  end
89
87
  end
90
88
 
91
89
 
92
- def statuses
93
- content_for_scanner.scan(/Domain Status: (.+)\n/).flatten.map(&:downcase)
94
- end
95
-
96
-
97
- private
90
+ private
98
91
 
99
92
  def parse_time(value)
100
93
  # Hack to remove usec. Do you know a better way?
@@ -80,7 +80,7 @@ module Whois
80
80
  end
81
81
 
82
82
  property_supported :admin_contacts do
83
- build_contact("Administrative Contact", Whois::Record::Contact::TYPE_ADMIN)
83
+ build_contact("Administrative Contact", Whois::Record::Contact::TYPE_ADMINISTRATIVE)
84
84
  end
85
85
 
86
86
  property_supported :technical_contacts do
@@ -82,7 +82,7 @@ module Whois
82
82
  end
83
83
 
84
84
  property_supported :admin_contacts do
85
- build_contact("admin", Whois::Record::Contact::TYPE_ADMIN)
85
+ build_contact("admin", Whois::Record::Contact::TYPE_ADMINISTRATIVE)
86
86
  end
87
87
 
88
88
  property_supported :technical_contacts do
@@ -21,14 +21,13 @@ module Whois
21
21
  class BaseWhoisd < Base
22
22
  include Scanners::Scannable
23
23
 
24
- self.scanner = Scanners::BaseWhoisd
25
-
26
-
27
24
  class_attribute :status_mapping
25
+
28
26
  self.status_mapping = {
29
- 'paid and in zone' => :registered,
30
- 'expired' => :expired,
27
+ "paid and in zone" => :registered,
28
+ "expired" => :expired,
31
29
  }
30
+ self.scanner = Scanners::BaseWhoisd
32
31
 
33
32
 
34
33
  property_supported :domain do
@@ -88,7 +87,7 @@ module Whois
88
87
 
89
88
  property_supported :admin_contacts do
90
89
  node('admin-c') do |value|
91
- build_contact(value, Record::Contact::TYPE_ADMIN)
90
+ build_contact(value, Record::Contact::TYPE_ADMINISTRATIVE)
92
91
  end
93
92
  end
94
93