npa_lookup 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 John Dyer
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.
@@ -0,0 +1,44 @@
1
+ # Command line NPA / NPANXX lookup tool
2
+
3
+ This tool queries CloudVox's NPA lookup API via the command line, that is all, please carry on :)
4
+
5
+ ## Examples
6
+
7
+ dyer:~/dev/number_lookup git:master
8
+ → ./lookup 415704
9
+ +---------------------------+---------------------------------------------+
10
+ | Data | Value |
11
+ +---------------------------+---------------------------------------------+
12
+ | NPA | 415 |
13
+ | Nxx | 704 |
14
+ | State | CA |
15
+ | Status | Allocated |
16
+ | Carrier | PAC - WEST TELECOMM, INC. |
17
+ +---------------------------+---------------------------------------------+
18
+
19
+
20
+ dyer:~/dev/number_lookup git:master
21
+ → ./lookup 4074740200
22
+ +---------------------------+-------------------------------------------------------+
23
+ | Data | Value |
24
+ +---------------------------+-------------------------------------------------------+
25
+ | NPA | 407 |
26
+ | Nxx | 474 |
27
+ | City | Sanford |
28
+ | State | FL |
29
+ | Status | Allocated |
30
+ | Carrier | NEW CINGULAR WIRELESS PCS, LLC - GA |
31
+ +---------------------------+-------------------------------------------------------+
32
+
33
+
34
+ dyer:~/dev/number_lookup git:master
35
+ → ./lookup 407
36
+ +--------------------------+-----------------------------+
37
+ | Data | Value |
38
+ +--------------------------+-----------------------------+
39
+ | NPA | 407 |
40
+ | City | Orlando |
41
+ | State | FL |
42
+ | Status | Allocated |
43
+ +--------------------------+-----------------------------+
44
+
@@ -0,0 +1,48 @@
1
+ # Command line NPA / NPANXX lookup tool
2
+
3
+ This tool queries CloudVox's NPA lookup API via the command line, that is all, please carry on :)
4
+
5
+ ## Examples
6
+
7
+ dyer:~/dev/number_lookup git:master
8
+ → ./lookup 415704
9
+ +---------------------------+---------------------------------------------+
10
+ | Data | Value |
11
+ +---------------------------+---------------------------------------------+
12
+ | NPA | 415 |
13
+ | Nxx | 704 |
14
+ | State | CA |
15
+ | Status | Allocated |
16
+ | Carrier | PAC - WEST TELECOMM, INC. |
17
+ +---------------------------+---------------------------------------------+
18
+
19
+
20
+ dyer:~/dev/number_lookup git:master
21
+ → ./lookup 4074740200
22
+ +---------------------------+-------------------------------------------------------+
23
+ | Data | Value |
24
+ +---------------------------+-------------------------------------------------------+
25
+ | NPA | 407 |
26
+ | Nxx | 474 |
27
+ | City | Sanford |
28
+ | State | FL |
29
+ | Status | Allocated |
30
+ | Carrier | NEW CINGULAR WIRELESS PCS, LLC - GA |
31
+ +---------------------------+-------------------------------------------------------+
32
+
33
+
34
+ dyer:~/dev/number_lookup git:master
35
+ → ./lookup 407
36
+ +--------------------------+-----------------------------+
37
+ | Data | Value |
38
+ +--------------------------+-----------------------------+
39
+ | NPA | 407 |
40
+ | City | Orlando |
41
+ | State | FL |
42
+ | Status | Allocated |
43
+ +--------------------------+-----------------------------+
44
+
45
+
46
+ == Copyright
47
+
48
+ Copyright (c) 2010 John Dyer. See LICENSE for details.
@@ -0,0 +1,46 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "npa_lookup"
8
+ gem.summary = "NPA|Nxx Lookup command line tool for CloudVox's Digits.cloundvox.com API"
9
+ gem.description = "NPA|Nxx Lookup command line tool for CloudVox's Digits.cloundvox.com API"
10
+ gem.email = "john@krumpt.com"
11
+ gem.homepage = "http://github.com/krumpt/npa_lookup"
12
+ gem.authors = ["John Dyer"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'spec/rake/spectask'
22
+ Spec::Rake::SpecTask.new(:spec) do |spec|
23
+ spec.libs << 'lib' << 'spec'
24
+ spec.spec_files = FileList['spec/**/*_spec.rb']
25
+ end
26
+
27
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
28
+ spec.libs << 'lib' << 'spec'
29
+ spec.pattern = 'spec/**/*_spec.rb'
30
+ spec.rcov = true
31
+ end
32
+
33
+ task :spec => :check_dependencies
34
+
35
+ task :default => :spec
36
+
37
+ require 'rake/rdoctask'
38
+ Rake::RDocTask.new do |rdoc|
39
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
+
41
+ rdoc.rdoc_dir = 'rdoc'
42
+ rdoc.title = "npa_lookup #{version}"
43
+ rdoc.rdoc_files.include('README*')
44
+ rdoc.rdoc_files.include('lib/**/*.rb')
45
+ end
46
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.0
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby -WKU
2
+ require 'rubygems'
3
+ require "net/http"
4
+ require "uri"
5
+ require 'json/pure'
6
+ require 'terminal-table/import' #http://vision-media.ca/resources/ruby/ruby-terminal-table-gem
7
+
8
+ SPACES = "18"
9
+
10
+ def colorize(text, color_code,how_many_spaces)
11
+ "\e[#{color_code}m#{text}\e[#{how_many_spaces}C\033[0m\033[0m"
12
+ end
13
+
14
+ def red(text,how_many_spaces); colorize(text, 31,how_many_spaces); end
15
+ def green(text,how_many_spaces); colorize(text, 32,how_many_spaces); end
16
+ def yellow(text,how_many_spaces); colorize(text, 33,how_many_spaces); end
17
+ def blue(text,how_many_spaces); colorize(text, 34,how_many_spaces); end
18
+ def cyan(text,how_many_spaces); colorize(text, 36,how_many_spaces); end
19
+ def white(test,how_many_spaces);colorize(test,37,how_many_spaces);end
20
+
21
+ def parse_args(i)
22
+ i=i.to_s
23
+ if i.length==3
24
+ return i
25
+ elsif i.length==6
26
+ i=i.dup
27
+ i.insert(3, '/')
28
+ elsif i.length==10
29
+ return i
30
+ else
31
+ puts "Error {NumberError}"
32
+ exit!
33
+ end
34
+ end
35
+
36
+ ARGV.each do|a|
37
+ uri = URI.parse("http://digits.cloudvox.com/#{parse_args(a)}.json")
38
+ response = Net::HTTP.get_response(uri)
39
+ begin
40
+ jsonObject = JSON.parse(response.body)
41
+ rescue JSON::ParserError => msg
42
+ puts "Failed: #{msg.message} | #{a}.json"
43
+ exit!
44
+ end
45
+
46
+ data = jsonObject['allocation']
47
+
48
+ t = table ['Data', 'Value']
49
+ t << [red("NPA","18"),yellow("#{data['npa']}",SPACES)]
50
+
51
+ if data['nxx']!=nil; t << [red("Nxx","18"),yellow("#{data['nxx']}",SPACES)];end
52
+
53
+ if data['ratecenter_formatted'] !=nil&&data['ratecenter_formatted']!=""; t << [red("City","18"),yellow("#{data['ratecenter_formatted']}",SPACES)]; end
54
+
55
+ t << [red("State","18"),yellow("#{data['region']}",SPACES)]
56
+ t << [red("Status","18"),yellow("#{data['status'].capitalize}",SPACES)]
57
+
58
+ if data['carrier_name'] !=nil; t << [red("Carrier","18"),yellow("#{data['carrier_name']}",SPACES)]; end
59
+
60
+ puts t
61
+ puts "\n\n"
62
+ end
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby -WKU
2
+ require 'rubygems'
3
+ require "net/http"
4
+ require "uri"
5
+ require 'json/pure'
6
+ require 'terminal-table/import' #http://vision-media.ca/resources/ruby/ruby-terminal-table-gem
7
+
8
+ SPACES = "18"
9
+
10
+ def colorize(text, color_code,how_many_spaces)
11
+ "\e[#{color_code}m#{text}\e[#{how_many_spaces}C\033[0m\033[0m"
12
+ end
13
+
14
+ def red(text,how_many_spaces); colorize(text, 31,how_many_spaces); end
15
+ def green(text,how_many_spaces); colorize(text, 32,how_many_spaces); end
16
+ def yellow(text,how_many_spaces); colorize(text, 33,how_many_spaces); end
17
+ def blue(text,how_many_spaces); colorize(text, 34,how_many_spaces); end
18
+ def cyan(text,how_many_spaces); colorize(text, 36,how_many_spaces); end
19
+ def white(test,how_many_spaces);colorize(test,37,how_many_spaces);end
20
+
21
+ def parse_args(i)
22
+ i=i.to_s
23
+ if i.length==3
24
+ return i
25
+ elsif i.length==6
26
+ i=i.dup
27
+ i.insert(3, '/')
28
+ elsif i.length==10
29
+ return i
30
+ else
31
+ puts "Error {NumberError}"
32
+ exit!
33
+ end
34
+ end
35
+
36
+ ARGV.each do|a|
37
+ uri = URI.parse("http://digits.cloudvox.com/#{parse_args(a)}.json")
38
+ response = Net::HTTP.get_response(uri)
39
+ begin
40
+ jsonObject = JSON.parse(response.body)
41
+ rescue JSON::ParserError => msg
42
+ puts "Failed: #{msg.message} | #{a}.json"
43
+ exit!
44
+ end
45
+
46
+ data = jsonObject['allocation']
47
+
48
+ t = table ['Data', 'Value']
49
+ t << [red("NPA","18"),yellow("#{data['npa']}",SPACES)]
50
+
51
+ if data['nxx']!=nil; t << [red("Nxx","18"),yellow("#{data['nxx']}",SPACES)];end
52
+
53
+ if data['ratecenter_formatted'] !=nil&&data['ratecenter_formatted']!=""; t << [red("City","18"),yellow("#{data['ratecenter_formatted']}",SPACES)]; end
54
+
55
+ t << [red("State","18"),yellow("#{data['region']}",SPACES)]
56
+ t << [red("Status","18"),yellow("#{data['status'].capitalize}",SPACES)]
57
+
58
+ if data['carrier_name'] !=nil; t << [red("Carrier","18"),yellow("#{data['carrier_name']}",SPACES)]; end
59
+
60
+ puts t
61
+ puts "\n\n"
62
+ end
Binary file
@@ -0,0 +1,61 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{npa_lookup}
8
+ s.version = "0.3.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["John Dyer"]
12
+ s.date = %q{2010-07-29}
13
+ s.default_executable = %q{lookup}
14
+ s.description = %q{NPA|Nxx Lookup command line tool for CloudVox's Digits.cloundvox.com API}
15
+ s.email = %q{john@krumpt.com}
16
+ s.executables = ["lookup"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.markdown",
20
+ "README.rdoc"
21
+ ]
22
+ s.files = [
23
+ ".document",
24
+ ".gitignore",
25
+ "LICENSE",
26
+ "README.markdown",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "bin/lookup",
31
+ "lib/npa_lookup.rb",
32
+ "npa_lookup-0.2.0.gem",
33
+ "npa_lookup.gemspec",
34
+ "spec/npa_lookup_spec.rb",
35
+ "spec/spec.opts",
36
+ "spec/spec_helper.rb"
37
+ ]
38
+ s.homepage = %q{http://github.com/krumpt/npa_lookup}
39
+ s.rdoc_options = ["--charset=UTF-8"]
40
+ s.require_paths = ["lib"]
41
+ s.rubygems_version = %q{1.3.7}
42
+ s.summary = %q{NPA|Nxx Lookup command line tool for CloudVox's Digits.cloundvox.com API}
43
+ s.test_files = [
44
+ "spec/npa_lookup_spec.rb",
45
+ "spec/spec_helper.rb"
46
+ ]
47
+
48
+ if s.respond_to? :specification_version then
49
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
+ s.specification_version = 3
51
+
52
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
54
+ else
55
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
56
+ end
57
+ else
58
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
59
+ end
60
+ end
61
+
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "NpaLookup" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'npa_lookup'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: npa_lookup
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
+ platform: ruby
12
+ authors:
13
+ - John Dyer
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-29 00:00:00 -04:00
19
+ default_executable: lookup
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 1
32
+ - 2
33
+ - 9
34
+ version: 1.2.9
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: NPA|Nxx Lookup command line tool for CloudVox's Digits.cloundvox.com API
38
+ email: john@krumpt.com
39
+ executables:
40
+ - lookup
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - LICENSE
45
+ - README.markdown
46
+ - README.rdoc
47
+ files:
48
+ - .document
49
+ - .gitignore
50
+ - LICENSE
51
+ - README.markdown
52
+ - README.rdoc
53
+ - Rakefile
54
+ - VERSION
55
+ - bin/lookup
56
+ - lib/npa_lookup.rb
57
+ - npa_lookup-0.2.0.gem
58
+ - npa_lookup.gemspec
59
+ - spec/npa_lookup_spec.rb
60
+ - spec/spec.opts
61
+ - spec/spec_helper.rb
62
+ has_rdoc: true
63
+ homepage: http://github.com/krumpt/npa_lookup
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options:
68
+ - --charset=UTF-8
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ requirements: []
90
+
91
+ rubyforge_project:
92
+ rubygems_version: 1.3.7
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: NPA|Nxx Lookup command line tool for CloudVox's Digits.cloundvox.com API
96
+ test_files:
97
+ - spec/npa_lookup_spec.rb
98
+ - spec/spec_helper.rb