ncua 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ncua.rb +2 -0
- data/lib/ncua/credit_union.rb +8 -0
- data/lib/ncua/scraper.rb +47 -0
- data/lib/ncua/version.rb +1 -1
- data/ncua.gemspec +1 -0
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d80b3ab492107fa4574336a527522217465ac829
|
4
|
+
data.tar.gz: 89b3e21b98a1feaa85d3555d4fe7a3a7b01535dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f1ece268d4b81aebc6b6ac37654aa67dd1b5c2b0772caa7258b9aaa9bd87a2174f3fee57e2c838e61fcec4b8348762c6826e8ca29634216f0aebad534872457
|
7
|
+
data.tar.gz: adead7d121f4afa6b779b1e8fab4890d90e0423ec508b7156e30fc39e7e984e2d677f3d09ea8858dfd0b4cd711269231900e91231bfb7f1bef58018f7e601e60
|
data/lib/ncua.rb
CHANGED
data/lib/ncua/credit_union.rb
CHANGED
@@ -16,5 +16,13 @@ module NCUA
|
|
16
16
|
field :zip, 'Zipcode'
|
17
17
|
field(:distance_from_query_address, 'distance') { |value| nil if value < 0 }
|
18
18
|
field(:street, 'Street', &:strip)
|
19
|
+
|
20
|
+
def munge!
|
21
|
+
@scraped_attributes ||= Scraper.new(charter_number).scrape!
|
22
|
+
end
|
23
|
+
|
24
|
+
def additional_attributes
|
25
|
+
@scraped_attributes
|
26
|
+
end
|
19
27
|
end
|
20
28
|
end
|
data/lib/ncua/scraper.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
module NCUA
|
2
|
+
class Scraper
|
3
|
+
#This bit is as brittle as glass, as coupled as conjoined twins, and as stinky as bad cheese
|
4
|
+
include HTTParty
|
5
|
+
|
6
|
+
base_uri 'http://mapping.ncua.gov'
|
7
|
+
def initialize(charter_number)
|
8
|
+
@charter_number = charter_number
|
9
|
+
end
|
10
|
+
|
11
|
+
def scrape!
|
12
|
+
Hash[html_doc.at_css("table#MainContent_newDetails").css("tr").map do |tr|
|
13
|
+
if tr.at_css("td.dvHeader") && tr.at_css("td.dvHeader + td")
|
14
|
+
[clean_header(tr.at_css("td.dvHeader").text), clean_value(tr.at_css("td.dvHeader + td").text)]
|
15
|
+
end
|
16
|
+
end]
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def clean_header(text)
|
22
|
+
text.gsub(/[,:]/,"").
|
23
|
+
gsub("/", " or ").
|
24
|
+
gsub(" ","_").
|
25
|
+
downcase.
|
26
|
+
to_sym
|
27
|
+
end
|
28
|
+
|
29
|
+
def clean_value(text)
|
30
|
+
text.gsub(/[\n\r]/,"").strip
|
31
|
+
end
|
32
|
+
|
33
|
+
def html_doc
|
34
|
+
Nokogiri::HTML(request.body)
|
35
|
+
end
|
36
|
+
|
37
|
+
def request
|
38
|
+
self.class.get(endpoint, query: {
|
39
|
+
"ID" => @charter_number
|
40
|
+
})
|
41
|
+
end
|
42
|
+
|
43
|
+
def endpoint
|
44
|
+
'/SingleResult.aspx'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/ncua/version.rb
CHANGED
data/ncua.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
23
|
spec.add_runtime_dependency "httparty", "~> 0.13"
|
24
|
+
spec.add_runtime_dependency "nokogiri", "~> 1.6.0"
|
24
25
|
spec.add_development_dependency "bundler", "~> 1.10"
|
25
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
27
|
spec.add_development_dependency "rspec", "~> 3.0"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ncua
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Reznick
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.6.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.6.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +100,7 @@ files:
|
|
86
100
|
- lib/ncua/client.rb
|
87
101
|
- lib/ncua/credit_union.rb
|
88
102
|
- lib/ncua/record.rb
|
103
|
+
- lib/ncua/scraper.rb
|
89
104
|
- lib/ncua/version.rb
|
90
105
|
- ncua.gemspec
|
91
106
|
homepage: https://github.com/ContinuityControl/ncua
|