nz-whois 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +4 -0
- data/.travis.yml +30 -0
- data/README.md +5 -0
- data/lib/nz-whois/client.rb +3 -1
- data/lib/nz-whois/gem_version.rb +1 -1
- data/lib/nz-whois/parser.rb +10 -2
- data/nz-whois.gemspec +1 -0
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10ea1944e4b10b7c711322ed5edd29157565acfd
|
4
|
+
data.tar.gz: 0e0aeb8cb2cbd8cc33f38c608d6331d9bdbf9f43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ace1b1303e577d297699575fa58d7e04f2c1cf798fc89a94a45986e630cda81e4b43660462304699beeb3492d286547a7a5ee3b00bb0c535d36c5b8dba61041f
|
7
|
+
data.tar.gz: '0758b02cecd0dcff152a338964594434abf2e2f2064581f94e12f0fa088f630f864d1a083899feeb5ce29befdd3e647b9b8601dc8255e53852328bb0a7395345'
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.travis.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
env:
|
2
|
+
global:
|
3
|
+
- CC_TEST_REPORTER_ID=ed7d1bb3e103154083e313b9536b2d0e6f76539d2b866505d60edb20671adf5a
|
4
|
+
|
5
|
+
language: ruby
|
6
|
+
|
7
|
+
rvm:
|
8
|
+
- 2.1
|
9
|
+
- 2.2
|
10
|
+
- 2.3
|
11
|
+
- 2.4
|
12
|
+
|
13
|
+
before_install:
|
14
|
+
- gem update bundler
|
15
|
+
|
16
|
+
install:
|
17
|
+
- bundle install --jobs=3 --retry=3
|
18
|
+
- gem install rubocop
|
19
|
+
|
20
|
+
before_script:
|
21
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
22
|
+
- chmod +x ./cc-test-reporter
|
23
|
+
- ./cc-test-reporter before-build
|
24
|
+
|
25
|
+
script:
|
26
|
+
- rubocop
|
27
|
+
- bundle exec rake
|
28
|
+
|
29
|
+
after_script:
|
30
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/README.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
[](https://travis-ci.org/abrom/nz-whois)
|
2
|
+
[](https://codeclimate.com/github/abrom/nz-whois/maintainability)
|
3
|
+
[](https://codeclimate.com/github/abrom/nz-whois/test_coverage)
|
4
|
+
[](#)
|
5
|
+
|
1
6
|
# New Zealand whois scraper
|
2
7
|
|
3
8
|
Since the NZ DNC block port 43 whois, instead we need to scrape their website :/
|
data/lib/nz-whois/client.rb
CHANGED
@@ -22,7 +22,7 @@ module NZWhois
|
|
22
22
|
# @return Client instance (`self`)
|
23
23
|
#
|
24
24
|
def whois(domain)
|
25
|
-
raise InvalidDomainError unless domain.to_s
|
25
|
+
raise InvalidDomainError unless domain.to_s =~ /\.nz\z/i
|
26
26
|
fetch_content domain
|
27
27
|
self
|
28
28
|
end
|
@@ -56,6 +56,8 @@ module NZWhois
|
|
56
56
|
@status = f.status.first
|
57
57
|
@content = f.read
|
58
58
|
end
|
59
|
+
rescue OpenURI::HTTPError => e
|
60
|
+
@status = e.message.strip
|
59
61
|
end
|
60
62
|
|
61
63
|
def parser
|
data/lib/nz-whois/gem_version.rb
CHANGED
data/lib/nz-whois/parser.rb
CHANGED
@@ -12,7 +12,7 @@ module NZWhois
|
|
12
12
|
|
13
13
|
def valid_whois?
|
14
14
|
return @valid_whois if defined? @valid_whois
|
15
|
-
@valid_whois = !whois_content.
|
15
|
+
@valid_whois = !whois_content.empty? && !request_denied?
|
16
16
|
end
|
17
17
|
|
18
18
|
def status
|
@@ -40,18 +40,22 @@ module NZWhois
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def registrar
|
43
|
+
return unless valid_whois?
|
43
44
|
Contact.new self, 'Registrar'
|
44
45
|
end
|
45
46
|
|
46
47
|
def registrant_contact
|
48
|
+
return unless valid_whois?
|
47
49
|
Contact.new self, 'Registrant Contact'
|
48
50
|
end
|
49
51
|
|
50
52
|
def admin_contact
|
53
|
+
return unless valid_whois?
|
51
54
|
Contact.new self, 'Admin Contact'
|
52
55
|
end
|
53
56
|
|
54
57
|
def technical_contact
|
58
|
+
return unless valid_whois?
|
55
59
|
Contact.new self, 'Technical Contact'
|
56
60
|
end
|
57
61
|
|
@@ -73,8 +77,12 @@ module NZWhois
|
|
73
77
|
@whois_content ||= page.xpath("//*[@id='block-dnc-content']")
|
74
78
|
end
|
75
79
|
|
80
|
+
def request_denied?
|
81
|
+
page.css('.page-title').text.include? '(Request Denied)'
|
82
|
+
end
|
83
|
+
|
76
84
|
def contents_for(description)
|
77
|
-
return unless valid_whois?
|
85
|
+
return [] unless valid_whois?
|
78
86
|
|
79
87
|
whois_content.xpath("//td/*[text() = '#{description}']").map do |element|
|
80
88
|
element.ancestors('td').first.next_element.text
|
data/nz-whois.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency 'rake', '~> 10.0'
|
27
27
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
28
|
spec.add_development_dependency 'rubocop', '~> 0.52'
|
29
|
+
spec.add_development_dependency 'shoulda-matchers', '~> 3.1'
|
29
30
|
spec.add_development_dependency 'simplecov', '~> 0.15'
|
30
31
|
spec.add_development_dependency 'webmock', '~> 3.2'
|
31
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nz-whois
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- abrom
|
@@ -86,6 +86,20 @@ dependencies:
|
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0.52'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: shoulda-matchers
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '3.1'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '3.1'
|
89
103
|
- !ruby/object:Gem::Dependency
|
90
104
|
name: simplecov
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +137,7 @@ extra_rdoc_files: []
|
|
123
137
|
files:
|
124
138
|
- ".gitignore"
|
125
139
|
- ".rubocop.yml"
|
140
|
+
- ".travis.yml"
|
126
141
|
- Gemfile
|
127
142
|
- LICENSE
|
128
143
|
- README.md
|