domain_expiry 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +30 -0
- data/.travis.yml +34 -0
- data/CHANGELOG.md +5 -0
- data/CODEOWNERS +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +71 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/domain_expiry.gemspec +31 -0
- data/exe/check-domain +64 -0
- data/lib/domain_expiry/version.rb +3 -0
- data/lib/domain_expiry.rb +79 -0
- data/spec/domain_expiry_spec.rb +29 -0
- data/spec/spec_helper.rb +26 -0
- metadata +162 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b78066138505f44ebc43f9fa4a6384ffca6ba635
|
4
|
+
data.tar.gz: 194dcecfefc7b3562c6592173dfbfb190b51ce4c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0db053808cff224f72d1f453a51d57bc74ee800e268672e5b08a5084fd16b9830abc21e9b66d490e3cc804428da68a7c7323ba6bc5ab51a5a6f2f46ab9d99cfb
|
7
|
+
data.tar.gz: 4abd3c07d9d828f41c633446b96c82885ada8e20cac7552f70eb846b80b5293acf29a0bf995b28fe4ba0d24c41cb74c598aa58bacb413c082068ec82a03a2c97
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
Layout/IndentationWidth:
|
2
|
+
Width: 4
|
3
|
+
|
4
|
+
Metrics/AbcSize:
|
5
|
+
Max: 50
|
6
|
+
|
7
|
+
Metrics/LineLength:
|
8
|
+
Max: 180
|
9
|
+
|
10
|
+
Metrics/BlockLength:
|
11
|
+
Max: 40
|
12
|
+
|
13
|
+
Metrics/CyclomaticComplexity:
|
14
|
+
Max: 20
|
15
|
+
|
16
|
+
Metrics/MethodLength:
|
17
|
+
Max: 60
|
18
|
+
|
19
|
+
Metrics/PerceivedComplexity:
|
20
|
+
Max: 20
|
21
|
+
|
22
|
+
Style/GlobalVars:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/RaiseArgs:
|
26
|
+
EnforcedStyle: compact
|
27
|
+
|
28
|
+
Style/WordArray:
|
29
|
+
EnforcedStyle: brackets
|
30
|
+
|
data/.travis.yml
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
sudo: required
|
2
|
+
matrix:
|
3
|
+
include:
|
4
|
+
- language: ruby
|
5
|
+
rvm: 2.2
|
6
|
+
before_install:
|
7
|
+
- gem install bundler -v 1.16.1
|
8
|
+
- language: ruby
|
9
|
+
rvm: 2.4.4
|
10
|
+
before_install:
|
11
|
+
- gem install bundler -v 1.17.3
|
12
|
+
- language: ruby
|
13
|
+
env: SKIP_INTERPRETER=true
|
14
|
+
|
15
|
+
rvm: 2.4.4
|
16
|
+
before_install:
|
17
|
+
- git clone https://github.com/TravisToolbox/rubocop-travis.git
|
18
|
+
install:
|
19
|
+
- ./rubocop-travis/install.sh
|
20
|
+
script:
|
21
|
+
- ./rubocop-travis/scan.sh
|
22
|
+
- language: ruby
|
23
|
+
rvm: 2.2
|
24
|
+
before_install:
|
25
|
+
- mkdir travis
|
26
|
+
- git clone https://github.com/TravisToolbox/awesomebot-travis.git travis/awesomebot
|
27
|
+
install:
|
28
|
+
- ./travis/awesomebot/install.sh
|
29
|
+
script:
|
30
|
+
- ./travis/awesomebot/scan.sh
|
31
|
+
notifications:
|
32
|
+
email: false
|
33
|
+
slack:
|
34
|
+
secure: cm2g/oSbcI0fMNzEzEI+pD4jSoKjTDbMv/GzZCxH9qMMgpnF6Oh2UodjdHlV4D3TJ1QeeEZvalxj5zXMuofMSC80e+h+Iuw/ZkZFyYJ8tIzpJzmQ063nOy/yCGdFVrL//v1kQi033Oo/f4E3k94l7CQyYIIx5NbJjVrqlRIBpaAgv35Bu+CDgl8JSVJyRKmccYP9gfr+YbjUCnbVbv6WwdtF3P/wzixtNHdJ+l+yDdXZZTnAewEO0aZVkNmX2zfnwyqZhOU+ZhxXqn61ck7/xGRm/yn6q/Rxz12I2+TR4/qBYo4SSuw/+AbUe9lXXFXNK9Knv+PNNT85kwGX/wxFSNsD5htEvJ1FIyX/YHH0zqnMJa0LCclJqxiTwkbo4YZpb3Ml81Nld1yFXxfhdOrSC5UVeC94XYSSXAeIj3UvRof7K2/pyP7IHRxczvAZVxUMQa+eRy7oZ/T9KfqkLKiU+ih5dZoP53it/o2X5AnKJmLI4wR4g0oKTX4eTJqQVRiq3pY4VGkhNCVJEDDRqJWfYwEGXx1JAb4v4oxTrjNgfw5oOPpy1MjtvfQ9Wf2T4Rh4n1FH6TcmgWCx2KzgMF+y7Ezc/ZbmU1uLnBI8Fn5VVuWlgJSAa14RGsNA02Q+90Bu7a014dG8P3dY0BMnSzIa1QOg9Ea5zUPS7NfnFKf2d38=
|
data/CHANGELOG.md
ADDED
data/CODEOWNERS
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at tim.gurney@timgurney.net. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Tim Gurney
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
[![Build Status](https://img.shields.io/travis/AntiPhotonltd/domain_expiry/master.svg)](https://travis-ci.org/AntiPhotonltd/domain_expiry)
|
2
|
+
[![Software License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md)
|
3
|
+
[![Release](https://img.shields.io/github/release/AntiPhotonltd/domain_expiry.svg)](https://github.com/AntiPhotonltd/domain_expiry/releases/latest)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/domain_expiry.svg)](https://badge.fury.io/rb/domain_expiry)
|
5
|
+
[![Github commits (since latest release)](https://img.shields.io/github/commits-since/AntiPhotonltd/domain_expiry/latest.svg)](https://github.com/AntiPhotonltd/domain_expiry/commits)
|
6
|
+
[![GitHub repo size in bytes](https://img.shields.io/github/repo-size/AntiPhotonltd/domain_expiry.svg)](https://github.com/AntiPhotonltd/domain_expiry)
|
7
|
+
[![GitHub contributors](https://img.shields.io/github/contributors/AntiPhotonltd/domain_expiry.svg)](https://github.com/AntiPhotonltd/domain_expiry)
|
8
|
+
|
9
|
+
# DomainExpiry
|
10
|
+
|
11
|
+
This is a simple little gem for checking when a domain will expire.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'domain_expiry'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install domain_expiry
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'domain_expiry'
|
33
|
+
|
34
|
+
DomainExpiry::DomainExpiry.domain_details('antiphoton.com')
|
35
|
+
```
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
require 'domain_expiry'
|
39
|
+
|
40
|
+
results = DomainExpiry::DomainExpiry.domain_details(['antiphoton.com','wolfsoftware.com'])
|
41
|
+
DomainExpiry::DomainExpiry.display_results(results)
|
42
|
+
|
43
|
+
------------------------------------------------------------------------------------------------------------------------
|
44
|
+
Domain | Status
|
45
|
+
------------------------------------------------------------------------------------------------------------------------
|
46
|
+
antiphoton.com | expires on 11 Oct 2020 (in 598 days)
|
47
|
+
wolfsoftware.com | expires on 24 Jan 2022 (in 1068 days)
|
48
|
+
------------------------------------------------------------------------------------------------------------------------
|
49
|
+
```
|
50
|
+
|
51
|
+
## Development
|
52
|
+
|
53
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
54
|
+
|
55
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
56
|
+
|
57
|
+
## Testing
|
58
|
+
|
59
|
+
For local testing make sure that you run `bundle exec rspec spec` and then `rake install` to install the gem locally.
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/AntiPhotonltd/domain_expiry. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
64
|
+
|
65
|
+
## License
|
66
|
+
|
67
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
68
|
+
|
69
|
+
## Code of Conduct
|
70
|
+
|
71
|
+
Everyone interacting in the DomainExpiry project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/AntiPhotonltd/domain_expiry/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "DomainExpiry"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'domain_expiry/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'domain_expiry'
|
8
|
+
spec.version = DomainExpiry::VERSION
|
9
|
+
spec.authors = ['Tim Gurney aka Wolf']
|
10
|
+
spec.email = ['wolf@tgwolf.com']
|
11
|
+
|
12
|
+
spec.summary = %q{A simple gem checking for domain expiry.}
|
13
|
+
spec.description = %q{A simple gem checking for domain expiry.}
|
14
|
+
spec.homepage = 'https://github.com/AntiPhotonltd/domain_expiry'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'whois', '~> 4.0'
|
27
|
+
spec.add_development_dependency 'whois-parser', '~> 1.1'
|
28
|
+
|
29
|
+
spec.add_runtime_dependency 'whois', '~> 4.0'
|
30
|
+
spec.add_runtime_dependency 'whois-parser', '~> 1.1'
|
31
|
+
end
|
data/exe/check-domain
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'domain_expiry'
|
5
|
+
|
6
|
+
# -------------------------------------------------------------------------------- #
|
7
|
+
# Process Arguments #
|
8
|
+
# -------------------------------------------------------------------------------- #
|
9
|
+
# This function will process the input from the command line and work out what it #
|
10
|
+
# is that the user wants to see. #
|
11
|
+
# #
|
12
|
+
# This is the main processing function where all the processing logic is handled. #
|
13
|
+
# -------------------------------------------------------------------------------- #
|
14
|
+
|
15
|
+
def process_arguments
|
16
|
+
options = {}
|
17
|
+
# Enforce the presence of
|
18
|
+
mandatory = %I[domain]
|
19
|
+
|
20
|
+
optparse = OptionParser.new do |opts|
|
21
|
+
opts.banner = "Usage: #{$PROGRAM_NAME}"
|
22
|
+
|
23
|
+
opts.on('-h', '--help', 'Display this screen') do
|
24
|
+
puts opts
|
25
|
+
exit(1)
|
26
|
+
end
|
27
|
+
opts.on('-d', '--domain string', 'The domain name to check') do |domain|
|
28
|
+
options[:domain] = domain
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
begin
|
33
|
+
optparse.parse!
|
34
|
+
options[:message] = ARGF.read if !STDIN.tty? # override message parameter if data is piped in
|
35
|
+
missing = mandatory.select { |param| options[param].nil? }
|
36
|
+
raise OptionParser::MissingArgument.new(missing.join(', ')) unless missing.empty?
|
37
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
|
38
|
+
puts e.to_s
|
39
|
+
puts optparse
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
|
43
|
+
results = DomainExpiry::DomainExpiry.domain_details(options[:domain])
|
44
|
+
DomainExpiry::DomainExpiry.display_results(results)
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
# -------------------------------------------------------------------------------- #
|
49
|
+
# Main() #
|
50
|
+
# -------------------------------------------------------------------------------- #
|
51
|
+
# The main function where all of the heavy lifting and script config is done. #
|
52
|
+
# -------------------------------------------------------------------------------- #
|
53
|
+
|
54
|
+
def main
|
55
|
+
process_arguments
|
56
|
+
end
|
57
|
+
|
58
|
+
main
|
59
|
+
|
60
|
+
# -------------------------------------------------------------------------------- #
|
61
|
+
# End of Script #
|
62
|
+
# -------------------------------------------------------------------------------- #
|
63
|
+
# This is the end - nothing more to see here. #
|
64
|
+
# -------------------------------------------------------------------------------- #
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'domain_expiry/version'
|
2
|
+
|
3
|
+
require 'whois'
|
4
|
+
require 'whois-parser'
|
5
|
+
|
6
|
+
#
|
7
|
+
# Docs to follow
|
8
|
+
#
|
9
|
+
module DomainExpiry
|
10
|
+
#
|
11
|
+
# docs to follow
|
12
|
+
#
|
13
|
+
class DomainExpiry
|
14
|
+
def self.registered?(domain)
|
15
|
+
whois = Whois::Client.new
|
16
|
+
r = whois.lookup(domain).parser
|
17
|
+
|
18
|
+
r.registered?
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.available?(domain)
|
22
|
+
whois = Whois::Client.new
|
23
|
+
r = whois.lookup(domain).parser
|
24
|
+
|
25
|
+
r.available?
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.domain_details(domains, date_format = '%d %b %Y')
|
29
|
+
results = {}
|
30
|
+
|
31
|
+
domains = domains.split(',') unless domains.is_a?
|
32
|
+
whois = Whois::Client.new
|
33
|
+
|
34
|
+
domains.each do |domain|
|
35
|
+
begin
|
36
|
+
whois_result = whois.lookup(domain).parser
|
37
|
+
rescue Timeout::Error, Errno::ECONNRESET, Whois::ConnectionError
|
38
|
+
results[domain] = { 'status' => 400, 'error' => 'Connection error' }
|
39
|
+
next
|
40
|
+
rescue Whois::ServerNotFound
|
41
|
+
results[domain] = { 'status' => 400, 'error' => 'Server not found error' }
|
42
|
+
next
|
43
|
+
end
|
44
|
+
|
45
|
+
begin
|
46
|
+
if whois_result.registered?
|
47
|
+
expires_on = DateTime.parse(whois_result.expires_on.to_s)
|
48
|
+
num_days = (expires_on - DateTime.now).to_i
|
49
|
+
|
50
|
+
results[domain] = { 'status' => 200, 'expires_on' => expires_on.strftime(date_format), 'expires_in' => num_days }
|
51
|
+
else
|
52
|
+
results[domain] = { 'status' => 400, 'error' => 'Unregistered domain' }
|
53
|
+
end
|
54
|
+
rescue StandardError
|
55
|
+
results[domain] = results = { 'status' => 400, 'error' => 'Parsing error' }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
results.sort
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.display_results(results, width = 120)
|
62
|
+
delim = '-' * width
|
63
|
+
|
64
|
+
puts(delim)
|
65
|
+
printf(' %-30s | %<status>s\n', 'Domain', status: 'Status')
|
66
|
+
puts(delim)
|
67
|
+
|
68
|
+
results.each do |domain, details|
|
69
|
+
status = if details['status'] == 400
|
70
|
+
details['error']
|
71
|
+
else
|
72
|
+
format('expires on %<expires_in>s (in %<expires_on>s days)', expires_in: details['expires_on'], expires_on: details['expires_in'])
|
73
|
+
end
|
74
|
+
printf(' %-30s | %s\n', domain, status)
|
75
|
+
end
|
76
|
+
puts(delim)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'domain_expiry'
|
2
|
+
|
3
|
+
RSpec.describe DomainExpiry do
|
4
|
+
it 'has a version number' do
|
5
|
+
expect(DomainExpiry::VERSION).not_to be nil
|
6
|
+
end
|
7
|
+
|
8
|
+
context 'Simple Tests' do
|
9
|
+
before(:each) do
|
10
|
+
@c = DomainExpiry::DomainExpiry
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'available? = false for antiphoton.com' do
|
14
|
+
expect(@c.available?('antiphoton.com')).to eql(false)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'registered? = true for antiphoton.com' do
|
18
|
+
expect(@c.registered?('antiphoton.com')).to eql(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'available? = true for iamnotgoingtoberegisteredandonlyusedfortesting.com' do
|
22
|
+
expect(@c.available?('iamnotgoingtoberegisteredandonlyusedfortesting.com')).to eql(true)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'registered? = false for iamnotgoingtoberegisteredandonlyusedfortesting.com' do
|
26
|
+
expect(@c.registered?('iamnotgoingtoberegisteredandonlyusedfortesting.com')).to eql(false)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'domain_expiry'
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
# Enable flags like --only-failures and --next-failure
|
6
|
+
config.example_status_persistence_file_path = '.rspec_status'
|
7
|
+
|
8
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
9
|
+
config.disable_monkey_patching!
|
10
|
+
|
11
|
+
config.expect_with :rspec do |c|
|
12
|
+
c.syntax = :expect
|
13
|
+
end
|
14
|
+
|
15
|
+
original_stderr = $stderr
|
16
|
+
original_stdout = $stdout
|
17
|
+
config.before(:all) do
|
18
|
+
# Redirect stderr and stdout
|
19
|
+
$stderr = File.open(File::NULL, 'w')
|
20
|
+
$stdout = File.open(File::NULL, 'w')
|
21
|
+
end
|
22
|
+
config.after(:all) do
|
23
|
+
$stderr = original_stderr
|
24
|
+
$stdout = original_stdout
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: domain_expiry
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tim Gurney aka Wolf
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: whois
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: whois-parser
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: whois
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '4.0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '4.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: whois-parser
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.1'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.1'
|
111
|
+
description: A simple gem checking for domain expiry.
|
112
|
+
email:
|
113
|
+
- wolf@tgwolf.com
|
114
|
+
executables:
|
115
|
+
- check-domain
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
122
|
+
- ".travis.yml"
|
123
|
+
- CHANGELOG.md
|
124
|
+
- CODEOWNERS
|
125
|
+
- CODE_OF_CONDUCT.md
|
126
|
+
- Gemfile
|
127
|
+
- LICENSE.txt
|
128
|
+
- README.md
|
129
|
+
- Rakefile
|
130
|
+
- bin/console
|
131
|
+
- bin/setup
|
132
|
+
- domain_expiry.gemspec
|
133
|
+
- exe/check-domain
|
134
|
+
- lib/domain_expiry.rb
|
135
|
+
- lib/domain_expiry/version.rb
|
136
|
+
- spec/domain_expiry_spec.rb
|
137
|
+
- spec/spec_helper.rb
|
138
|
+
homepage: https://github.com/AntiPhotonltd/domain_expiry
|
139
|
+
licenses:
|
140
|
+
- MIT
|
141
|
+
metadata: {}
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
requirements: []
|
157
|
+
rubyforge_project:
|
158
|
+
rubygems_version: 2.6.14
|
159
|
+
signing_key:
|
160
|
+
specification_version: 4
|
161
|
+
summary: A simple gem checking for domain expiry.
|
162
|
+
test_files: []
|