whois 3.4.5 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,4 +6,6 @@ else
6
6
  require 'whois/core_ext/array/wrap'
7
7
  require 'whois/core_ext/class/attribute'
8
8
  require 'whois/core_ext/object/blank'
9
- end
9
+ end
10
+
11
+ require 'whois/core_ext/time/calculations'
@@ -0,0 +1,32 @@
1
+ class Time
2
+
3
+ # Returns a new Time where one or more of the elements have been changed according
4
+ # to the +options+ parameter. The time options (<tt>:hour</tt>, <tt>:min</tt>,
5
+ # <tt>:sec</tt>, <tt>:usec</tt>) reset cascadingly, so if only the hour is passed,
6
+ # then minute, sec, and usec is set to 0. If the hour and minute is passed, then
7
+ # sec and usec is set to 0. The +options+ parameter takes a hash with any of these
8
+ # keys: <tt>:year</tt>, <tt>:month</tt>, <tt>:day</tt>, <tt>:hour</tt>, <tt>:min</tt>,
9
+ # <tt>:sec</tt>, <tt>:usec</tt>.
10
+ #
11
+ # Time.new(2012, 8, 29, 22, 35, 0).change(day: 1) # => Time.new(2012, 8, 1, 22, 35, 0)
12
+ # Time.new(2012, 8, 29, 22, 35, 0).change(year: 1981, day: 1) # => Time.new(1981, 8, 1, 22, 35, 0)
13
+ # Time.new(2012, 8, 29, 22, 35, 0).change(year: 1981, hour: 0) # => Time.new(1981, 8, 29, 0, 0, 0)
14
+ def change(options)
15
+ new_year = options.fetch(:year, year)
16
+ new_month = options.fetch(:month, month)
17
+ new_day = options.fetch(:day, day)
18
+ new_hour = options.fetch(:hour, hour)
19
+ new_min = options.fetch(:min, options[:hour] ? 0 : min)
20
+ new_sec = options.fetch(:sec, (options[:hour] || options[:min]) ? 0 : sec)
21
+ new_usec = options.fetch(:usec, (options[:hour] || options[:min] || options[:sec]) ? 0 : Rational(nsec, 1000))
22
+
23
+ if utc?
24
+ ::Time.utc(new_year, new_month, new_day, new_hour, new_min, new_sec, new_usec)
25
+ elsif zone
26
+ ::Time.local(new_year, new_month, new_day, new_hour, new_min, new_sec, new_usec)
27
+ else
28
+ ::Time.new(new_year, new_month, new_day, new_hour, new_min, new_sec + (new_usec.to_r / 1000000), utc_offset)
29
+ end
30
+ end unless method_defined? :change
31
+
32
+ end
@@ -87,11 +87,10 @@ module Whois
87
87
  end
88
88
 
89
89
 
90
- private
90
+ private
91
91
 
92
92
  def parse_time(value)
93
- # Hack to remove usec. Do you know a better way?
94
- Time.utc(*Time.parse(value).to_a)
93
+ Time.parse(value).change(usec: 0)
95
94
  end
96
95
 
97
96
  end
@@ -57,19 +57,19 @@ module Whois
57
57
 
58
58
  property_supported :created_on do
59
59
  node('Creation Date') do |value|
60
- Time.parse(value)
60
+ parse_time(value)
61
61
  end
62
62
  end
63
63
 
64
64
  property_supported :updated_on do
65
65
  node('Updated Date') do |value|
66
- Time.parse(value)
66
+ parse_time(value)
67
67
  end
68
68
  end
69
69
 
70
70
  property_supported :expires_on do
71
71
  node('Registrar Registration Expiration Date') do |value|
72
- Time.parse(value)
72
+ parse_time(value)
73
73
  end
74
74
  end
75
75
 
@@ -126,6 +126,10 @@ module Whois
126
126
  end
127
127
  end
128
128
 
