usernamecheck 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.
- data/CHANGELOG +8 -0
- data/LICENSE +20 -0
- data/Manifest +8 -0
- data/README.rdoc +14 -0
- data/Rakefile +21 -0
- data/bin/usernamecheck +22 -0
- data/lib/username_check.rb +93 -0
- data/usernamecheck.gemspec +32 -0
- metadata +71 -0
data/CHANGELOG
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
v0.1.0. Minor cleanups and release to gemcutter.
|
2
|
+
|
3
|
+
v0.0.3. Added support for stumbleupon, soundcloud, hulu, slashdot, plurk and myopenid.
|
4
|
+
|
5
|
+
v0.0.2. UsernameCheck.check_all accepts a block.
|
6
|
+
UsernameCheck.check_all is multi-threaded.
|
7
|
+
|
8
|
+
v0.0.1. Initial release.
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Elijah Miller
|
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/Manifest
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
= Usernamecheck
|
2
|
+
|
3
|
+
Checks username availability on many populer sites.
|
4
|
+
|
5
|
+
== Examples
|
6
|
+
|
7
|
+
usernamecheck jqr
|
8
|
+
|
9
|
+
== Install
|
10
|
+
|
11
|
+
gem install usernamecheck
|
12
|
+
|
13
|
+
Homepage:: http://github.com/jqr/usernamecheck
|
14
|
+
Copyright:: Copyright (c) 2008 Elijah Miller <mailto:elijah.miller@gmail.com>, released under the MIT license.
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec/rake/spectask'
|
2
|
+
|
3
|
+
require 'echoe'
|
4
|
+
Echoe.new 'usernamecheck' do |p|
|
5
|
+
p.description = "Checks username availability on many populer sites."
|
6
|
+
p.url = "http://usernamecheck.rubyforge.org"
|
7
|
+
p.author = "Elijah Miller"
|
8
|
+
p.email = "elijah.miller@gmail.com"
|
9
|
+
p.retain_gemspec = true
|
10
|
+
p.need_tar_gz = false
|
11
|
+
p.extra_deps = [
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Default: run specs'
|
16
|
+
task :default => :spec
|
17
|
+
Spec::Rake::SpecTask.new do |t|
|
18
|
+
t.spec_files = FileList["spec/**/*_spec.rb"]
|
19
|
+
end
|
20
|
+
|
21
|
+
task :test => :spec
|
data/bin/usernamecheck
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'username_check')
|
5
|
+
|
6
|
+
REDCODE = 31
|
7
|
+
GREENCODE = 32
|
8
|
+
|
9
|
+
if ARGV.size == 0
|
10
|
+
puts "Please supply all usernames you would like to check the availability for."
|
11
|
+
puts " #{$0} jerk eleventyseven"
|
12
|
+
else
|
13
|
+
ARGV.each do |name|
|
14
|
+
puts "Checking #{name}..."
|
15
|
+
UsernameCheck.check_all(name) do |service, used|
|
16
|
+
code = used ? REDCODE : GREENCODE
|
17
|
+
availability = used ? 'in use' : 'available'
|
18
|
+
puts " \e[#{ code }m#{service} #{availability}\e[0m"
|
19
|
+
end
|
20
|
+
puts
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module UsernameCheck
|
4
|
+
SITES = {
|
5
|
+
:twitter => 'twitter.com/',
|
6
|
+
:github => 'github.com/',
|
7
|
+
:flickr => 'flickr.com/photos/',
|
8
|
+
:lastfm => 'last.fm/user/',
|
9
|
+
:blogspot => '%s.blogspot.com',
|
10
|
+
'%s.com' => ['%s.com', :whois],
|
11
|
+
'%s.net' => ['%s.net', :whois],
|
12
|
+
'%s.org' => ['%s.org', :whois],
|
13
|
+
:delicious => 'delicious.com/',
|
14
|
+
:friendfeed => 'friendfeed.com/',
|
15
|
+
"friendfeed room" => 'friendfeed.com/rooms/',
|
16
|
+
:hulu => 'hulu.com/profiles/',
|
17
|
+
:disqus => 'disqus.com/people/',
|
18
|
+
:linkedin => ['www.linkedin.com/in/', :match, 'contact settings'],
|
19
|
+
:stumbleupon => ['stumbleupon.com/stumbler/', :not_match, 'no such username'],
|
20
|
+
:soundcloud => 'soundcloud.com/',
|
21
|
+
:hulu => 'hulu.com/profiles/',
|
22
|
+
:slashdot => ['slashdot.org/~', :not_match, 'does not exist'],
|
23
|
+
:plurk => ['plurk.com/', :not_match, 'register this nick name'],
|
24
|
+
:myopenid => '%s.myopenid.com',
|
25
|
+
:tumblr => ['%s.tumblr.com', :not_match, "We couldn't find the page you were looking for"],
|
26
|
+
:vimeo => 'vimeo.com/',
|
27
|
+
:youtube => 'youtube.com/',
|
28
|
+
:deviantart => '%s.deviantart.com',
|
29
|
+
:reddit => 'reddit.com/user/',
|
30
|
+
:livejournal => 'community.livejournal.com/',
|
31
|
+
:ustream => 'ustream.tv/',
|
32
|
+
}
|
33
|
+
|
34
|
+
def self.check_all(name)
|
35
|
+
memo_mutex = Mutex.new
|
36
|
+
memo = {}
|
37
|
+
threads = []
|
38
|
+
SITES.each do |site_and_options|
|
39
|
+
threads << Thread.new do
|
40
|
+
site, address, condition, *args = site_and_options.flatten
|
41
|
+
condition ||= :is_200
|
42
|
+
rendered_address =
|
43
|
+
if address.include?('%s')
|
44
|
+
address % name
|
45
|
+
else
|
46
|
+
address + name
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
service = site.to_s % name
|
51
|
+
in_use = send(condition, rendered_address, *args)
|
52
|
+
memo_mutex.synchronize do
|
53
|
+
yield(service, in_use) if block_given?
|
54
|
+
memo[service] = in_use
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
threads.each { |t| t.join }
|
59
|
+
memo
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.get(address)
|
63
|
+
HTTParty.get("http://#{address}")
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.is_200(address)
|
67
|
+
begin
|
68
|
+
get(address).code.to_i == 200
|
69
|
+
rescue
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.match(address, regexp)
|
74
|
+
!!(get(address).body =~ regexify(regexp))
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.not_match(address, regexp)
|
78
|
+
!(get(address).body =~ regexify(regexp))
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.regexify(regexp)
|
82
|
+
if regexp.is_a?(Regexp)
|
83
|
+
regexp
|
84
|
+
else
|
85
|
+
Regexp.new(regexp, true)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.whois(domain)
|
90
|
+
# FIXME: seems to be broken on .org
|
91
|
+
`whois #{domain.inspect} | head -n 10 | grep "No match for" || echo 1`.chomp == '1'
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{usernamecheck}
|
5
|
+
s.version = "0.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Elijah Miller"]
|
9
|
+
s.date = %q{2009-12-03}
|
10
|
+
s.default_executable = %q{usernamecheck}
|
11
|
+
s.description = %q{Checks username availability on many populer sites.}
|
12
|
+
s.email = %q{elijah.miller@gmail.com}
|
13
|
+
s.executables = ["usernamecheck"]
|
14
|
+
s.extra_rdoc_files = ["bin/usernamecheck", "CHANGELOG", "lib/username_check.rb", "LICENSE", "README.rdoc"]
|
15
|
+
s.files = ["bin/usernamecheck", "CHANGELOG", "lib/username_check.rb", "LICENSE", "Manifest", "Rakefile", "README.rdoc", "usernamecheck.gemspec"]
|
16
|
+
s.homepage = %q{http://usernamecheck.rubyforge.org}
|
17
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Usernamecheck", "--main", "README.rdoc"]
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
s.rubyforge_project = %q{usernamecheck}
|
20
|
+
s.rubygems_version = %q{1.3.5}
|
21
|
+
s.summary = %q{Checks username availability on many populer sites.}
|
22
|
+
|
23
|
+
if s.respond_to? :specification_version then
|
24
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
|
+
s.specification_version = 3
|
26
|
+
|
27
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
|
+
else
|
29
|
+
end
|
30
|
+
else
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: usernamecheck
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Elijah Miller
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-03 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Checks username availability on many populer sites.
|
17
|
+
email: elijah.miller@gmail.com
|
18
|
+
executables:
|
19
|
+
- usernamecheck
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- bin/usernamecheck
|
24
|
+
- CHANGELOG
|
25
|
+
- lib/username_check.rb
|
26
|
+
- LICENSE
|
27
|
+
- README.rdoc
|
28
|
+
files:
|
29
|
+
- bin/usernamecheck
|
30
|
+
- CHANGELOG
|
31
|
+
- lib/username_check.rb
|
32
|
+
- LICENSE
|
33
|
+
- Manifest
|
34
|
+
- Rakefile
|
35
|
+
- README.rdoc
|
36
|
+
- usernamecheck.gemspec
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: http://usernamecheck.rubyforge.org
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options:
|
43
|
+
- --line-numbers
|
44
|
+
- --inline-source
|
45
|
+
- --title
|
46
|
+
- Usernamecheck
|
47
|
+
- --main
|
48
|
+
- README.rdoc
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "1.2"
|
62
|
+
version:
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project: usernamecheck
|
66
|
+
rubygems_version: 1.3.5
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: Checks username availability on many populer sites.
|
70
|
+
test_files: []
|
71
|
+
|