ncua 0.7.2 → 0.8.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.
- checksums.yaml +4 -4
 - data/README.md +4 -0
 - data/lib/ncua.rb +1 -0
 - data/lib/ncua/credit_union/details_client.rb +36 -0
 - data/lib/ncua/credit_union/scraper.rb +1 -10
 - data/lib/ncua/version.rb +1 -1
 - metadata +3 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 7239d68f260fe6848f3bb85f19e6f51815531635
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: b690ef06d9dd96db0af6e6e1e47fd1035f0b506f
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: df38dffc69a867b8240e751452cfcbe75d55ca20dae4f5fb809dda1c28cc06d15eefe6f26bedd54d871f06ddf3dce6d33439cafd925669cb2bf7e7aa1fdfac9e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: b721282110eb5cd8a98a292c0900d850af75da2ad2a7b4f76445edc8bee671b9e67ff4bd60e42e934843bafe90cd1c91369baa596e71180bee9bc9d71e710989
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -108,6 +108,10 @@ Right now, an `NCUA::CreditUnion::Details` object has the following getters: 
     | 
|
| 
       108 
108 
     | 
    
         | 
| 
       109 
109 
     | 
    
         
             
            You can also scrape this directly from the NCUA module by calling `NCUA.find_credit_union(charter_number)`
         
     | 
| 
       110 
110 
     | 
    
         | 
| 
      
 111 
     | 
    
         
            +
            If you pass `nil` into this method, it will raise an `ArgumentError`. The NCUA will actually return a 200 without a charter number, but the data on the page is blank.
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
            If for some reason the NCUA returns a 500 error when directly scraping for credit union details, the gem will raise `NCUA::CreditUnion::ServerError`. This can happen if your charter number is invalid.
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
       111 
115 
     | 
    
         
             
            ## Contributing
         
     | 
| 
       112 
116 
     | 
    
         | 
| 
       113 
117 
     | 
    
         
             
            Bug reports and pull requests are welcome on GitHub at https://github.com/ContinuityControl/ncua.
         
     | 
    
        data/lib/ncua.rb
    CHANGED
    
    | 
         @@ -6,6 +6,7 @@ require 'ncua/credit_union/record' 
     | 
|
| 
       6 
6 
     | 
    
         
             
            require 'ncua/credit_union/office'
         
     | 
| 
       7 
7 
     | 
    
         
             
            require 'ncua/credit_union/details'
         
     | 
| 
       8 
8 
     | 
    
         
             
            require 'ncua/credit_union/scraper'
         
     | 
| 
      
 9 
     | 
    
         
            +
            require 'ncua/credit_union/details_client'
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
            module NCUA
         
     | 
| 
       11 
12 
     | 
    
         
             
              def self.find_office_by_address(address, opts={radius: 100})
         
     | 
| 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module NCUA
         
     | 
| 
      
 2 
     | 
    
         
            +
              module CreditUnion
         
     | 
| 
      
 3 
     | 
    
         
            +
                class ServerError < ::StandardError; end
         
     | 
| 
      
 4 
     | 
    
         
            +
                class DetailsClient
         
     | 
| 
      
 5 
     | 
    
         
            +
                  include HTTParty
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                  base_uri 'http://mapping.ncua.gov'
         
     | 
| 
      
 8 
     | 
    
         
            +
                  def get_details(charter_number)
         
     | 
| 
      
 9 
     | 
    
         
            +
                    if charter_number.nil?
         
     | 
| 
      
 10 
     | 
    
         
            +
                      raise ArgumentError, "charter number cannot be nil"
         
     | 
| 
      
 11 
     | 
    
         
            +
                    end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                    response = execute_query(charter_number)
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                    case response.code
         
     | 
| 
      
 16 
     | 
    
         
            +
                    when 200...300
         
     | 
| 
      
 17 
     | 
    
         
            +
                      response
         
     | 
| 
      
 18 
     | 
    
         
            +
                    when 500...600
         
     | 
| 
      
 19 
     | 
    
         
            +
                      raise ServerError
         
     | 
| 
      
 20 
     | 
    
         
            +
                    end
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                  private
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  def endpoint
         
     | 
| 
      
 26 
     | 
    
         
            +
                    '/SingleResult.aspx'
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                  def execute_query(charter_number)
         
     | 
| 
      
 30 
     | 
    
         
            +
                    self.class.get(endpoint, query: {
         
     | 
| 
      
 31 
     | 
    
         
            +
                      "ID" => charter_number
         
     | 
| 
      
 32 
     | 
    
         
            +
                    })
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -2,9 +2,6 @@ module NCUA 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module CreditUnion
         
     | 
| 
       3 
3 
     | 
    
         
             
                class Scraper
         
     | 
| 
       4 
4 
     | 
    
         
             
                  #This bit is as brittle as glass, as coupled as conjoined twins, and as stinky as bad cheese
         
     | 
| 
       5 
     | 
    
         
            -
                  include HTTParty
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                  base_uri 'http://mapping.ncua.gov'
         
     | 
| 
       8 
5 
     | 
    
         
             
                  def initialize(charter_number)
         
     | 
| 
       9 
6 
     | 
    
         
             
                    @charter_number = charter_number
         
     | 
| 
       10 
7 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -36,13 +33,7 @@ module NCUA 
     | 
|
| 
       36 
33 
     | 
    
         
             
                  end
         
     | 
| 
       37 
34 
     | 
    
         | 
| 
       38 
35 
     | 
    
         
             
                  def request
         
     | 
| 
       39 
     | 
    
         
            -
                     
     | 
| 
       40 
     | 
    
         
            -
                      "ID" => @charter_number
         
     | 
| 
       41 
     | 
    
         
            -
                    })
         
     | 
| 
       42 
     | 
    
         
            -
                  end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                  def endpoint
         
     | 
| 
       45 
     | 
    
         
            -
                    '/SingleResult.aspx'
         
     | 
| 
      
 36 
     | 
    
         
            +
                    @request ||= DetailsClient.new.get_details(@charter_number)
         
     | 
| 
       46 
37 
     | 
    
         
             
                  end
         
     | 
| 
       47 
38 
     | 
    
         
             
                end
         
     | 
| 
       48 
39 
     | 
    
         
             
              end
         
     | 
    
        data/lib/ncua/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: ncua
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.8.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Tom Reznick
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-10-19 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: httparty
         
     | 
| 
         @@ -105,6 +105,7 @@ files: 
     | 
|
| 
       105 
105 
     | 
    
         
             
            - lib/ncua.rb
         
     | 
| 
       106 
106 
     | 
    
         
             
            - lib/ncua/client.rb
         
     | 
| 
       107 
107 
     | 
    
         
             
            - lib/ncua/credit_union/details.rb
         
     | 
| 
      
 108 
     | 
    
         
            +
            - lib/ncua/credit_union/details_client.rb
         
     | 
| 
       108 
109 
     | 
    
         
             
            - lib/ncua/credit_union/office.rb
         
     | 
| 
       109 
110 
     | 
    
         
             
            - lib/ncua/credit_union/record.rb
         
     | 
| 
       110 
111 
     | 
    
         
             
            - lib/ncua/credit_union/scraper.rb
         
     |