129
+ def parse_time(value)
130
+ Time.parse(value)
131
+ end
132
+
129
133
  def value_for_phone_property(element, property)
130
134
  [
131
135
  value_for_property(element, "#{property}"),
@@ -0,0 +1,63 @@
1
+ #--
2
+ # Ruby Whois
3
+ #
4
+ # An intelligent pure Ruby WHOIS client and parser.
5
+ #
6
+ # Copyright (c) 2009-2014 Simone Carletti <weppos@weppos.net>
7
+ #++
8
+
9
+
10
+ require 'whois/record/parser/base_icann_compliant'
11
+
12
+
13
+ module Whois
14
+ class Record
15
+ class Parser
16
+
17
+ # Parser for the whois.donuts.com server.
18
+ #
19
+ # @see Whois::Record::Parser::Example
20
+ # The Example parser for the list of all available methods.
21
+ #
22
+ class WhoisDonutsCo < BaseIcannCompliant
23
+ self.scanner = Scanners::BaseIcannCompliant, {
24
+ pattern_available: /^Domain not found\.\n/
25
+ }
26
+
27
+
28
+ property_supported :domain_id do
29
+ node('Domain ID')
30
+ end
31
+
32
+
33
+ property_supported :expires_on do
34
+ node('Registry Expiry Date') do |value|
35
+ Time.parse(value)
36
+ end
37
+ end
38
+
39
+
40
+ property_supported :registrar do
41
+ return unless node('Sponsoring Registrar')
42
+ Record::Registrar.new(
43
+ id: node('Sponsoring Registrar IANA ID'),
44
+ name: node('Sponsoring Registrar'),
45
+ organization: node('Sponsoring Registrar')
46
+ )
47
+ end
48
+
49
+
50
+ private
51
+
52
+ def build_contact(element, type)
53
+ if (contact = super)
54
+ contact.id = node("#{element} ID")
55
+ end
56
+ contact
57
+ end
58
+
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -28,7 +28,7 @@ module Whois
28
28
 
29
29
  def build_contact(element, type)
30
30
  if (contact = super) && !contact.state.present?
31
- contact.state = value_for_property(element, 'State')
31
+ contact.state = node("#{element} State")
32
32
  end
33
33
  contact
34
34
  end
@@ -24,12 +24,14 @@ module Whois
24
24
 
25
25
  self.scanner = Scanners::WhoisNicCz
26
26
 
27
- self.status_mapping = {
28
- "paid and in zone" => :registered,
29
- "update prohibited" => :registered,
30
- "expired" => :expired,
31
- "to be deleted" => :expired,
32
- }
27
+ property_supported :status do
28
+ if available?
29
+ :available
30
+ else
31
+ :registered
32
+ end
33
+ end
34
+
33
35
 
34
36
  def response_throttled?
35
37
  !!node("response:throttled")
@@ -36,7 +36,7 @@ module Whois
36
36
 
37
37
  property_supported :status do
38
38
  case s = node("Status").to_s.downcase
39
- when /^ok/, "active", /\bclient/
39
+ when /^ok/, /\bclient/
40
40
  :registered
41
41
  when "grace-period", "no-provider"
42
42
  :registered
@@ -95,9 +95,10 @@ module Whois
95
95
  property_supported :registrar do
96
96
  node("Registrar") do |str|
97
97
  Record::Registrar.new(
98
- :id => str["Name"],
99
- :name => str["Name"],
100
- :organization => str["Organization"]
98
+ id: str["Name"],
99
+ name: str["Name"],
100
+ organization: str["Organization"],
101
+ url: str["Web"]
101
102
  )
102
103
  end
103
104
  end
@@ -20,6 +20,12 @@ module Whois
20
20
  # The Example parser for the list of all available methods.
21
21
  #
22
22
  class WhoisNicMg < BaseCocca2
23
+
24
+ property_supported :status do
25
+ list = Array.wrap(node("Domain Status")).map(&:downcase)
26
+ list.include?("available") ? :available : super()
27
+ end
28
+
23
29
  end
24
30
 
25
31
  end
@@ -20,12 +20,6 @@ module Whois
20
20
  # The Example parser for the list of all available methods.
21
21
  #
22
22
  class WhoisNicMu < BaseCocca2
23
-
24
- property_supported :status do
25
- list = Array.wrap(node("Domain Status")).map(&:downcase)
26
- list.include?("available") ? :available : super()
27
- end
28
-
29
23
  end
30
24
 
31
25
  end
@@ -14,16 +14,14 @@ module Whois
14
14
  class Record
15
15
  class Parser
16
16
 
17
- #
18
- # = whois.nic.net.sa parser
19
- #
20
17
  # Parser for the whois.nic.net.sa server.
21
18
  #
22
- # NOTE: This parser is just a stub and provides only a few basic methods
23
- # to check for domain availability and get domain status.
24
- # Please consider to contribute implementing missing methods.
25
- # See WhoisNicIt parser for an explanation of all available methods
26
- # and examples.
19
+ # @note This parser is just a stub and provides only a few basic methods
20
+ # to check for domain availability and get domain status.
21
+ # Please consider to contribute implementing missing methods.
22
+ #
23
+ # @see Whois::Record::Parser::Example
24
+ # The Example parser for the list of all available methods.
27
25
  #
28
26
  class WhoisNicNetSa < Base
29
27
 
@@ -36,7 +34,7 @@ module Whois
36
34
  end
37
35
 
38
36
  property_supported :available? do
39
- !!(content_for_scanner =~ /^No match\.$/)
37
+ !!(content_for_scanner =~ /^No Match for/)
40
38
  end
41
39
 
42
40
  property_supported :registered? do
@@ -45,19 +43,25 @@ module Whois
45
43
 
46
44
 
47
45
  property_supported :created_on do
48
- if content_for_scanner =~ /reg-date:\s+(.*)\n/
46
+ if content_for_scanner =~ /Created on: (.+)\n/
49
47
  Time.parse($1)
50
48
  end
51
49
  end
52
50
 
53
- property_not_supported :updated_on
51
+ property_supported :updated_on do
52
+ if content_for_scanner =~ /Last Updated on: (.+)\n/
53
+ Time.parse($1)
54
+ end
55
+ end
54
56
 
55
57
  property_not_supported :expires_on
56
58
 
57
59
 
58
60
  property_supported :nameservers do
59
- content_for_scanner.scan(/nserver:\s+(.+)\n/).flatten.map do |name|
60
- Record::Nameserver.new(:name => name)
61
+ if content_for_scanner =~ /Name Servers:\n((.+\n)+)\n/
62
+ $1.split("\n").map do |name|
63
+ Record::Nameserver.new(name: name.strip)
64
+ end
61
65
  end
62
66
  end
63
67
 
@@ -110,10 +110,8 @@ module Whois
110
110
  def build_contact(node)
111
111
  lines = node.dup
112
112
 
113
- name = lines.shift
114
- email, phone, fax = [:email, :phone, :fax].map do |attribute|
115
- lines.shift.split(":").last.strip
116
- end
113
+ fax, phone, email = 3.times.map { lines.pop.split(":", 2).last.strip.presence }
114
+ name = lines.delete_if(&:blank?).join("\n")
117
115
 
118
116
  Record::Contact.new(
119
117
  type: Whois::Record::Contact::TYPE_REGISTRANT,
@@ -0,0 +1,67 @@
1
+ #--
2
+ # Ruby Whois
3
+ #
4
+ # An intelligent pure Ruby WHOIS client and parser.
5
+ #
6
+ # Copyright (c) 2009-2014 Simone Carletti <weppos@weppos.net>
7
+ #++
8
+
9
+
10
+ require 'whois/record/parser/base_icann_compliant'
11
+
12
+
13
+ module Whois
14
+ class Record
15
+ class Parser
16
+
17
+ # Parser for the whois.donuts.com server.
18
+ #
19
+ # @see Whois::Record::Parser::Example
20
+ # The Example parser for the list of all available methods.
21
+ #
22
+ class WhoisUniregistryNet < BaseIcannCompliant
23
+ self.scanner = Scanners::BaseIcannCompliant, {
24
+ pattern_available: />>> Domain \".+\" is available/
25
+ }
26
+
27
+
28
+ property_supported :domain_id do
29
+ node('Domain ID')
30
+ end
31
+
32
+
33
+ property_supported :expires_on do
34
+ node('Registry Expiry Date') do |value|
35
+ parse_time(value)
36
+ end
37
+ end
38
+
39
+
40
+ property_supported :registrar do
41
+ return unless node('Sponsoring Registrar')
42
+ Record::Registrar.new(
43
+ id: node('Sponsoring Registrar IANA ID'),
44
+ name: node('Sponsoring Registrar'),
45
+ organization: node('Sponsoring Registrar')
46
+ )
47
+ end
48
+
49
+
50
+ private
51
+
52
+ def build_contact(element, type)
53
+ if (contact = super)
54
+ contact.id = node("#{element} ID")
55
+ end
56
+ contact
57
+ end
58
+
59
+ def parse_time(value)
60
+ Time.parse(value).change(usec: 0)
61
+ end
62
+
63
+ end
64
+
65
+ end
66
+ end
67
+ end
data/lib/whois/version.rb CHANGED
@@ -12,8 +12,8 @@ module Whois
12
12
  # Holds information about library version.
13
13
  module Version
14
14
  MAJOR = 3
15
- MINOR = 4
16
- PATCH = 5
15
+ MINOR = 5
16
+ PATCH = 0
17
17
  BUILD = nil
18
18
 
19
19
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join(".")
data/whois.gemspec CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Simone Carletti"]
9
- s.date = "2014-03-06"
9
+ s.date = "2014-03-10"
10
10
  s.description = "Whois is an intelligent WHOIS client and parser written in pure Ruby. It can query registry data for IPv4, IPv6 and top level domains, parse and convert responses into easy-to-use Ruby objects."
11
11
  s.email = ["weppos@weppos.net"]
12
12
  s.executables = ["ruby-whois"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whois
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.5
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simone Carletti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-06 00:00:00.000000000 Z
11
+ date: 2014-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -94,6 +94,7 @@ files:
94
94
  - lib/whois/core_ext/kernel/singleton_class.rb
95
95
  - lib/whois/core_ext/module/remove_method.rb
96
96
  - lib/whois/core_ext/object/blank.rb
97
+ - lib/whois/core_ext/time/calculations.rb
97
98
  - lib/whois/core_ext.rb
98
99
  - lib/whois/errors.rb
99
100
  - lib/whois/record/contact.rb
@@ -153,6 +154,7 @@ files:
153
154
  - lib/whois/record/parser/whois.domainregistry.ie.rb
154
155
  - lib/whois/record/parser/whois.domainregistry.my.rb
155
156
  - lib/whois/record/parser/whois.domreg.lt.rb
157
+ - lib/whois/record/parser/whois.donuts.co.rb
156
158
  - lib/whois/record/parser/whois.dot.cf.rb
157
159
  - lib/whois/record/parser/whois.dot.tk.rb
158
160
  - lib/whois/record/parser/whois.dotmobiregistry.net.rb
@@ -298,6 +300,7 @@ files:
298
300
  - lib/whois/record/parser/whois.tznic.or.tz.rb
299
301
  - lib/whois/record/parser/whois.ua.rb
300
302
  - lib/whois/record/parser/whois.udag.net.rb
303
+ - lib/whois/record/parser/whois.uniregistry.net.rb
301
304
  - lib/whois/record/parser/whois.usp.ac.fj.rb
302
305
  - lib/whois/record/parser/whois.verisign-grs.com.rb
303
306
  - lib/whois/record/parser/whois.website.ws.rb