b_named 0.0.1
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.
- data/LICENSE +20 -0
- data/README.rdoc +62 -0
- data/Rakefile +69 -0
- data/VERSION +1 -0
- data/lib/b_named.rb +13 -0
- data/lib/b_named/availability.rb +46 -0
- data/lib/b_named/version.rb +3 -0
- data/spec/b_named_spec.rb +7 -0
- data/spec/spec_helper.rb +9 -0
- metadata +94 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 wout fierens
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
= b_named
|
2
|
+
|
3
|
+
* http://github.com/wout/b_named
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
A Ruby wrapper for the bNamed.net API.
|
8
|
+
Currently it enables you to retrieve a list of domains and their status.
|
9
|
+
|
10
|
+
== FEATURES/PROBLEMS:
|
11
|
+
|
12
|
+
* Checking availability of domain names
|
13
|
+
|
14
|
+
== SYNOPSIS:
|
15
|
+
|
16
|
+
# controller example
|
17
|
+
|
18
|
+
bnamed = BNamed::Availability.new('012345', 'your_pass_key')
|
19
|
+
@result = bnamed.check('rubyonrails', %w(com net org info name biz))
|
20
|
+
|
21
|
+
# view example (haml)
|
22
|
+
|
23
|
+
.domains
|
24
|
+
- @result.domains.each do |domain|
|
25
|
+
.domain
|
26
|
+
.name= domain.sld + '.' + domain.tld
|
27
|
+
.text= domain.availability_text
|
28
|
+
|
29
|
+
== REQUIREMENTS:
|
30
|
+
|
31
|
+
* httparty gem (>= 0.4.0)
|
32
|
+
* mash gem (>= 0.0.3)
|
33
|
+
|
34
|
+
== INSTALL:
|
35
|
+
|
36
|
+
* sudo gem install b_named --source http://gemcutter.org
|
37
|
+
(currently the gem itself is hosted at gemcutter because github gem building is down)
|
38
|
+
|
39
|
+
== LICENSE:
|
40
|
+
|
41
|
+
(The MIT License)
|
42
|
+
|
43
|
+
Copyright (c) 2009 wout fierens
|
44
|
+
|
45
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
46
|
+
a copy of this software and associated documentation files (the
|
47
|
+
'Software'), to deal in the Software without restriction, including
|
48
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
49
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
50
|
+
permit persons to whom the Software is furnished to do so, subject to
|
51
|
+
the following conditions:
|
52
|
+
|
53
|
+
The above copyright notice and this permission notice shall be
|
54
|
+
included in all copies or substantial portions of the Software.
|
55
|
+
|
56
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
57
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
58
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
59
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
60
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
61
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
62
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
#-Github begin
|
5
|
+
#-Github require 'jeweler'
|
6
|
+
#-Github Jeweler::Tasks.new do |gem|
|
7
|
+
#-Github gem.name = "b_named"
|
8
|
+
#-Github gem.summary = %Q{A Ruby wrapper for the bNamed.net API.}
|
9
|
+
#-Github gem.description = %Q{Currently it enables you to retrieve a list of domains and their status.}
|
10
|
+
#-Github gem.email = "wout@qimmiq.net"
|
11
|
+
#-Github gem.homepage = "http://github.com/wout/b_named"
|
12
|
+
#-Github gem.authors = ["wout"]
|
13
|
+
#-Github gem.add_development_dependency "rspec"
|
14
|
+
#-Github # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
#-Github end
|
16
|
+
#-Github rescue LoadError
|
17
|
+
#-Github puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
18
|
+
#-Github end
|
19
|
+
|
20
|
+
begin
|
21
|
+
require 'jeweler'
|
22
|
+
Jeweler::Tasks.new do |gem|
|
23
|
+
gem.name = "b_named"
|
24
|
+
gem.summary = %Q{A Ruby wrapper for the bNamed.net API.}
|
25
|
+
gem.description = %Q{Currently it enables you to retrieve a list of domains and their status.}
|
26
|
+
gem.email = "wout@qimmiq.net"
|
27
|
+
gem.homepage = "http://github.com/wout/b_named"
|
28
|
+
gem.authors = ["wout"]
|
29
|
+
gem.files = FileList["[A-Z]*", "{lib,spec}/**/*"]
|
30
|
+
|
31
|
+
gem.add_dependency('mash', '0.0.3')
|
32
|
+
gem.add_dependency('httparty', '>= 0.4.3')
|
33
|
+
|
34
|
+
gem.add_development_dependency "rspec"
|
35
|
+
end
|
36
|
+
Jeweler::GemcutterTasks.new
|
37
|
+
rescue LoadError
|
38
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
39
|
+
end
|
40
|
+
|
41
|
+
require 'spec/rake/spectask'
|
42
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
43
|
+
spec.libs << 'lib' << 'spec'
|
44
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
45
|
+
end
|
46
|
+
|
47
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
48
|
+
spec.libs << 'lib' << 'spec'
|
49
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
50
|
+
spec.rcov = true
|
51
|
+
end
|
52
|
+
|
53
|
+
task :spec => :check_dependencies
|
54
|
+
|
55
|
+
task :default => :spec
|
56
|
+
|
57
|
+
require 'rake/rdoctask'
|
58
|
+
Rake::RDocTask.new do |rdoc|
|
59
|
+
if File.exist?('VERSION')
|
60
|
+
version = File.read('VERSION')
|
61
|
+
else
|
62
|
+
version = ""
|
63
|
+
end
|
64
|
+
|
65
|
+
rdoc.rdoc_dir = 'rdoc'
|
66
|
+
rdoc.title = "b_named #{version}"
|
67
|
+
rdoc.rdoc_files.include('README*')
|
68
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
69
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/lib/b_named.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
gem 'httparty', '>=0.4.3'
|
7
|
+
require 'httparty'
|
8
|
+
|
9
|
+
gem 'mash', '>=0.0.3'
|
10
|
+
require 'mash'
|
11
|
+
|
12
|
+
require 'b_named/availability'
|
13
|
+
require 'b_named/version'
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module BNamed
|
2
|
+
class Availability
|
3
|
+
API_URL = 'https://www2.bNamed.net/en/api.asp'
|
4
|
+
|
5
|
+
def initialize(uid, pass_key)
|
6
|
+
@uid = uid
|
7
|
+
@pass_key = pass_key
|
8
|
+
raise ArgumentError.new("Please provide a uid and pass_key") if @uid.nil? || @pass_key.nil?
|
9
|
+
end
|
10
|
+
|
11
|
+
def check(sld, tlds=nil)
|
12
|
+
@tlds = tlds || %w(com net org info name biz)
|
13
|
+
@slds = Array.new(@tlds.length).fill(sld)
|
14
|
+
|
15
|
+
response = HTTParty.get("#{API_URL}?UID=#{@uid}&Key=#{@pass_key}&command=check&TLDList=#{@tlds.join(',')}&SLDList=#{@slds.join(',')}")
|
16
|
+
|
17
|
+
mashup(response['API'])
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def mashup(response)
|
23
|
+
raw_result = response['Result'].
|
24
|
+
to_a.
|
25
|
+
sort{ |a,b| a[0] <=> b[0] }.
|
26
|
+
collect{ |r| r[1] }
|
27
|
+
|
28
|
+
result_hash = Hash.new
|
29
|
+
result_hash[:domains] = raw_result.each{ |h| Mash.new(h.each_pair{ |k,v| h[underscore(k)] = h.delete(k) }) }
|
30
|
+
result_hash[:time] = response['Time'].tr(',','.').to_f
|
31
|
+
result_hash[:done] = response['Done'] == 'True'
|
32
|
+
result_hash[:error_code] = response['ErrorCode']
|
33
|
+
result_hash[:error_text] = response['ErrorText']
|
34
|
+
|
35
|
+
Mash.new(result_hash)
|
36
|
+
end
|
37
|
+
|
38
|
+
def underscore(camel_cased_word)
|
39
|
+
camel_cased_word.to_s.gsub(/::/, '/').
|
40
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
41
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
42
|
+
tr("-", "_").
|
43
|
+
downcase
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: b_named
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- wout
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-09-30 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mash
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - "="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.3
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: httparty
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.4.3
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
description: Currently it enables you to retrieve a list of domains and their status.
|
46
|
+
email: wout@qimmiq.net
|
47
|
+
executables: []
|
48
|
+
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files:
|
52
|
+
- LICENSE
|
53
|
+
- README.rdoc
|
54
|
+
files:
|
55
|
+
- LICENSE
|
56
|
+
- README.rdoc
|
57
|
+
- Rakefile
|
58
|
+
- VERSION
|
59
|
+
- lib/b_named.rb
|
60
|
+
- lib/b_named/availability.rb
|
61
|
+
- lib/b_named/version.rb
|
62
|
+
- spec/b_named_spec.rb
|
63
|
+
- spec/spec_helper.rb
|
64
|
+
has_rdoc: true
|
65
|
+
homepage: http://github.com/wout/b_named
|
66
|
+
licenses: []
|
67
|
+
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options:
|
70
|
+
- --charset=UTF-8
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "0"
|
78
|
+
version:
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: "0"
|
84
|
+
version:
|
85
|
+
requirements: []
|
86
|
+
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 1.3.5
|
89
|
+
signing_key:
|
90
|
+
specification_version: 3
|
91
|
+
summary: A Ruby wrapper for the bNamed.net API.
|
92
|
+
test_files:
|
93
|
+
- spec/b_named_spec.rb
|
94
|
+
- spec/spec_helper.rb
|