turboname 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/turboname.rb ADDED
@@ -0,0 +1,71 @@
1
+ require "turboname/version"
2
+ require "whois"
3
+
4
+ module Turboname
5
+
6
+ def self.path
7
+ File.dirname(__FILE__)
8
+ end
9
+
10
+ class Domain
11
+ CountryTLDs = %w{ac ad ae af ag ai al am an ao aq ar as at au aw ax az ba bb bd be bf bg bh bi bj bm bn bo br bs bt bu bv bw by bz ca cc cd cf cg ch ci ck cl cm cn co cr cs cu cv cx cy cz de dj dk dm do dz ec ee eg eh er es et eu fi fj fk fm fo fr ga gb gd ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il im in io iq ir is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc li lk lr ls lt lu lv ly ma mc md me mg mh mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz na nc ne nf ng ni nl no np nr nu nz om pa pe pf pg ph pk pl pm pn pr ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sj sk sl sm sn so sr st su sv sy sz tc td tf tg tj tk tl tm tn to tp tr tt tv tw tz ua ug uk us uy uz va vc ve vg vi vn vu wf ws ye yt yu za zm zw}
12
+
13
+ attr_accessor :name
14
+
15
+ def initialize opts = {}
16
+ self.name = opts[:from].is_a?(Dictionary) ? opts[:from].get : opts[:from] if opts[:from]
17
+ end
18
+
19
+ # let's remove the tld at the end of the domain. eljojo -> eljo.jo | asdfk -> asdfk.jo
20
+ def with_tld tld
21
+ @name[-tld.length..-1] == tld ? @name[0..-tld.length-1] + ".#{tld}" : "#{@name}.#{tld}"
22
+ end
23
+
24
+ def save tld = 'com'
25
+ `echo "#{with_tld(tld)}" >> names.txt`
26
+ end
27
+
28
+ def available? tld = nil
29
+ tld = 'com' if tld.nil?
30
+ name_with_tld = with_tld(tld)
31
+ print name_with_tld
32
+ begin
33
+ domain = Whois.whois(name_with_tld)
34
+ available = domain.available?
35
+ rescue
36
+ available = false
37
+ end
38
+ puts "#{' '*(25 - name_with_tld.length)}#{available ? 'IS' : 'is not'} available"
39
+ available
40
+ end
41
+
42
+ def tldize
43
+ last_letters = self.name[-2..-1]
44
+ last_letters if CountryTLDs.include?(last_letters)
45
+ end
46
+
47
+ # this will not include the tld
48
+ def to_s
49
+ @name
50
+ end
51
+
52
+ def length
53
+ @name.length
54
+ end
55
+ end
56
+
57
+ class Dictionary # maybe dictionary is not a good word
58
+ def get; ''; end
59
+ end
60
+
61
+ class Random < Dictionary
62
+ def get
63
+ vowels=["a","e","i","o","u"]
64
+ line = File.readlines(File.join(Turboname::path, 'dictionary.txt'))[rand(435000)-1].gsub("\n","")
65
+ rand(20).times do
66
+ line=line.gsub(vowels.sample,vowels.sample)
67
+ end
68
+ line
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,3 @@
1
+ module Turboname
2
+ VERSION = "0.0.1"
3
+ end
data/turboname.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'turboname/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "turboname"
8
+ spec.version = Turboname::VERSION
9
+ spec.authors = ["José Tomás Albornoz"]
10
+ spec.email = ["jojo@eljojo.net"]
11
+ spec.description = %q{finding domain names at lightspeed}
12
+ spec.summary = %q{Simple gem that searches for random domain names and tells you if they're available}
13
+ spec.homepage = "https://github.com/eljojo/turboname"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+
24
+ spec.add_dependency('whois', '>= 2.0.0') # we should actually test with this version. i just picked a random one
25
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: turboname
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - José Tomás Albornoz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-16 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
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
+ - !ruby/object:Gem::Dependency
42
+ name: whois
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 2.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.0
55
+ description: finding domain names at lightspeed
56
+ email:
57
+ - jojo@eljojo.net
58
+ executables:
59
+ - turboname
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/turboname
70
+ - lib/dictionary.txt
71
+ - lib/turboname.rb
72
+ - lib/turboname/version.rb
73
+ - turboname.gemspec
74
+ homepage: https://github.com/eljojo/turboname
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.0.3
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Simple gem that searches for random domain names and tells you if they're
98
+ available
99
+ test_files: []