domainsbot 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0a4c0a83635d284bd3c2b14efb3288780435e177
4
+ data.tar.gz: 55954ad44c064d389d254ec3d757f440e897e94f
5
+ SHA512:
6
+ metadata.gz: a428c6aceaddeb58eaea64c8e90a4b7d65390766f0fe25ab409849bda6be2831cf34a5f4bdbdddfe083601814b325edf00310985ccb80ebb23efe6da67eea409
7
+ data.tar.gz: de51ddbe7057fa78677817d7081cb089e2697f21fc114cf87571753e8b4270ed0d51db2da46e3c30f4c23cc4ca1635c39d7bb814f58bebdc46dade04ee4570cb
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in domainsbot.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'webmock'
8
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Daniel Westendorf
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,34 @@
1
+ # Domainsbot
2
+
3
+ Simple Ruby API for http://domainsbot.com
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'domainsbot'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install domainsbot
18
+
19
+ ## Usage
20
+
21
+ require 'domainsbot'
22
+
23
+ Domainsbot.api_key = 'MY_API_KEY'
24
+ Domainsbot.suggest(q: 'my-fancy-domain-name.com')
25
+
26
+ Suggest will add all the options passed to it as query params in the request
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it ( http://github.com/<my-github-username>/domainsbot/fork )
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << 'lib/domainsbot'
8
+ t.test_files = FileList['test/lib/domainsbot_test.rb']
9
+ t.verbose = true
10
+ end
11
+
12
+ task :default => :test
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "domainsbot"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Daniel Westendorf"]
9
+ spec.email = ["daniel@prowestech.com"]
10
+ spec.summary = %q{Simple ruby client for domainsbot.com's api}
11
+ spec.description = %q{Simple ruby client for domainsbot.com's api}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.5"
21
+ spec.add_development_dependency "rake"
22
+ end
@@ -0,0 +1,57 @@
1
+ # Simple API wrapper for the Domainsbot API
2
+ # Visit https://developers.domainsbot.com/docs for more information about the API
3
+ # Built for API v4
4
+ #
5
+ # Author:: Daniel Westendorf (daniel@prowestech.com)
6
+ # License:: MIT
7
+
8
+ require 'net/http'
9
+ require 'json'
10
+
11
+ class Domainsbot
12
+ @@api_key = nil
13
+
14
+ BASE_URI = 'https://api.domainsbot.com/v4'
15
+
16
+ # Set the API key to be used for all requests
17
+ #
18
+ # ==== Attributes
19
+ #
20
+ # * +key+ - String Domainsbot API Key
21
+ #
22
+ # ==== Examples
23
+ #
24
+ # Domainsbot.api_key = "MYAPIKEY"
25
+ def self.api_key=(key)
26
+ @@api_key = key
27
+ end
28
+
29
+ def self.api_key; @@api_key; end
30
+
31
+ # Accepts a hash of options
32
+ # All options will be added as a query paramerter
33
+
34
+ # ==== Attributes
35
+ #
36
+ # * +options+ - Hash query parameters
37
+ #
38
+ # ==== Examples
39
+ #
40
+ # Domainsbot.suggest({q: 'example.com', pageSize: 2, tlds: 'com,org,net'})
41
+ def self.suggest(options={q: '', pageSize: 25, tlds: 'com,org,net', format: 'json'})
42
+ options['auth-token'] = @@api_key
43
+ options[:json] = 'json'
44
+ uri = build_uri('/spinner', options)
45
+
46
+ response = Net::HTTP.get_response(uri)
47
+ return JSON.parse(response.body)
48
+ end
49
+
50
+ # Helper method for building the URI
51
+ # Shouldn't ever be called directly
52
+ def self.build_uri(path, options) #:nodoc: all
53
+ uri = URI("#{BASE_URI}#{path}")
54
+ uri.query = URI.encode_www_form(options)
55
+ return uri
56
+ end
57
+ end
@@ -0,0 +1,34 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe Domainsbot do
4
+ API_KEY = '123456'
5
+ before do
6
+ Domainsbot.api_key = API_KEY
7
+ end
8
+
9
+ it "must have an api_key defined" do
10
+ Domainsbot.api_key.wont_be_nil
11
+ end
12
+
13
+
14
+ it '#build_uri' do
15
+ uri = Domainsbot.build_uri('/spinner', {pageSize: 40, q: 'flubber'})
16
+ assert_equal("https://api.domainsbot.com/v4/spinner?pageSize=40&q=flubber", uri.to_s)
17
+ end
18
+
19
+ describe '#suggest' do
20
+
21
+ before do
22
+ stub_request(:get, "https://api.domainsbot.com/v4/spinner").
23
+ with(query: hash_including({}),:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host'=>'api.domainsbot.com', 'User-Agent'=>'Ruby'}).
24
+ to_return(status: 200, headers: {'Content-Type' => 'application/json'}, body: RESPONSE_DATA)
25
+ end
26
+
27
+ it "always gets a JSON Hash response" do
28
+ response = Domainsbot.suggest(q: 'hotpeppers.com', format: 'xml')
29
+ assert_kind_of(Hash, response)
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ Bundler.require(:default, :test)
3
+ require 'minitest/autorun'
4
+ require 'minitest/pride'
5
+ require 'webmock/minitest'
6
+ require File.expand_path('../../lib/domainsbot.rb', __FILE__)
7
+
8
+ RESPONSE_DATA = '{"Domains":[{"Extension":"com","DomainName":"DirectlyBuilt.com","NameWithoutExtension":"DirectlyBuilt","Keys":["directly","built"],"Data":[[{"Name":"database","Data":"available"},{"Name":"language","Data":"en"},{"Name":"PercentileRank","Data":99},{"Name":"length","Data":13},{"Name":"keyscount","Data":2},{"Name":"bad","Data":false},{"Name":"dash","Data":false},{"Name":"numbers","Data":false},{"Name":"idn","Data":false},{"Name":"#synonyms","Data":true}]]},{"Extension":"com","DomainName":"StraightforwardBuilt.com","NameWithoutExtension":"StraightforwardBuilt","Keys":["straightforward","built"],"Data":[[{"Name":"database","Data":"available"},{"Name":"language","Data":"en"},{"Name":"PercentileRank","Data":99},{"Name":"length","Data":20},{"Name":"keyscount","Data":2},{"Name":"bad","Data":false},{"Name":"dash","Data":false},{"Name":"numbers","Data":false},{"Name":"idn","Data":false},{"Name":"#synonyms","Data":true}]]}],"Keys":[["simply","directly","straightforward","plainly","modestly"],["built"]],"PageIndex":0,"PageSize":2,"TotalResults":347}'
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: domainsbot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Westendorf
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-27 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Simple ruby client for domainsbot.com's api
42
+ email:
43
+ - daniel@prowestech.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - domainsbot.gemspec
54
+ - lib/domainsbot.rb
55
+ - test/lib/domainsbot_test.rb
56
+ - test/test_helper.rb
57
+ homepage: ''
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
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: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.0.14
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Simple ruby client for domainsbot.com's api
81
+ test_files:
82
+ - test/lib/domainsbot_test.rb
83
+ - test/test_helper.rb