ncua 0.4.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e329a8d091a46b2798649cc3ddd24d42163fed3b
4
+ data.tar.gz: 8842978e48032d39ef122a5cee6f99edcd70ff2e
5
+ SHA512:
6
+ metadata.gz: a035575691a5c83843d75548f8053d23761ae5b9c28f6cb0fddb34148191dcf401cf09f70d55c26777cb8c523414585fad5fc4152a6df6e2069ba00cbd9e5760
7
+ data.tar.gz: 6d5791fb1ffef2964f20dbfd4d15a1be7726b2f9dc3a55c6cb26fdc1dbf395bf2379761586777ca61c3ac355b40f05abc5e70643fcb80978f4322fc018c6e387
@@ -0,0 +1,10 @@
1
+ ncua-*.gem
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ncua.gemspec
4
+ gemspec
@@ -0,0 +1,76 @@
1
+ # Ncua
2
+
3
+ The NCUA [lets you search for a credit union office](http://www.ncua.gov/NCUAMapping/Pages/NCUAGOVMapping.aspx) by name, address and charter number. Their site uses a JSON api behind their
4
+
5
+ This gem is a ruby client to that API. It's totally unaffiliated with the NCUA.
6
+ It's open source, so anyone can use it, and anyone can help maintain it. At
7
+ this point, it's maintained by [the
8
+ developers](http://engineering.continuity.net/) at
9
+ [Continuity](http://continuity.net).
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'ncua'
17
+ ```
18
+
19
+ And then execute:
20
+ ```
21
+ $ bundle
22
+ ```
23
+ Or install it yourself as:
24
+ ```
25
+ $ gem install ncua
26
+ ```
27
+ ## Usage
28
+
29
+ Currently all of our features are namespaced under the `NCUA` module.
30
+
31
+ The NCUA lets you find a Credit Union office by its name, charter number, or within an address:
32
+
33
+ ```ruby
34
+ credit_unions = NCUA.find_by_name('Federal') #=> [NCUA::CreditUnion, ... ]
35
+ ```
36
+
37
+ You can `find_by` `name`, `address`, `charter_number`. Searching by address takes an optional radius argument to limit the scope of the address query (units are in miles):
38
+ ```ruby
39
+ credit_unions = NCUA.find_by_charter_number(12345) #=> [NCUA::CreditUnion, ... ]
40
+
41
+ credit_unions = NCUA.find_by_address("125 Main St., Anywhere, CT", radius: 50) #=> [NCUA::CreditUnion, ... ]
42
+
43
+ ```
44
+
45
+ Right now, an `NCUA::CreditUnion` has all of the following getters:
46
+
47
+ | ----------------------------- | ------------------------------------------------------------- |
48
+ | Method | Explanation |
49
+ | ----------------------------- | ------------------------------------------------------------- |
50
+ | `name` | The Credit Union's Name |
51
+ | `long` | The Longitude of the Credit Union |
52
+ | `lat` | The Latitude of the Credit Union |
53
+ | `site_name` | The name of the Credit Union office or branch |
54
+ | `charter_number` | The Credit Union's Charter Number |
55
+ | `city` | The Credit Union's City |
56
+ | `country` | The Credit Union's Country |
57
+ | `main_office?` | Whether the Credit Union office is the Main Office |
58
+ | `phone` | The Credit Union's phone number |
59
+ | `site_functions` | The Credit Union's Site functions.\* |
60
+ | `site_id` | The Credit Union's Site ID |
61
+ | `state` | The Credit Union's State |
62
+ | `url` | The Credit Union's Url |
63
+ | `zip` | The Credit Union's Zip Code |
64
+ | `distance_from_query_address` | The Distance between the queried address and the Credit Union |
65
+ | `street` | The Credit Union's Street address |
66
+ | ----------------------------- | ------------------------------------------------------------- |
67
+
68
+ \*Currently these are limited to `Member Services`, `Drive Through` and `ATM`
69
+
70
+ ## Contributing
71
+
72
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ContinuityControl/ncua.
73
+
74
+ ## License
75
+
76
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ncua"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,22 @@
1
+ require 'httparty'
2
+ require 'ncua/version'
3
+ require 'ncua/client'
4
+ require 'ncua/record'
5
+ require 'ncua/credit_union'
6
+
7
+ module NCUA
8
+ def self.find_by_address(address, opts={radius: 100})
9
+ resp = Client.new.find_credit_union_by_address(address, opts[:radius])
10
+ resp["list"].map { |result| CreditUnion.new(result) }
11
+ end
12
+
13
+ def self.find_by_name(name)
14
+ resp = Client.new.find_credit_union_by_name(name)
15
+ resp["list"].map { |result| CreditUnion.new(result) }
16
+ end
17
+
18
+ def self.find_by_charter_number(charter_number)
19
+ resp = Client.new.find_credit_union_by_charter_number(charter_number)
20
+ resp["list"].map { |result| CreditUnion.new(result) }
21
+ end
22
+ end
@@ -0,0 +1,35 @@
1
+ module NCUA
2
+ class Client
3
+ include HTTParty
4
+
5
+ base_uri 'http://mapping.ncua.gov'
6
+ format :json
7
+ #debug_output $stderr
8
+
9
+ def find_credit_union_by_address(address, radius)
10
+ self.class.get(query_endpoint, query: {
11
+ address: address,
12
+ type: 'address',
13
+ radius: radius.to_s })
14
+ end
15
+
16
+ def find_credit_union_by_name(name)
17
+ self.class.get(query_endpoint, query: {
18
+ address: name,
19
+ type: 'cuname' })
20
+ end
21
+
22
+ def find_credit_union_by_charter_number(charter_number)
23
+ self.class.get(query_endpoint, query: {
24
+ address: charter_number,
25
+ type: 'cunumber' })
26
+ end
27
+
28
+ private
29
+
30
+ def query_endpoint
31
+ '/findCUByRadius.aspx'
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,20 @@
1
+ module NCUA
2
+ class CreditUnion < Record
3
+ field :name, 'CU_NAME'
4
+ field :long, 'AddressLongitude'
5
+ field :lat, 'AddressLatitude'
6
+ field :site_name, 'CU_SITENAME'
7
+ field :charter_number, 'CU_NUMBER'
8
+ field :city, 'City'
9
+ field :country, 'Country'
10
+ field :main_office?, 'IsMainOffice'
11
+ field :phone, 'Phone'
12
+ field(:site_functions, 'SiteFunctions') { |value| value.split(";") }
13
+ field :site_id, 'SiteId'
14
+ field :state, 'State'
15
+ field :url, 'URL'
16
+ field :zip, 'Zipcode'
17
+ field(:distance_from_query_address, 'distance') { |value| nil if value < 0 }
18
+ field(:street, 'Street', &:strip)
19
+ end
20
+ end
@@ -0,0 +1,34 @@
1
+ module NCUA
2
+ class Record
3
+ def initialize(attributes)
4
+ @attributes = attributes
5
+ @attributes.freeze
6
+ end
7
+
8
+ attr_reader :attributes
9
+
10
+ def self.field(method_name, response_key=method_name, &munger)
11
+ munger ||= lambda { |x| x }
12
+ define_method(method_name) {
13
+ value = attributes[response_key.to_s]
14
+ value && munger.call(value)
15
+ }
16
+ end
17
+
18
+ def self.int_field(method_name, response_key=method_name)
19
+ field(method_name, response_key, &:to_i)
20
+ end
21
+
22
+ def self.currency_field(method_name, response_key=method_name)
23
+ field(method_name, response_key) { |value|
24
+ value.to_f * 1000
25
+ }
26
+ end
27
+
28
+ def self.date_field(method_name, response_key=method_name)
29
+ field(method_name, response_key) { |value|
30
+ Date.parse(value)
31
+ }
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module NCUA
2
+ VERSION = "0.4.0"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ncua/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ncua"
8
+ spec.version = NCUA::VERSION
9
+ spec.authors = ["Tom Reznick"]
10
+ spec.email = ["treznick@continuty.net"]
11
+
12
+ spec.summary = %q{A Ruby client for the NCUA's "Find a Credit Union tool"}
13
+ spec.description = %q{The NCUA recently started using asynchronous json requests in their Find a Credit Union tool. We make that query-able from Ruby.}
14
+ spec.homepage = "https://github.com/ContinuityControl/ncua"
15
+ spec.license = "MIT"
16
+
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_runtime_dependency "httparty", "~> 0.13"
24
+ spec.add_development_dependency "bundler", "~> 1.10"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ncua
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom Reznick
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.13'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: The NCUA recently started using asynchronous json requests in their Find
70
+ a Credit Union tool. We make that query-able from Ruby.
71
+ email:
72
+ - treznick@continuty.net
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - lib/ncua.rb
86
+ - lib/ncua/client.rb
87
+ - lib/ncua/credit_union.rb
88
+ - lib/ncua/record.rb
89
+ - lib/ncua/version.rb
90
+ - ncua.gemspec
91
+ homepage: https://github.com/ContinuityControl/ncua
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.4.8
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: A Ruby client for the NCUA's "Find a Credit Union tool"
115
+ test_files: []