kdonovan-duns-lookup 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ begin
11
11
  gem.homepage = "http://github.com/kdonovan/duns-lookup"
12
12
  gem.authors = ["Kali Donovan"]
13
13
  gem.add_development_dependency "rspec"
14
+ gem.add_development_dependency "nokogiri"
14
15
  gem.add_development_dependency "mechanize"
15
16
  end
16
17
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -0,0 +1,265 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Duns</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Duns</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/duns-lookup_rb.html">
59
+ lib/duns-lookup.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+ <div id="description">
82
+ <h1>Synopsis</h1>
83
+ <p>
84
+ The <a href="Duns.html">Duns</a> library provides a small wrapper around
85
+ the Dun &amp; Bradstreet website&#8216;s advanced search functionality.
86
+ Currently it only implements searching for company by DUNS number.
87
+ </p>
88
+ <h2>Example</h2>
89
+ <pre>
90
+ require 'rubygems'
91
+ require 'kdonovan-duns-lookup'
92
+
93
+ Duns.lookup_duns( *invalid_number* )
94
+ # =&gt; nil
95
+ Duns.lookup_duns( *some_valid_number* )
96
+ # =&gt; {:name =&gt; *a_name*, :address =&gt; *an_address*}
97
+ </pre>
98
+
99
+ </div>
100
+
101
+
102
+ </div>
103
+
104
+ <div id="method-list">
105
+ <h3 class="section-bar">Methods</h3>
106
+
107
+ <div class="name-list">
108
+ <a href="#M000006">enforce_duns_formatting</a>&nbsp;&nbsp;
109
+ <a href="#M000004">extract_address</a>&nbsp;&nbsp;
110
+ <a href="#M000005">extract_name</a>&nbsp;&nbsp;
111
+ <a href="#M000003">extract_search_results</a>&nbsp;&nbsp;
112
+ <a href="#M000001">lookup_duns</a>&nbsp;&nbsp;
113
+ <a href="#M000002">update_advanced_search_url</a>&nbsp;&nbsp;
114
+ </div>
115
+ </div>
116
+
117
+ </div>
118
+
119
+
120
+ <!-- if includes -->
121
+
122
+ <div id="section">
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+ <!-- if method_list -->
132
+ <div id="methods">
133
+ <h3 class="section-bar">Public Class methods</h3>
134
+
135
+ <div id="method-M000001" class="method-detail">
136
+ <a name="M000001"></a>
137
+
138
+ <div class="method-heading">
139
+ <a href="Duns.src/M000001.html" target="Code" class="method-signature"
140
+ onclick="popupCode('Duns.src/M000001.html');return false;">
141
+ <span class="method-name">lookup_duns</span><span class="method-args">(number)</span>
142
+ </a>
143
+ </div>
144
+
145
+ <div class="method-description">
146
+ <p>
147
+ Look up a given DUNS number in the D&amp;B database. If the number is
148
+ found, returns a hash with :name and :address keys. Otherwise, returns nil.
149
+ </p>
150
+ </div>
151
+ </div>
152
+
153
+ <div id="method-M000002" class="method-detail">
154
+ <a name="M000002"></a>
155
+
156
+ <div class="method-heading">
157
+ <a href="Duns.src/M000002.html" target="Code" class="method-signature"
158
+ onclick="popupCode('Duns.src/M000002.html');return false;">
159
+ <span class="method-name">update_advanced_search_url</span><span class="method-args">()</span>
160
+ </a>
161
+ </div>
162
+
163
+ <div class="method-description">
164
+ <p>
165
+ Updates the internal URL used as the base for advanced searches.
166
+ </p>
167
+ <p>
168
+ The D&amp;B website uses lots of extraneous (to us) URL params, and I have
169
+ no idea what they all mean. If the base URL stops working, this method will
170
+ try to set a new one by visiting the main page and finding &amp; clicking
171
+ an Advanced Search link.
172
+ </p>
173
+ <p>
174
+ This is mostly a precaution, but if searches stop working a good first bet
175
+ would be to try running this method. If search is still broken, something
176
+ actually changed in the D&amp;B HTML and we&#8216;ll need to retool the
177
+ gem.
178
+ </p>
179
+ </div>
180
+ </div>
181
+
182
+ <h3 class="section-bar">Protected Class methods</h3>
183
+
184
+ <div id="method-M000006" class="method-detail">
185
+ <a name="M000006"></a>
186
+
187
+ <div class="method-heading">
188
+ <a href="Duns.src/M000006.html" target="Code" class="method-signature"
189
+ onclick="popupCode('Duns.src/M000006.html');return false;">
190
+ <span class="method-name">enforce_duns_formatting</span><span class="method-args">(orig_number)</span>
191
+ </a>
192
+ </div>
193
+
194
+ <div class="method-description">
195
+ <p>
196
+ Strip out non-numeric characters, and raise error if remaining number is
197
+ still invalid
198
+ </p>
199
+ </div>
200
+ </div>
201
+
202
+ <div id="method-M000004" class="method-detail">
203
+ <a name="M000004"></a>
204
+
205
+ <div class="method-heading">
206
+ <a href="Duns.src/M000004.html" target="Code" class="method-signature"
207
+ onclick="popupCode('Duns.src/M000004.html');return false;">
208
+ <span class="method-name">extract_address</span><span class="method-args">(td)</span>
209
+ </a>
210
+ </div>
211
+
212
+ <div class="method-description">
213
+ <p>
214
+ Retrieve an address from the proper D&amp;B HTML for the td element
215
+ </p>
216
+ </div>
217
+ </div>
218
+
219
+ <div id="method-M000005" class="method-detail">
220
+ <a name="M000005"></a>
221
+
222
+ <div class="method-heading">
223
+ <a href="Duns.src/M000005.html" target="Code" class="method-signature"
224
+ onclick="popupCode('Duns.src/M000005.html');return false;">
225
+ <span class="method-name">extract_name</span><span class="method-args">(td)</span>
226
+ </a>
227
+ </div>
228
+
229
+ <div class="method-description">
230
+ <p>
231
+ Retrieve a name from the proper D&amp;B HTML for the td element
232
+ </p>
233
+ </div>
234
+ </div>
235
+
236
+ <div id="method-M000003" class="method-detail">
237
+ <a name="M000003"></a>
238
+
239
+ <div class="method-heading">
240
+ <a href="Duns.src/M000003.html" target="Code" class="method-signature"
241
+ onclick="popupCode('Duns.src/M000003.html');return false;">
242
+ <span class="method-name">extract_search_results</span><span class="method-args">(page)</span>
243
+ </a>
244
+ </div>
245
+
246
+ <div class="method-description">
247
+ <p>
248
+ Given a search page, extract the results
249
+ </p>
250
+ </div>
251
+ </div>
252
+
253
+
254
+ </div>
255
+
256
+
257
+ </div>
258
+
259
+
260
+ <div id="validator-badges">
261
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
262
+ </div>
263
+
264
+ </body>
265
+ </html>
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>lookup_duns (Duns)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/duns-lookup.rb, line 39</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">lookup_duns</span>(<span class="ruby-identifier">number</span>)
15
+ <span class="ruby-identifier">form</span> = <span class="ruby-ivar">@@agent</span>.<span class="ruby-identifier">get</span>( <span class="ruby-ivar">@@dnb_advanced_search</span> ).<span class="ruby-identifier">form</span>(<span class="ruby-value str">'DunsSearchForm'</span>)
16
+ <span class="ruby-identifier">form</span>.<span class="ruby-identifier">dunsNumber</span> = <span class="ruby-identifier">enforce_duns_formatting</span>(<span class="ruby-identifier">number</span>)
17
+ <span class="ruby-identifier">page</span> = <span class="ruby-ivar">@@agent</span>.<span class="ruby-identifier">submit</span>(<span class="ruby-identifier">form</span>)
18
+
19
+ <span class="ruby-identifier">extract_search_results</span>(<span class="ruby-identifier">page</span>)
20
+ <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>update_advanced_search_url (Duns)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/duns-lookup.rb, line 59</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">update_advanced_search_url</span>
15
+ <span class="ruby-identifier">page</span> = <span class="ruby-ivar">@@agent</span>.<span class="ruby-identifier">get</span>( <span class="ruby-ivar">@@dnb_homepage</span> )
16
+ <span class="ruby-identifier">advanced_link</span> = <span class="ruby-identifier">page</span>.<span class="ruby-identifier">links</span>.<span class="ruby-identifier">find</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">text</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/search/i</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/AdvancedCompanySearch/</span>)}
17
+ <span class="ruby-identifier">raise</span>(<span class="ruby-constant">DunsError</span>, <span class="ruby-node">&quot;Unable to find an advanced search link at: #{@@dnb_homepage}&quot;</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">advanced_link</span>.<span class="ruby-identifier">nil?</span>
18
+ <span class="ruby-ivar">@@dnb_advanced_search</span> = <span class="ruby-identifier">advanced_link</span>.<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>
19
+ <span class="ruby-keyword kw">end</span></pre>
20
+ </body>
21
+ </html>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>extract_search_results (Duns)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/duns-lookup.rb, line 70</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">extract_search_results</span>(<span class="ruby-identifier">page</span>)
15
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">page</span>.<span class="ruby-identifier">search</span>(<span class="ruby-value str">'div.text-red'</span>).<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
16
+
17
+ <span class="ruby-comment cmt"># Given a DUNS number search, we only expect one result. For other search types (when/if implemented), loop over all TRs returned in this table</span>
18
+ <span class="ruby-identifier">company_name</span> = <span class="ruby-identifier">extract_name</span>( <span class="ruby-identifier">page</span>.<span class="ruby-identifier">search</span>(<span class="ruby-value str">&quot;//table[@id='SearchResultsTable']//tr[1]/td[2]&quot;</span>) )
19
+ <span class="ruby-identifier">company_address</span> = <span class="ruby-identifier">extract_address</span>( <span class="ruby-identifier">page</span>.<span class="ruby-identifier">search</span>(<span class="ruby-value str">&quot;//table[@id='SearchResultsTable']//tr[1]/td[3]&quot;</span>) )
20
+
21
+ {<span class="ruby-identifier">:name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">company_name</span>, <span class="ruby-identifier">:address</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">company_address</span>}
22
+ <span class="ruby-keyword kw">end</span></pre>
23
+ </body>
24
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>extract_address (Duns)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/duns-lookup.rb, line 81</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">extract_address</span>(<span class="ruby-identifier">td</span>)
15
+ <span class="ruby-identifier">td</span>.<span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\s{2,}/</span>, <span class="ruby-value str">' '</span>)
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>extract_name (Duns)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/duns-lookup.rb, line 86</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">extract_name</span>(<span class="ruby-identifier">td</span>)
15
+ <span class="ruby-identifier">raw_text</span> = <span class="ruby-identifier">td</span>.<span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\s{2,}/</span>, <span class="ruby-value str">' '</span>)
16
+ <span class="ruby-identifier">with_js</span> = <span class="ruby-identifier">raw_text</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/var companyName=escape(.+?)var companyAddr/</span>)[<span class="ruby-value">1</span>] <span class="ruby-comment cmt"># First get the surrounding js, to ensure we don't get confused by e.g. a ) in the company name</span>
17
+
18
+ <span class="ruby-comment cmt"># Now we have e.g. &gt;&gt; ('NORTH TEXAS CIRCUIT BOARD CO., INC.'); &lt;&lt; and we need to strip off the extraneous stuff</span>
19
+ <span class="ruby-identifier">with_js</span>[<span class="ruby-value">2</span><span class="ruby-operator">..</span><span class="ruby-value">-5</span>]
20
+ <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>enforce_duns_formatting (Duns)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/duns-lookup.rb, line 95</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">enforce_duns_formatting</span>(<span class="ruby-identifier">orig_number</span>)
15
+ <span class="ruby-identifier">number</span> = <span class="ruby-identifier">orig_number</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\D/</span>, <span class="ruby-value str">''</span>)
16
+ <span class="ruby-identifier">raise</span>(<span class="ruby-constant">DunsError</span>, <span class="ruby-node">&quot;Received invalid DUNS number (must be 9 digits): #{orig_number}&quot;</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">number</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">9</span>
17
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">number</span>
18
+ <span class="ruby-keyword kw">end</span></pre>
19
+ </body>
20
+ </html>
@@ -0,0 +1,111 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: DunsError</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">DunsError</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/duns-lookup_rb.html">
59
+ lib/duns-lookup.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Exception
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+
82
+
83
+ </div>
84
+
85
+
86
+ </div>
87
+
88
+
89
+ <!-- if includes -->
90
+
91
+ <div id="section">
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+ <!-- if method_list -->
101
+
102
+
103
+ </div>
104
+
105
+
106
+ <div id="validator-badges">
107
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
108
+ </div>
109
+
110
+ </body>
111
+ </html>
@@ -0,0 +1 @@
1
+ Wed, 12 Aug 2009 15:11:32 -0700
@@ -0,0 +1,110 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: duns-lookup.rb</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>duns-lookup.rb</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>lib/duns-lookup.rb
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Wed Aug 12 15:11:28 -0700 2009</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+
72
+ <div id="requires-list">
73
+ <h3 class="section-bar">Required files</h3>
74
+
75
+ <div class="name-list">
76
+ rubygems&nbsp;&nbsp;
77
+ open-uri&nbsp;&nbsp;
78
+ mechanize&nbsp;&nbsp;
79
+ </div>
80
+ </div>
81
+
82
+ </div>
83
+
84
+
85
+ </div>
86
+
87
+
88
+ <!-- if includes -->
89
+
90
+ <div id="section">
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+ <!-- if method_list -->
100
+
101
+
102
+ </div>
103
+
104
+
105
+ <div id="validator-badges">
106
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
107
+ </div>
108
+
109
+ </body>
110
+ </html>
@@ -0,0 +1,28 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Classes
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Classes</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Classes</h1>
22
+ <div id="index-entries">
23
+ <a href="classes/Duns.html">Duns</a><br />
24
+ <a href="classes/DunsError.html">DunsError</a><br />
25
+ </div>
26
+ </div>
27
+ </body>
28
+ </html>
@@ -0,0 +1,27 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Files
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Files</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Files</h1>
22
+ <div id="index-entries">
23
+ <a href="files/lib/duns-lookup_rb.html">lib/duns-lookup.rb</a><br />
24
+ </div>
25
+ </div>
26
+ </body>
27
+ </html>
@@ -0,0 +1,32 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Methods
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Methods</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Methods</h1>
22
+ <div id="index-entries">
23
+ <a href="classes/Duns.html#M000006">enforce_duns_formatting (Duns)</a><br />
24
+ <a href="classes/Duns.html#M000004">extract_address (Duns)</a><br />
25
+ <a href="classes/Duns.html#M000005">extract_name (Duns)</a><br />
26
+ <a href="classes/Duns.html#M000003">extract_search_results (Duns)</a><br />
27
+ <a href="classes/Duns.html#M000001">lookup_duns (Duns)</a><br />
28
+ <a href="classes/Duns.html#M000002">update_advanced_search_url (Duns)</a><br />
29
+ </div>
30
+ </div>
31
+ </body>
32
+ </html>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
5
+
6
+ <!--
7
+
8
+ RDoc Documentation
9
+
10
+ -->
11
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
12
+ <head>
13
+ <title>RDoc Documentation</title>
14
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
15
+ </head>
16
+ <frameset rows="20%, 80%">
17
+ <frameset cols="25%,35%,45%">
18
+ <frame src="fr_file_index.html" title="Files" name="Files" />
19
+ <frame src="fr_class_index.html" name="Classes" />
20
+ <frame src="fr_method_index.html" name="Methods" />
21
+ </frameset>
22
+ <frame src="files/lib/duns-lookup_rb.html" name="docwin" />
23
+ </frameset>
24
+ </html>
@@ -0,0 +1,208 @@
1
+
2
+ body {
3
+ font-family: Verdana,Arial,Helvetica,sans-serif;
4
+ font-size: 90%;
5
+ margin: 0;
6
+ margin-left: 40px;
7
+ padding: 0;
8
+ background: white;
9
+ }
10
+
11
+ h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
12
+ h1 { font-size: 150%; }
13
+ h2,h3,h4 { margin-top: 1em; }
14
+
15
+ a { background: #eef; color: #039; text-decoration: none; }
16
+ a:hover { background: #039; color: #eef; }
17
+
18
+ /* Override the base stylesheet's Anchor inside a table cell */
19
+ td > a {
20
+ background: transparent;
21
+ color: #039;
22
+ text-decoration: none;
23
+ }
24
+
25
+ /* and inside a section title */
26
+ .section-title > a {
27
+ background: transparent;
28
+ color: #eee;
29
+ text-decoration: none;
30
+ }
31
+
32
+ /* === Structural elements =================================== */
33
+
34
+ div#index {
35
+ margin: 0;
36
+ margin-left: -40px;
37
+ padding: 0;
38
+ font-size: 90%;
39
+ }
40
+
41
+
42
+ div#index a {
43
+ margin-left: 0.7em;
44
+ }
45
+
46
+ div#index .section-bar {
47
+ margin-left: 0px;
48
+ padding-left: 0.7em;
49
+ background: #ccc;
50
+ font-size: small;
51
+ }
52
+
53
+
54
+ div#classHeader, div#fileHeader {
55
+ width: auto;
56
+ color: white;
57
+ padding: 0.5em 1.5em 0.5em 1.5em;
58
+ margin: 0;
59
+ margin-left: -40px;
60
+ border-bottom: 3px solid #006;
61
+ }
62
+
63
+ div#classHeader a, div#fileHeader a {
64
+ background: inherit;
65
+ color: white;
66
+ }
67
+
68
+ div#classHeader td, div#fileHeader td {
69
+ background: inherit;
70
+ color: white;
71
+ }
72
+
73
+
74
+ div#fileHeader {
75
+ background: #057;
76
+ }
77
+
78
+ div#classHeader {
79
+ background: #048;
80
+ }
81
+
82
+
83
+ .class-name-in-header {
84
+ font-size: 180%;
85
+ font-weight: bold;
86
+ }
87
+
88
+
89
+ div#bodyContent {
90
+ padding: 0 1.5em 0 1.5em;
91
+ }
92
+
93
+ div#description {
94
+ padding: 0.5em 1.5em;
95
+ background: #efefef;
96
+ border: 1px dotted #999;
97
+ }
98
+
99
+ div#description h1,h2,h3,h4,h5,h6 {
100
+ color: #125;;
101
+ background: transparent;
102
+ }
103
+
104
+ div#validator-badges {
105
+ text-align: center;
106
+ }
107
+ div#validator-badges img { border: 0; }
108
+
109
+ div#copyright {
110
+ color: #333;
111
+ background: #efefef;
112
+ font: 0.75em sans-serif;
113
+ margin-top: 5em;
114
+ margin-bottom: 0;
115
+ padding: 0.5em 2em;
116
+ }
117
+
118
+
119
+ /* === Classes =================================== */
120
+
121
+ table.header-table {
122
+ color: white;
123
+ font-size: small;
124
+ }
125
+
126
+ .type-note {
127
+ font-size: small;
128
+ color: #DEDEDE;
129
+ }
130
+
131
+ .xxsection-bar {
132
+ background: #eee;
133
+ color: #333;
134
+ padding: 3px;
135
+ }
136
+
137
+ .section-bar {
138
+ color: #333;
139
+ border-bottom: 1px solid #999;
140
+ margin-left: -20px;
141
+ }
142
+
143
+
144
+ .section-title {
145
+ background: #79a;
146
+ color: #eee;
147
+ padding: 3px;
148
+ margin-top: 2em;
149
+ margin-left: -30px;
150
+ border: 1px solid #999;
151
+ }
152
+
153
+ .top-aligned-row { vertical-align: top }
154
+ .bottom-aligned-row { vertical-align: bottom }
155
+
156
+ /* --- Context section classes ----------------------- */
157
+
158
+ .context-row { }
159
+ .context-item-name { font-family: monospace; font-weight: bold; color: black; }
160
+ .context-item-value { font-size: small; color: #448; }
161
+ .context-item-desc { color: #333; padding-left: 2em; }
162
+
163
+ /* --- Method classes -------------------------- */
164
+ .method-detail {
165
+ background: #efefef;
166
+ padding: 0;
167
+ margin-top: 0.5em;
168
+ margin-bottom: 1em;
169
+ border: 1px dotted #ccc;
170
+ }
171
+ .method-heading {
172
+ color: black;
173
+ background: #ccc;
174
+ border-bottom: 1px solid #666;
175
+ padding: 0.2em 0.5em 0 0.5em;
176
+ }
177
+ .method-signature { color: black; background: inherit; }
178
+ .method-name { font-weight: bold; }
179
+ .method-args { font-style: italic; }
180
+ .method-description { padding: 0 0.5em 0 0.5em; }
181
+
182
+ /* --- Source code sections -------------------- */
183
+
184
+ a.source-toggle { font-size: 90%; }
185
+ div.method-source-code {
186
+ background: #262626;
187
+ color: #ffdead;
188
+ margin: 1em;
189
+ padding: 0.5em;
190
+ border: 1px dashed #999;
191
+ overflow: hidden;
192
+ }
193
+
194
+ div.method-source-code pre { color: #ffdead; overflow: hidden; }
195
+
196
+ /* --- Ruby keyword styles --------------------- */
197
+
198
+ .standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
199
+
200
+ .ruby-constant { color: #7fffd4; background: transparent; }
201
+ .ruby-keyword { color: #00ffff; background: transparent; }
202
+ .ruby-ivar { color: #eedd82; background: transparent; }
203
+ .ruby-operator { color: #00ffee; background: transparent; }
204
+ .ruby-identifier { color: #ffdead; background: transparent; }
205
+ .ruby-node { color: #ffa07a; background: transparent; }
206
+ .ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
207
+ .ruby-regexp { color: #ffa07a; background: transparent; }
208
+ .ruby-value { color: #7fffd4; background: transparent; }
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{duns-lookup}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kali Donovan"]
12
- s.date = %q{2009-08-12}
12
+ s.date = %q{2009-08-21}
13
13
  s.description = %q{Provides a small wrapper around the Dun & Bradstreet website to retrieve business information from DUNS numbers.}
14
14
  s.email = %q{kali.donovan@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -23,6 +23,21 @@ Gem::Specification.new do |s|
23
23
  "README.rdoc",
24
24
  "Rakefile",
25
25
  "VERSION",
26
+ "doc/classes/Duns.html",
27
+ "doc/classes/Duns.src/M000001.html",
28
+ "doc/classes/Duns.src/M000002.html",
29
+ "doc/classes/Duns.src/M000003.html",
30
+ "doc/classes/Duns.src/M000004.html",
31
+ "doc/classes/Duns.src/M000005.html",
32
+ "doc/classes/Duns.src/M000006.html",
33
+ "doc/classes/DunsError.html",
34
+ "doc/created.rid",
35
+ "doc/files/lib/duns-lookup_rb.html",
36
+ "doc/fr_class_index.html",
37
+ "doc/fr_file_index.html",
38
+ "doc/fr_method_index.html",
39
+ "doc/index.html",
40
+ "doc/rdoc-style.css",
26
41
  "duns-lookup.gemspec",
27
42
  "lib/duns-lookup.rb",
28
43
  "spec/duns-lookup_spec.rb",
@@ -45,13 +60,16 @@ Gem::Specification.new do |s|
45
60
 
46
61
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
47
62
  s.add_development_dependency(%q<rspec>, [">= 0"])
63
+ s.add_development_dependency(%q<nokogiri>, [">= 0"])
48
64
  s.add_development_dependency(%q<mechanize>, [">= 0"])
49
65
  else
50
66
  s.add_dependency(%q<rspec>, [">= 0"])
67
+ s.add_dependency(%q<nokogiri>, [">= 0"])
51
68
  s.add_dependency(%q<mechanize>, [">= 0"])
52
69
  end
53
70
  else
54
71
  s.add_dependency(%q<rspec>, [">= 0"])
72
+ s.add_dependency(%q<nokogiri>, [">= 0"])
55
73
  s.add_dependency(%q<mechanize>, [">= 0"])
56
74
  end
57
75
  end
@@ -16,16 +16,20 @@ 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( fake_duns_number ).should be_nil
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( real_duns_number )
23
+ unless real_duns[:number] && real_duns[:name] && real_duns[:address]
24
+ raise "Must provide information from an existing company to validates results are correct. Edit #real_duns in spec_helper.rb"
25
+ end
26
+
27
+ results = Duns.lookup_duns( real_duns[:number] )
24
28
  results.should_not be_nil
25
29
  results.should be_a_kind_of Hash
26
30
 
27
- results[:name].should == "NORTH TEXAS CIRCUIT BOARD CO., INC."
28
- results[:address].should == "1501 W SHADY GROVE RD, GRAND PRAIRIE, TX"
31
+ results[:name].should == real_duns[:name]
32
+ results[:address].should == real_duns[:address]
29
33
  end
30
34
  end
31
35
  end
@@ -8,12 +8,18 @@ Spec::Runner.configure do |config|
8
8
 
9
9
  end
10
10
 
11
- # The DUNS number of an existing corporation
12
- def real_duns_number
13
- '095444246'
11
+ # TODO -- to run the specs, input valid information from a real company here
12
+ # Try looking up your business by hand first to see exactly the format used by the D&B website
13
+ # (for instance punctuation matters, as in the abbreviations of CO and INC below)
14
+ def real_duns
15
+ {
16
+ :number => nil, # Enter the company's DUNS number
17
+ :name => nil, # Enter the official company name, ALL UPPER CASE: FOO WIDGET CO., INC.
18
+ :address => nil # Enter the officially registered address, ALL UPPER CASE: 123 W MAIN ST, SAN FRANCISCO, CA
19
+ }
14
20
  end
15
21
 
16
22
  # A valid, but non-existant DUNS number
17
- def fake_duns_number
18
- '123456789'
19
- end
23
+ def fake_duns
24
+ {:number => '123456789'}
25
+ end
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kali Donovan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-12 00:00:00 -07:00
12
+ date: 2009-08-21 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: nokogiri
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
25
35
  - !ruby/object:Gem::Dependency
26
36
  name: mechanize
27
37
  type: :development
@@ -48,6 +58,21 @@ files:
48
58
  - README.rdoc
49
59
  - Rakefile
50
60
  - VERSION
61
+ - doc/classes/Duns.html
62
+ - doc/classes/Duns.src/M000001.html
63
+ - doc/classes/Duns.src/M000002.html
64
+ - doc/classes/Duns.src/M000003.html
65
+ - doc/classes/Duns.src/M000004.html
66
+ - doc/classes/Duns.src/M000005.html
67
+ - doc/classes/Duns.src/M000006.html
68
+ - doc/classes/DunsError.html
69
+ - doc/created.rid
70
+ - doc/files/lib/duns-lookup_rb.html
71
+ - doc/fr_class_index.html
72
+ - doc/fr_file_index.html
73
+ - doc/fr_method_index.html
74
+ - doc/index.html
75
+ - doc/rdoc-style.css
51
76
  - duns-lookup.gemspec
52
77
  - lib/duns-lookup.rb
53
78
  - spec/duns-lookup_spec.rb