kdonovan-duns-lookup 0.0.0 → 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/README.rdoc +12 -2
- data/Rakefile +1 -1
- data/duns-lookup.gemspec +57 -0
- data/lib/duns-lookup.rb +3 -3
- data/spec/duns-lookup_spec.rb +2 -2
- data/spec/spec_helper.rb +10 -0
- metadata +5 -4
data/README.rdoc
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
This provides a small wrapper around the Dun & Bradstreet website to retrieve business information from DUNS numbers.
|
|
4
4
|
|
|
5
|
+
== Usage
|
|
6
|
+
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
require 'kdonovan-duns-lookup'
|
|
9
|
+
|
|
10
|
+
Duns.lookup_duns( *invalid_number* )
|
|
11
|
+
# => nil
|
|
12
|
+
Duns.lookup_duns( *some_valid_number* )
|
|
13
|
+
# => {:name => *a_name*, :address => *an_address*}
|
|
14
|
+
|
|
15
|
+
|
|
5
16
|
== Note on Patches/Pull Requests
|
|
6
17
|
|
|
7
18
|
* Fork the project.
|
|
@@ -9,8 +20,7 @@ This provides a small wrapper around the Dun & Bradstreet website to retrieve bu
|
|
|
9
20
|
* Add tests for it. This is important so I don't break it in a
|
|
10
21
|
future version unintentionally.
|
|
11
22
|
* Commit, do not mess with rakefile, version, or history.
|
|
12
|
-
(if you want to have your own version, that is fine but
|
|
13
|
-
bump version in a commit by itself I can ignore when I pull)
|
|
23
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
|
14
24
|
* Send me a pull request. Bonus points for topic branches.
|
|
15
25
|
|
|
16
26
|
== Copyright
|
data/Rakefile
CHANGED
|
@@ -5,7 +5,7 @@ begin
|
|
|
5
5
|
require 'jeweler'
|
|
6
6
|
Jeweler::Tasks.new do |gem|
|
|
7
7
|
gem.name = "duns-lookup"
|
|
8
|
-
gem.summary = "
|
|
8
|
+
gem.summary = "Wrapper for looking up Dun & Bradstreet numbers (DUNS)"
|
|
9
9
|
gem.description = %Q{Provides a small wrapper around the Dun & Bradstreet website to retrieve business information from DUNS numbers.}
|
|
10
10
|
gem.email = "kali.donovan@gmail.com"
|
|
11
11
|
gem.homepage = "http://github.com/kdonovan/duns-lookup"
|
data/duns-lookup.gemspec
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
|
4
|
+
# -*- encoding: utf-8 -*-
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = %q{duns-lookup}
|
|
8
|
+
s.version = "0.0.1"
|
|
9
|
+
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
+
s.authors = ["Kali Donovan"]
|
|
12
|
+
s.date = %q{2009-08-12}
|
|
13
|
+
s.description = %q{Provides a small wrapper around the Dun & Bradstreet website to retrieve business information from DUNS numbers.}
|
|
14
|
+
s.email = %q{kali.donovan@gmail.com}
|
|
15
|
+
s.extra_rdoc_files = [
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"README.rdoc"
|
|
18
|
+
]
|
|
19
|
+
s.files = [
|
|
20
|
+
".document",
|
|
21
|
+
".gitignore",
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"README.rdoc",
|
|
24
|
+
"Rakefile",
|
|
25
|
+
"VERSION",
|
|
26
|
+
"duns-lookup.gemspec",
|
|
27
|
+
"lib/duns-lookup.rb",
|
|
28
|
+
"spec/duns-lookup_spec.rb",
|
|
29
|
+
"spec/spec_helper.rb"
|
|
30
|
+
]
|
|
31
|
+
s.has_rdoc = true
|
|
32
|
+
s.homepage = %q{http://github.com/kdonovan/duns-lookup}
|
|
33
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
|
34
|
+
s.require_paths = ["lib"]
|
|
35
|
+
s.rubygems_version = %q{1.3.1}
|
|
36
|
+
s.summary = %q{Wrapper for looking up Dun & Bradstreet numbers (DUNS)}
|
|
37
|
+
s.test_files = [
|
|
38
|
+
"spec/duns-lookup_spec.rb",
|
|
39
|
+
"spec/spec_helper.rb"
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
if s.respond_to? :specification_version then
|
|
43
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
44
|
+
s.specification_version = 2
|
|
45
|
+
|
|
46
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
47
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
|
48
|
+
s.add_development_dependency(%q<mechanize>, [">= 0"])
|
|
49
|
+
else
|
|
50
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
|
51
|
+
s.add_dependency(%q<mechanize>, [">= 0"])
|
|
52
|
+
end
|
|
53
|
+
else
|
|
54
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
|
55
|
+
s.add_dependency(%q<mechanize>, [">= 0"])
|
|
56
|
+
end
|
|
57
|
+
end
|
data/lib/duns-lookup.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
class DunsError < Exception
|
|
2
2
|
end
|
|
3
3
|
|
|
4
|
-
class Duns
|
|
5
4
|
# = Synopsis
|
|
6
5
|
# The Duns library provides a small wrapper around the Dun & Bradstreet
|
|
7
6
|
# website's advanced search functionality. Currently it only implements
|
|
@@ -11,11 +10,12 @@ class Duns
|
|
|
11
10
|
# require 'rubygems'
|
|
12
11
|
# require 'kdonovan-duns-lookup'
|
|
13
12
|
#
|
|
14
|
-
# Duns.lookup_duns(
|
|
13
|
+
# Duns.lookup_duns( *invalid_number* )
|
|
15
14
|
# # => nil
|
|
16
15
|
# Duns.lookup_duns( *some_valid_number* )
|
|
17
16
|
# # => {:name => *a_name*, :address => *an_address*}
|
|
18
17
|
|
|
18
|
+
class Duns
|
|
19
19
|
require 'rubygems'
|
|
20
20
|
require 'open-uri'
|
|
21
21
|
require 'mechanize'
|
|
@@ -92,7 +92,7 @@ class Duns
|
|
|
92
92
|
|
|
93
93
|
# Strip out non-numeric characters, and raise error if remaining number is still invalid
|
|
94
94
|
def self.enforce_duns_formatting(orig_number)
|
|
95
|
-
number = orig_number.gsub(/\D/, '')
|
|
95
|
+
number = orig_number.to_s.gsub(/\D/, '')
|
|
96
96
|
raise(DunsError, "Received invalid DUNS number (must be 9 digits): #{orig_number}") unless number.length == 9
|
|
97
97
|
return number
|
|
98
98
|
end
|
data/spec/duns-lookup_spec.rb
CHANGED
|
@@ -16,11 +16,11 @@ describe "DunsLookup" do
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "Returns no results where there shouldn't be any" do
|
|
19
|
-
Duns.lookup_duns(
|
|
19
|
+
Duns.lookup_duns( fake_duns_number ).should be_nil
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "Should properly extract company name and address when a valid result is found" do
|
|
23
|
-
results = Duns.lookup_duns(
|
|
23
|
+
results = Duns.lookup_duns( real_duns_number )
|
|
24
24
|
results.should_not be_nil
|
|
25
25
|
results.should be_a_kind_of Hash
|
|
26
26
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kdonovan-duns-lookup
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kali Donovan
|
|
@@ -23,7 +23,7 @@ dependencies:
|
|
|
23
23
|
version: "0"
|
|
24
24
|
version:
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
|
-
name:
|
|
26
|
+
name: mechanize
|
|
27
27
|
type: :development
|
|
28
28
|
version_requirement:
|
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -32,7 +32,7 @@ dependencies:
|
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: "0"
|
|
34
34
|
version:
|
|
35
|
-
description: Provides a small wrapper around
|
|
35
|
+
description: Provides a small wrapper around the Dun & Bradstreet website to retrieve business information from DUNS numbers.
|
|
36
36
|
email: kali.donovan@gmail.com
|
|
37
37
|
executables: []
|
|
38
38
|
|
|
@@ -48,6 +48,7 @@ files:
|
|
|
48
48
|
- README.rdoc
|
|
49
49
|
- Rakefile
|
|
50
50
|
- VERSION
|
|
51
|
+
- duns-lookup.gemspec
|
|
51
52
|
- lib/duns-lookup.rb
|
|
52
53
|
- spec/duns-lookup_spec.rb
|
|
53
54
|
- spec/spec_helper.rb
|
|
@@ -77,7 +78,7 @@ rubyforge_project:
|
|
|
77
78
|
rubygems_version: 1.3.5
|
|
78
79
|
signing_key:
|
|
79
80
|
specification_version: 2
|
|
80
|
-
summary:
|
|
81
|
+
summary: Wrapper for looking up Dun & Bradstreet numbers (DUNS)
|
|
81
82
|
test_files:
|
|
82
83
|
- spec/duns-lookup_spec.rb
|
|
83
84
|
- spec/spec_helper.rb
|