nz-whois 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f88f3349e53e2a1f068ebbf0cee392299f03f94d
4
- data.tar.gz: 05b0d3e04e42e856235098c5308ce99ae3e18fad
3
+ metadata.gz: 10ea1944e4b10b7c711322ed5edd29157565acfd
4
+ data.tar.gz: 0e0aeb8cb2cbd8cc33f38c608d6331d9bdbf9f43
5
5
  SHA512:
6
- metadata.gz: d096c351f2e412950e576bc1ce6fedc68df8ec133f6045affa65cece9e2a6e6900a97648b9a3aa2332bbfba8df1d03c795a03198e5168e44128b2106965d43c1
7
- data.tar.gz: 52b1d57e8919721b5506a53151b1bfb5d2de3b772fe439adf38bc92e253792e0c6d23daddc8f5b405c2f5431331ed7c343e26eca305ad50d3278606fa46b453c
6
+ metadata.gz: ace1b1303e577d297699575fa58d7e04f2c1cf798fc89a94a45986e630cda81e4b43660462304699beeb3492d286547a7a5ee3b00bb0c535d36c5b8dba61041f
7
+ data.tar.gz: '0758b02cecd0dcff152a338964594434abf2e2f2064581f94e12f0fa088f630f864d1a083899feeb5ce29befdd3e647b9b8601dc8255e53852328bb0a7395345'
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  Gemfile.lock
2
2
  *.gem
3
+ coverage/
@@ -1,3 +1,7 @@
1
+ Metrics/BlockLength:
2
+ Exclude:
3
+ - "**/*_spec.rb"
4
+
1
5
  Naming/FileName:
2
6
  Exclude:
3
7
  - "lib/nz-whois.rb"
@@ -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
+ [![Travis Build Status](http://img.shields.io/travis/abrom/nz-whois.svg?style=flat)](https://travis-ci.org/abrom/nz-whois)
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/a9fbbd2801b9c475914d/maintainability)](https://codeclimate.com/github/abrom/nz-whois/maintainability)
3
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/a9fbbd2801b9c475914d/test_coverage)](https://codeclimate.com/github/abrom/nz-whois/test_coverage)
4
+ [![Gem Version](http://img.shields.io/gem/v/nz-whois.svg?style=flat)](#)
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 :/
@@ -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.gsub(/\.nz\z/)
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
@@ -1,3 +1,3 @@
1
1
  module NZWhois
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
@@ -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.nil?
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
@@ -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.1
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