whois_rb 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c20fd2512ad19fa719a87c44dc6244cc24b2e0258fb1367ec02dfdcc78e181a6
4
+ data.tar.gz: 74748b0956817b926652646293e4858d9c3a9d44cb646f11faa726c968ad4273
5
+ SHA512:
6
+ metadata.gz: '079fa6173a6bcd3d58014290b59dd2571959dc27dd818131acf2b1a45acd182cd5d261a73e958cf1d5b1a886ce3a39d78b6bbc0d1af298944d7336ed6ebf8798'
7
+ data.tar.gz: cf28e642b45055c555cfcd1bb808be0c0ffb8f5e38d74a37b9bfd8b51dcca4854091a0649f4277a4ecbc7f7c754524355b65861c3ab2d122226cbfa8e1b11995
@@ -0,0 +1,15 @@
1
+ [bumpversion]
2
+ current_version = 0.1.0
3
+ commit = True
4
+
5
+ [bumpversion:file:README.md]
6
+ search = whois_rb --version "{current_version}"
7
+ replace = whois_rb --version "{new_version}"
8
+
9
+ [bumpversion:file:lib/whois_rb/version.rb]
10
+ search = VERSION = "{current_version}"
11
+ replace = VERSION = "{new_version}"
12
+
13
+ [bumpversion:file:Gemfile.lock]
14
+ search = whois_rb ({current_version})
15
+ replace = whois_rb ({new_version})
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.5
6
+ before_install: gem install bundler -v 2.1.4
@@ -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 hello@promptapi.com. 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 [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in whois_rb.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "minitest", "~> 5.0"
@@ -0,0 +1,25 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ whois_rb (0.1.0)
5
+ faraday (~> 1.0, >= 1.0.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ faraday (1.0.1)
11
+ multipart-post (>= 1.2, < 3)
12
+ minitest (5.14.2)
13
+ multipart-post (2.1.1)
14
+ rake (12.3.3)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ minitest (~> 5.0)
21
+ rake (~> 12.0)
22
+ whois_rb!
23
+
24
+ BUNDLED WITH
25
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Prompt API
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,146 @@
1
+ ![Ruby](https://img.shields.io/badge/ruby-2.7.0-green.svg)
2
+ [![Gem Version](https://badge.fury.io/rb/whois_rb.svg)](https://badge.fury.io/rb/whois_rb)
3
+ [![Build Status](https://travis-ci.org/promptapi/whois_rb.svg?branch=main)](https://travis-ci.org/promptapi/whois_rb)
4
+
5
+ # Prompt API - Whois API - Ruby Package
6
+
7
+ `whois_rb` is a simple ruby wrapper for [whois-api][whois-api].
8
+
9
+ ## Requirements
10
+
11
+ 1. You need to signup for [Prompt API][promptapi-signup]
12
+ 1. You need to subscribe [whois-api][whois-api], test drive is **free!!!**
13
+ 1. You need to set `PROMPTAPI_TOKEN` environment variable after subscription.
14
+
15
+ then;
16
+
17
+ ```bash
18
+ $ gem install whois_rb
19
+ ```
20
+
21
+ or; install from GitHub:
22
+
23
+ ```bash
24
+ $ gem install whois_rb --version "0.1.0" --source "https://rubygems.pkg.github.com/promptapi"
25
+ ```
26
+
27
+ ---
28
+
29
+ ## Example Usage
30
+
31
+ Check domain examples:
32
+
33
+ ```ruby
34
+ require 'whois_rb'
35
+
36
+ result = WhoisRb::check('promptapi.com')
37
+ # => {:result=>"registered"}
38
+
39
+ result = WhoisRb::check('promptapi.com', timeout=20)
40
+ # => {:result=>"registered"}
41
+
42
+ result = WhoisRb::check('foo')
43
+ # => {:error=>"Not a valid domain name"}
44
+
45
+ result = WhoisRb::check('promptapi123456.com')
46
+ # => {:result=>"available"}
47
+ ```
48
+
49
+ Query domain examples:
50
+
51
+ ```ruby
52
+ require 'whois_rb'
53
+
54
+ result = WhoisRb::query('foo')
55
+ # => {:error=>"Not a valid domain name"}
56
+
57
+ result = WhoisRb::query('promptapi.com')
58
+ # => {
59
+ :result=>{
60
+ :domain_name=>"PROMPTAPI.COM",
61
+ :registrar=>"NameCheap, Inc.",
62
+ :whois_server=>"whois.namecheap.com",
63
+ :referral_url=>nil,
64
+ :updated_date=>"2020-05-27 22:19:36",
65
+ :creation_date=>"2020-04-19 15:11:52",
66
+ :expiration_date=>"2021-04-19 15:11:52",
67
+ :name_servers=>["APOLLO.NS.CLOUDFLARE.COM", "MARJORY.NS.CLOUDFLARE.COM"],
68
+ :status=>"clientTransferProhibited https://icann.org/epp#clientTransferProhibited",
69
+ :emails=>"abuse@namecheap.com",
70
+ :dnssec=>"unsigned",
71
+ :name=>nil,
72
+ :org=>nil,
73
+ :address=>nil,
74
+ :city=>nil,
75
+ :state=>nil,
76
+ :zipcode=>nil,
77
+ :country=>nil
78
+ }
79
+ }
80
+
81
+ result = WhoisRb::query('promptapi1234.com')
82
+ # => {:error=>"No match for promptapi1234.com"}
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Development
88
+
89
+ After checking out the repo, run `bin/setup` to install dependencies. Then,
90
+ run `rake test` to run the tests. You can also run `bin/console` for an
91
+ interactive prompt that will allow you to experiment.
92
+
93
+ To install this gem onto your local machine, run `bundle exec rake install`.
94
+ To release a new version, update the version number in `version.rb`, and then
95
+ run `bundle exec rake release`, which will create a git tag for the version,
96
+ push git commits and tags, and push the `.gem` file to
97
+ [rubygems.org][rubygems]
98
+
99
+ ```bash
100
+ $ rake -T
101
+
102
+ rake build # Build whois_rb-0.0.0.gem into the pkg directory
103
+ rake bump[revision] # Bump version
104
+ rake clean # Remove any temporary products
105
+ rake clobber # Remove any generated files
106
+ rake install # Build and install whois_rb-0.0.0.gem into system gems
107
+ rake install:local # Build and install whois_rb-0.0.0.gem into system gems without network access
108
+ rake push_to_github # Push whois_rb-0.0.0.gem to GitHub registry
109
+ rake release[remote] # Create tag v0.0.0 and build and push whois_rb-0.0.0.gem to rubygems.org
110
+ rake test # Run tests
111
+ ```
112
+
113
+ ---
114
+
115
+ ## License
116
+
117
+ This project is licensed under MIT
118
+
119
+ ---
120
+
121
+ ## Contributer(s)
122
+
123
+ * [Prompt API](https://github.com/promptapi) - Creator, maintainer
124
+
125
+ ---
126
+
127
+ ## Contribute
128
+
129
+ Bug reports and pull requests are welcome on GitHub:
130
+
131
+ 1. `fork` (https://github.com/promptapi/whois_rb/fork)
132
+ 1. Create your `branch` (`git checkout -b my-feature`)
133
+ 1. `commit` yours (`git commit -am 'Add awesome features...'`)
134
+ 1. `push` your `branch` (`git push origin my-feature`)
135
+ 1. Than create a new **Pull Request**!
136
+
137
+ This project is intended to be a safe,
138
+ welcoming space for collaboration, and contributors are expected to adhere to
139
+ the [code of conduct][coc].
140
+
141
+ ---
142
+
143
+ [whois-api]: https://promptapi.com/marketplace/description/whois-api
144
+ [promptapi-signup]: https://promptapi.com/#signup-form
145
+ [coc]: https://github.com/promptapi/whois_rb/blob/main/CODE_OF_CONDUCT.md
146
+ [rubygems]: https://rubygems.org
@@ -0,0 +1,31 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
11
+
12
+ AVAILABLE_REVISIONS = ["major", "minor", "patch"]
13
+ desc "Bump version"
14
+ task :bump, [:revision] do |t, args|
15
+ args.with_defaults(revision: "patch")
16
+ abort "Please provide valid revision: #{AVAILABLE_REVISIONS.join(',')}" unless AVAILABLE_REVISIONS.include?(args.revision)
17
+ system "bumpversion #{args.revision}"
18
+ end
19
+
20
+ def get_package_name
21
+ name = Dir['*.gemspec'].first.split('.').first
22
+ line = File.read("lib/#{name}/version.rb")[/^\s*VERSION\s*=\s*.*/]
23
+ version = line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
24
+ "#{name}-#{version}.gem"
25
+ end
26
+
27
+ desc "Push #{get_package_name} to GitHub registry"
28
+ task :push_to_github do
29
+ package_path = "pkg/#{get_package_name}"
30
+ system "gem push --key github --host https://rubygems.pkg.github.com/promptapi #{package_path}"
31
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "whois_rb"
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__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,16 @@
1
+ require "whois_rb/version"
2
+ require "whois_rb/http"
3
+
4
+ module WhoisRb
5
+ class Error < StandardError; end
6
+
7
+ class << self
8
+ def check(domain, timeout=10)
9
+ WhoisRb::Http.get(domain, timeout)
10
+ end
11
+
12
+ def query(domain, timeout=10)
13
+ WhoisRb::Http.get(domain, timeout, 'query')
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,50 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ module WhoisRb
5
+ module Http
6
+ PROMPTAPI_ENDPOINT = 'https://api.promptapi.com/whois'
7
+
8
+ class << self
9
+ def parse(body)
10
+ begin
11
+ JSON.parse(body, symbolize_names: true)
12
+ rescue JSON::ParserError
13
+ {error: "JSON decoding error"}
14
+ end
15
+ end
16
+
17
+ def get(domain, timeout, url_suffix='check')
18
+ options = {
19
+ url: "#{PROMPTAPI_ENDPOINT}/#{url_suffix}",
20
+ params: {domain: domain},
21
+ request: {timeout: timeout},
22
+ headers: {
23
+ 'Accept' => 'application/json',
24
+ 'apikey' => ENV['PROMPTAPI_TOKEN'] || nil,
25
+ },
26
+ }
27
+ unless options[:headers]['apikey']
28
+ return {error: "You need to set PROMPTAPI_TOKEN environment variable"}
29
+ end
30
+
31
+ conn = Faraday.new(options) do |c|
32
+ c.use Faraday::Response::RaiseError
33
+ end
34
+
35
+ begin
36
+ response = conn.get
37
+ return self.parse(response.body)
38
+ rescue Faraday::ConnectionFailed
39
+ return {error: "Connection error"}
40
+ rescue Faraday::TimeoutError => e
41
+ return {error: e.message.capitalize}
42
+ rescue Faraday::ClientError => e
43
+ return {error: parse(e.response[:body])[:message].capitalize}
44
+ rescue Faraday::ServerError => e
45
+ return {error: e.message.capitalize}
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,3 @@
1
+ module WhoisRb
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,23 @@
1
+ require_relative 'lib/whois_rb/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "whois_rb"
5
+ spec.version = WhoisRb::VERSION
6
+ spec.authors = ["Prompt API"]
7
+ spec.email = ["hello@promptapi.com"]
8
+
9
+ spec.summary = %q{Ruby wrapper for Prompt API's Whois API}
10
+ spec.homepage = "https://github.com/promptapi/whois_rb"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = "https://github.com/promptapi/whois_rb"
16
+
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+
21
+ spec.require_paths = ["lib"]
22
+ spec.add_runtime_dependency 'faraday', '~> 1.0', '>= 1.0.1'
23
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: whois_rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Prompt API
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-09-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.1
33
+ description:
34
+ email:
35
+ - hello@promptapi.com
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - ".bumpversion.cfg"
41
+ - ".gitignore"
42
+ - ".travis.yml"
43
+ - CODE_OF_CONDUCT.md
44
+ - Gemfile
45
+ - Gemfile.lock
46
+ - LICENSE.txt
47
+ - README.md
48
+ - Rakefile
49
+ - bin/console
50
+ - bin/setup
51
+ - lib/whois_rb.rb
52
+ - lib/whois_rb/http.rb
53
+ - lib/whois_rb/version.rb
54
+ - whois_rb.gemspec
55
+ homepage: https://github.com/promptapi/whois_rb
56
+ licenses:
57
+ - MIT
58
+ metadata:
59
+ homepage_uri: https://github.com/promptapi/whois_rb
60
+ source_code_uri: https://github.com/promptapi/whois_rb
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 2.3.0
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubygems_version: 3.1.2
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Ruby wrapper for Prompt API's Whois API
80
+ test_files: []