domainr-cli2 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5c9f44b02db0f51121cd2f0a6c3890284fb0a68d
4
+ data.tar.gz: 0504e6ba3a941ca704dc275e82abbd680c39723f
5
+ SHA512:
6
+ metadata.gz: de6c6d78ef07665c9baed2e4da9a8c9a6f98cd305b068321b25dfce140d8b1978dded7269e494f20693ffd38f89936d184672ed5f94187f2ca70aa68bab176a4
7
+ data.tar.gz: 717bcdaf6882ae69e6305d4df3122c2c53589f05171e72cf944e3d1806f93d9bc34260691a0b0879ae03be5acde94ced53704b2970562e537cca87ec9b97ae94
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at cbielinski@acorns.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in domainr-cli2.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Chris Bielinski
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,47 @@
1
+ # Domainr::CLI2
2
+
3
+ Search for domains using [Domainr](https://domainr.com/) from the command line. Built on top of [stve/domainr](https://github.com/stve/domainr).
4
+
5
+ ## Installation
6
+
7
+ Install with:
8
+
9
+ $ gem install domainr-cli2
10
+
11
+ ## Setup
12
+
13
+ **NOTE:** You'll need a [Mashape API key](https://github.com/domainr/api/wiki) before you start.
14
+
15
+ Once you have your key, set it once and forget it:
16
+
17
+ $ domainr api_key <your-api-key-here>
18
+
19
+ ## Usage
20
+
21
+ Use the `search` command to look for domains:
22
+
23
+ $ domainr search awesomeness
24
+ +-------------+-----------------+------------------------+
25
+ | Status | Domain | Path |
26
+ +-------------+-----------------+------------------------+
27
+ | UNAVAILABLE | awesomeness.com | http://awesomeness.com |
28
+ | UNAVAILABLE | awesomeness.net | http://awesomeness.net |
29
+ | DELETING | awesomeness.org | http://awesomeness.org |
30
+ | UNAVAILABLE | awesomeness.us | http://awesomeness.us |
31
+ | UNAVAILABLE | awesomen.es | http://awesomen.es/s |
32
+ | UNKNOWN | awesome.ne | http://awesome.ne/ss |
33
+ | PREMIUM | aweso.men | http://aweso.men/ess |
34
+ | UNAVAILABLE | aweso.me | http://aweso.me/ness |
35
+ | UNAVAILABLE | awes.om | http://awes.om/eness |
36
+ | UNAVAILABLE | awe.so | http://awe.so/meness |
37
+ | UNAVAILABLE | aw.es | http://aw.es/omeness |
38
+ | UNAVAILABLE | aw | http://aw/esomeness |
39
+ +-------------+-----------------+------------------------+
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/chrisb/domainr-cli2. 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.
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "domainr/cli2"
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
data/bin/setup ADDED
@@ -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,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'domainr/cli2/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "domainr-cli2"
8
+ spec.version = Domainr::CLI2::VERSION
9
+ spec.authors = ["Chris Bielinski"]
10
+ spec.email = ["chris@shadow.io"]
11
+ spec.summary = 'Search for domain names from the command line.'
12
+ spec.description = 'Provides a handy command line interface to the domainr gem.'
13
+ spec.homepage = 'https://github.com/chrisb/domainr-cli2'
14
+ spec.license = "MIT"
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+ spec.add_dependency 'thor', '~> 0.19'
20
+ spec.add_dependency 'colored', '~> 1'
21
+ spec.add_dependency 'domainr', '~> 1'
22
+ spec.add_dependency 'terminal-table', '~> 1'
23
+ spec.add_development_dependency "bundler", "~> 1.12"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ end
data/exe/domainr ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "domainr/cli2"
5
+
6
+ Domainr::CLI2::Base.start(ARGV)
@@ -0,0 +1,119 @@
1
+ module Domainr
2
+ module CLI2
3
+ class Base < Thor
4
+ API_KEY_STORAGE_LOCATION = '~/.domainr-cli2'.freeze
5
+
6
+ class_option :verbose, type: :boolean, default: false
7
+ class_option :status, type: :boolean, default: true
8
+
9
+ desc "search TERM", "Execute a fuzzy search for domains like TERM"
10
+ def search(name)
11
+ results = client.search(name)
12
+ if results.any?
13
+ puts results_table(results)
14
+ else
15
+ puts "Nothing available for that."
16
+ end
17
+ end
18
+
19
+ desc 'status DOMAIN', 'Check the status of a single domain'
20
+ def status(domain)
21
+ table = ::Terminal::Table.new headings: %w(Status Domain)
22
+ table << [colorize_status(get_status(domain)), domain]
23
+ puts table
24
+ end
25
+
26
+ desc "api_key API_KEY", "Set your Mashape API key"
27
+ def api_key(api_key)
28
+ File.open(path_to_api_key, 'w') { |f| f.write(api_key) }
29
+ end
30
+
31
+ private
32
+
33
+ def warn_api_key
34
+ STDERR.puts "\nUh oh! You need to set a Mashape API key before you can use this tool.\n".red
35
+ STDERR.puts "To obtain one, visit: https://github.com/domainr/api/wiki\nThen use #{'domainr api_key <your-api-key>'.yellow} to set your key.\n\n"
36
+ exit
37
+ end
38
+
39
+ def path_to_api_key
40
+ File.expand_path(API_KEY_STORAGE_LOCATION)
41
+ end
42
+
43
+ def read_api_key
44
+ return @api_key if @api_key
45
+ warn_api_key unless File.exist?(path_to_api_key)
46
+ @api_key = File.open(path_to_api_key).read.strip
47
+ warn_api_key unless @api_key
48
+ debug "Read API key: #{@api_key.inspect}"
49
+ @api_key
50
+ end
51
+
52
+ def results_table(results)
53
+ ::Terminal::Table.new headings: %w(Status Domain Path) do |table|
54
+ results.each do |result|
55
+ status = options[:status] ? get_status(result.domain) : nil
56
+ table.add_row [
57
+ colorize_status(status),
58
+ result.domain,
59
+ url_for_result(result)
60
+ ]
61
+ end
62
+ end
63
+ end
64
+
65
+ def debug(info)
66
+ return unless options[:verbose]
67
+ puts "[#{'DEBUG'.yellow}] #{info}"
68
+ end
69
+
70
+ def url_for_result(result)
71
+ "http://#{result.domain}#{result.path}"
72
+ end
73
+
74
+ def colorize_status(status)
75
+ return 'UKNOWN'.yellow if status.nil?
76
+ summary = status.summary
77
+ friendly_summary(summary)
78
+ .upcase
79
+ .send(color_for_summary(summary))
80
+ .bold
81
+ end
82
+
83
+ def friendly_summary(summary)
84
+ case summary.downcase.to_sym
85
+ when :active, :undelegated, :tld, :pending
86
+ 'unavailable'
87
+ when :inactive
88
+ 'available'
89
+ when :priced, :marketed
90
+ 'for sale'
91
+ else
92
+ summary
93
+ end
94
+ end
95
+
96
+ def color_for_summary(summary)
97
+ case summary.downcase.to_sym
98
+ when :active, :undelegated, :tld, :pending
99
+ :red
100
+ when :inactive
101
+ :green
102
+ when :priced
103
+ :yellow
104
+ else
105
+ :to_s
106
+ end
107
+ end
108
+
109
+ def get_status(domain)
110
+ debug "Fetching status for: #{domain.inspect}"
111
+ client.status(domain).first
112
+ end
113
+
114
+ def client
115
+ @client = Domainr::Client.new mashape_key: read_api_key
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,5 @@
1
+ module Domainr
2
+ module CLI2
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require 'domainr/cli2/version'
2
+
3
+ require 'thor'
4
+ require 'domainr'
5
+ require 'colored'
6
+ require 'terminal-table'
7
+
8
+ require 'domainr/cli2/base'
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: domainr-cli2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris Bielinski
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.19'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.19'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colored
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: domainr
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: terminal-table
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.12'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.12'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ description: Provides a handy command line interface to the domainr gem.
112
+ email:
113
+ - chris@shadow.io
114
+ executables:
115
+ - domainr
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".travis.yml"
122
+ - CODE_OF_CONDUCT.md
123
+ - Gemfile
124
+ - LICENSE.txt
125
+ - README.md
126
+ - Rakefile
127
+ - bin/console
128
+ - bin/setup
129
+ - domainr-cli2.gemspec
130
+ - exe/domainr
131
+ - lib/domainr/cli2.rb
132
+ - lib/domainr/cli2/base.rb
133
+ - lib/domainr/cli2/version.rb
134
+ homepage: https://github.com/chrisb/domainr-cli2
135
+ licenses:
136
+ - MIT
137
+ metadata: {}
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubyforge_project:
154
+ rubygems_version: 2.5.1
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: Search for domain names from the command line.
158
+ test_files: []