FoneFinder 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.
- checksums.yaml +15 -0
- data/lib/FoneFinder.rb +96 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NDFjNzMwN2IzZjIxZjE0NjIwODg5NDljZDQ3OWQyYzRjYjIxNTcwMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NDUyZTA1Y2E4YzU0N2E2OWFjOGU3YmY4MWFkOGMzNDlkNjA4NzJmOA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YjQwZjcyZjE3N2Y0ZDFiYjE5YTJjMGVhOGQ2MjhiNTNhYjRjMTA1OWFiM2Y0
|
10
|
+
ZTk3MGZjNWE5ZTg2ODBjMTg0ODIxN2I2OGIyZGMyMjZiNDViNjI0ZDEyYWJk
|
11
|
+
MGVjNGZkMTkwNzU2YzAyZTJkODNiZjA1MTFiZTFhMzEyNmM2YmQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ODI5YjdmYTA3YTEzOGIzMTM1MzJlOTM5NTE4NjViMGYzNGQzZGJmNGNiMTEz
|
14
|
+
OWYyZTgzZDQ5NTg3ODIxNzI2MTY2ZmUxZjczNDk0OTJkYjJlOTJiYzg0NTdh
|
15
|
+
YWE0OTNhMDkyYWM1ZTIzOTE1OTE1OThiZjQ3MTY2YzBjNjgyMzg=
|
data/lib/FoneFinder.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
class FoneFinder
|
4
|
+
def initialize(number)
|
5
|
+
if(validPhoneNumber(number) == nil)
|
6
|
+
puts "Error invalid phone number"
|
7
|
+
return
|
8
|
+
end
|
9
|
+
@number = number
|
10
|
+
@area = @number[0,3]
|
11
|
+
@prefix = @number[3,3]
|
12
|
+
@thoublock = @number[6,4]
|
13
|
+
@url = makeURL(number)
|
14
|
+
scrape #assigns values to the rest of the properties
|
15
|
+
end
|
16
|
+
def area
|
17
|
+
@area
|
18
|
+
end
|
19
|
+
def prefix
|
20
|
+
@prefix
|
21
|
+
end
|
22
|
+
def thoublock
|
23
|
+
@thoublock
|
24
|
+
end
|
25
|
+
def number
|
26
|
+
@number
|
27
|
+
end
|
28
|
+
def city
|
29
|
+
@city
|
30
|
+
end
|
31
|
+
def state
|
32
|
+
@state
|
33
|
+
end
|
34
|
+
def carrier
|
35
|
+
@carrier
|
36
|
+
end
|
37
|
+
def url
|
38
|
+
@url
|
39
|
+
end
|
40
|
+
|
41
|
+
# canoncalize a phone number
|
42
|
+
private
|
43
|
+
def validPhoneNumber (number)
|
44
|
+
if number.is_a? String
|
45
|
+
number = number.gsub!(/ *-*\(*\)*/, "")
|
46
|
+
if number.size == 10
|
47
|
+
if number.match(/([0-9]){10}/)
|
48
|
+
return number;
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
return nil;
|
53
|
+
end
|
54
|
+
|
55
|
+
# create a URL
|
56
|
+
private
|
57
|
+
def makeURL(number)
|
58
|
+
url = "http://www.fonefinder.net/findome.php?npa=" + @area + "&nxx=" + @prefix + "&thoublock=" + @thoublock + "&usaquerytype=Search+by+Number&cityname="
|
59
|
+
return url
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
# filthy scraping
|
65
|
+
private
|
66
|
+
def scrape
|
67
|
+
html = (open(@url).read)
|
68
|
+
start = "<TABLE border=3 cellspacing=2"
|
69
|
+
start = html.index(start)
|
70
|
+
if (start == nil)
|
71
|
+
puts "Error invalid query"
|
72
|
+
return
|
73
|
+
end
|
74
|
+
startAreaIndex = html.index("<A HREF='findareacode")
|
75
|
+
html = html[startAreaIndex, html.size - startAreaIndex]
|
76
|
+
start = "cityname="
|
77
|
+
endChar = "&"
|
78
|
+
start = html.index(start) + start.size
|
79
|
+
html = html[start, html.size - start]
|
80
|
+
endChar = html.index(endChar)
|
81
|
+
@city = html[0,endChar]
|
82
|
+
html = html[endChar, html.size - city.size]
|
83
|
+
start = "&state="
|
84
|
+
html = html[start.size, html.size - start.size]
|
85
|
+
endChar = "\'"
|
86
|
+
@state = html[0, html.index(endChar)]
|
87
|
+
start = html.index(start)
|
88
|
+
start = "</A><TD><A HREF='http://fonefinder.net"
|
89
|
+
start = start.size + html.index(start)
|
90
|
+
html = html [start, html.size - start]
|
91
|
+
endChar = 1 + html.index(">")
|
92
|
+
html = html[endChar, html.size - endChar]
|
93
|
+
endChar = "<"
|
94
|
+
@carrier = html[0, html.index(endChar)]
|
95
|
+
end
|
96
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: FoneFinder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- evinugur
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Determines information such as carrier and city on a phone number by
|
14
|
+
interfacing with FoneFinder.com
|
15
|
+
email: evinoog96@gmailcom
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/FoneFinder.rb
|
21
|
+
homepage: https://github.com/evinugur
|
22
|
+
licenses: []
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.0.7
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Get metadata for a cell phone in US and Canada
|
44
|
+
test_files: []
|