govkit-ca 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/.yardopts +4 -0
  2. data/README.md +2 -1
  3. data/govkit-ca.gemspec +3 -3
  4. data/lib/gov_kit-ca/postal_code/strategy/liberal_ca.rb +1 -2
  5. data/lib/gov_kit-ca/postal_code/strategy/parl_gc_ca.rb +2 -2
  6. data/lib/gov_kit-ca/postal_code.rb +2 -4
  7. data/lib/gov_kit-ca/version.rb +1 -1
  8. data/lib/gov_kit-ca.rb +2 -2
  9. data/spec/cbc_ca_spec.rb +1 -0
  10. data/spec/{conservative_ca_spec.ca → conservative_ca_spec.rb} +1 -1
  11. data/spec/elections_ca_spec.rb +2 -2
  12. data/spec/fixtures/cbc_ca/A1A1A1.response +11 -0
  13. data/spec/fixtures/cbc_ca/G0C2Y0.response +11 -0
  14. data/spec/fixtures/cbc_ca/H0H0H0.response +11 -0
  15. data/spec/fixtures/cbc_ca/K0A1K0.response +11 -0
  16. data/spec/fixtures/cbc_ca/T5S2B9.response +11 -0
  17. data/spec/fixtures/cbc_ca/X1B1B1.response +11 -0
  18. data/spec/fixtures/conservative_ca/A1A1A1.response +452 -0
  19. data/spec/fixtures/conservative_ca/G0C2Y0.response +452 -0
  20. data/spec/fixtures/conservative_ca/H0H0H0.response +452 -0
  21. data/spec/fixtures/conservative_ca/K0A1K0.response +455 -0
  22. data/spec/fixtures/conservative_ca/T5S2B9.response +453 -0
  23. data/spec/fixtures/conservative_ca/X1B1B1.response +452 -0
  24. data/spec/fixtures/digital-copyright_ca/A1A1A1.response +227 -0
  25. data/spec/fixtures/digital-copyright_ca/G0C2Y0.response +229 -0
  26. data/spec/fixtures/digital-copyright_ca/H0H0H0.response +243 -0
  27. data/spec/fixtures/digital-copyright_ca/K0A1K0.response +230 -0
  28. data/spec/fixtures/digital-copyright_ca/T5S2B9.response +233 -0
  29. data/spec/fixtures/digital-copyright_ca/X1B1B1.response +243 -0
  30. data/spec/fixtures/elections_ca/A1A1A1.response +10 -0
  31. data/spec/fixtures/elections_ca/G0C2Y0.response +11 -0
  32. data/spec/fixtures/elections_ca/H0H0H0.response +10 -0
  33. data/spec/fixtures/elections_ca/K0A1K0.response +10 -0
  34. data/spec/fixtures/elections_ca/T5S2B9.response +10 -0
  35. data/spec/fixtures/elections_ca/X1B1B1.response +10 -0
  36. data/spec/fixtures/greenparty_ca/A1A1A1.response +13 -0
  37. data/spec/fixtures/greenparty_ca/G0C2Y0.response +13 -0
  38. data/spec/fixtures/greenparty_ca/H0H0H0.response +13 -0
  39. data/spec/fixtures/greenparty_ca/K0A1K0.response +13 -0
  40. data/spec/fixtures/greenparty_ca/T5S2B9.response +13 -0
  41. data/spec/fixtures/greenparty_ca/X1B1B1.response +13 -0
  42. data/spec/fixtures/liberal_ca/A1A1A1.response +702 -0
  43. data/spec/fixtures/liberal_ca/G0C2Y0.response +570 -0
  44. data/spec/fixtures/liberal_ca/H0H0H0.response +649 -0
  45. data/spec/fixtures/liberal_ca/K0A1K0.response +650 -0
  46. data/spec/fixtures/liberal_ca/T5S2B9.response +570 -0
  47. data/spec/fixtures/liberal_ca/X1B1B1.response +649 -0
  48. data/spec/fixtures/ndp_ca/A1A1A1.response +610 -0
  49. data/spec/fixtures/ndp_ca/G0C2Y0.response +610 -0
  50. data/spec/fixtures/ndp_ca/H0H0H0.response +593 -0
  51. data/spec/fixtures/ndp_ca/K0A1K0.response +641 -0
  52. data/spec/fixtures/ndp_ca/T5S2B9.response +605 -0
  53. data/spec/fixtures/ndp_ca/X1B1B1.response +593 -0
  54. data/spec/liberal_ca_spec.rb +1 -4
  55. data/spec/ndp_ca_spec.rb +1 -1
  56. data/spec/spec_helper.rb +4 -0
  57. data/spec/strategy_set_spec.rb +5 -0
  58. data/tasks/tasks.rb +4 -5
  59. metadata +114 -8
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --no-private
2
+ --hide-void-return
3
+ --embed-mixin ClassMethods
4
+ --markup=markdown
data/README.md CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/opennorth/govkit-ca.png)](http://travis-ci.org/opennorth/govkit-ca)
4
4
  [![Dependency Status](https://gemnasium.com/opennorth/govkit-ca.png)](https://gemnasium.com/opennorth/govkit-ca)
5
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/opennorth/govkit-ca)
5
+ [![Coverage Status](https://coveralls.io/repos/opennorth/govkit-ca/badge.png?branch=master)](https://coveralls.io/r/opennorth/govkit-ca)
6
+ [![Code Climate](https://codeclimate.com/github/opennorth/govkit-ca.png)](https://codeclimate.com/github/opennorth/govkit-ca)
6
7
 
7
8
  GovKit-CA is a Ruby gem that provides easy access to Canadian civic data around the web. It currently provides an API for free postal code to electoral district lookups, using the following sources:
8
9
 
data/govkit-ca.gemspec CHANGED
@@ -1,6 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "gov_kit-ca/version"
2
+ require File.expand_path('../lib/gov_kit-ca/version', __FILE__)
4
3
 
5
4
  Gem::Specification.new do |s|
6
5
  s.name = "govkit-ca"
@@ -19,10 +18,11 @@ Gem::Specification.new do |s|
19
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
19
  s.require_paths = ["lib"]
21
20
 
22
- s.add_runtime_dependency('httparty', '~> 0.7.8')
21
+ s.add_runtime_dependency('httparty', '~> 0.10.0')
23
22
  s.add_runtime_dependency('nokogiri', '~> 1.5.0')
24
23
  s.add_runtime_dependency('yajl-ruby', '~> 0.8.2')
25
24
  s.add_development_dependency('rspec', '~> 2.6.0')
26
25
  s.add_development_dependency('fakeweb', '~> 1.3.0')
27
26
  s.add_development_dependency('rake')
27
+ s.add_development_dependency('coveralls')
28
28
  end
@@ -2,8 +2,7 @@ module GovKit
2
2
  module CA
3
3
  module PostalCode
4
4
  module Strategy
5
- # liberal.ca seems unreliable. It returns no ridings for B0J2L0 and
6
- # three ridings for K0A1K0.
5
+ # liberal.ca seems unreliable. It returns three ridings for K0A1K0.
7
6
  class LiberalCa < Base
8
7
  follow_redirects true
9
8
  base_uri 'www.liberal.ca'
@@ -10,11 +10,11 @@ module GovKit
10
10
  private
11
11
 
12
12
  def electoral_districts!
13
- # TODO returns HTML with electoral district names only
13
+ # @todo returns HTML with electoral district names only
14
14
  end
15
15
 
16
16
  def valid?
17
- # TODO
17
+ # @todo
18
18
  end
19
19
  end
20
20
 
@@ -3,8 +3,6 @@ module GovKit
3
3
  # A collection of postal code helpers.
4
4
  # @see http://en.wikipedia.org/wiki/Postal_codes_in_Canada Postal codes in Canada
5
5
  module PostalCode
6
- autoload :StrategySet, 'gov_kit-ca/postal_code/strategy_set'
7
-
8
6
  # @param [String] postal_code a postal code
9
7
  # @return [Boolean] whether the postal code is properly formatted
10
8
  # @see http://en.wikipedia.org/wiki/Postal_codes_in_Canada#Number_of_possible_postal_codes Possible postal codes
@@ -79,9 +77,9 @@ module GovKit
79
77
  end
80
78
  end
81
79
 
80
+ require 'gov_kit-ca/postal_code/strategy_set'
82
81
  require 'gov_kit-ca/postal_code/strategy/base'
83
- # Returns only riding name.
84
- #require 'gov_kit-ca/postal_code/strategy/parl_gc_ca'
82
+ #require 'gov_kit-ca/postal_code/strategy/parl_gc_ca' # only riding name
85
83
  require 'gov_kit-ca/postal_code/strategy/elections_ca' # only one-to-one
86
84
  require 'gov_kit-ca/postal_code/strategy/ndp_ca'
87
85
  require 'gov_kit-ca/postal_code/strategy/liberal_ca' # incomplete database
@@ -1,5 +1,5 @@
1
1
  module GovKit
2
2
  module CA
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
data/lib/gov_kit-ca.rb CHANGED
@@ -8,10 +8,10 @@ require 'yajl'
8
8
 
9
9
  module GovKit
10
10
  module CA
11
- autoload :PostalCode, 'gov_kit-ca/postal_code'
12
-
13
11
  class GovKitError < StandardError; end
14
12
  class ResourceNotFound < GovKitError; end
15
13
  class InvalidRequest < GovKitError; end
16
14
  end
17
15
  end
16
+
17
+ require 'gov_kit-ca/postal_code'
data/spec/cbc_ca_spec.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require 'gov_kit-ca/postal_code/strategy/cbc_ca'
2
3
 
3
4
  class GovKit::CA::PostalCode::Strategy::CBCCa
4
5
  describe GovKit::CA::PostalCode::Strategy::CBCCa do
@@ -15,7 +15,7 @@ describe GovKit::CA::PostalCode::Strategy::ConservativeCa do
15
15
  it 'should return the electoral districts within a postal code' do
16
16
  { 'T5S2B9' => [48015],
17
17
  'K0A1K0' => [35025, 35052, 35063],
18
- 'B0J2L0' => [12002, 12006, 12009, 12011],
18
+ # returns nothing for B0J2L0
19
19
  }.each do |postal_code,electoral_districts|
20
20
  GovKit::CA::PostalCode::Strategy::ConservativeCa.new(postal_code).electoral_districts.should == electoral_districts
21
21
  end
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
2
+ require 'gov_kit-ca/postal_code/strategy/elections_ca'
3
3
 
4
4
  describe GovKit::CA::PostalCode::Strategy::ElectionsCa do
5
5
  describe '#electoral_districts' do
@@ -14,7 +14,7 @@ describe GovKit::CA::PostalCode::Strategy::ElectionsCa do
14
14
 
15
15
  it 'should return the electoral districts within a postal code' do
16
16
  { 'G0C2Y0' => [24019],
17
- 'T5S2B9' => [48015],
17
+ # returns nothing for T5S2B9
18
18
  }.each do |postal_code,electoral_districts|
19
19
  GovKit::CA::PostalCode::Strategy::ElectionsCa.new(postal_code).electoral_districts.should == electoral_districts
20
20
  end
@@ -0,0 +1,11 @@
1
+ HTTP/1.1 200 OK
2
+ Server: Apache/2.2.3 (Red Hat)
3
+ X-Origin-Server: web17:sb17
4
+ Content-Type: text/html
5
+ Cache-Control: max-age=28
6
+ Expires: Tue, 05 Mar 2013 03:46:36 GMT
7
+ Date: Tue, 05 Mar 2013 03:46:08 GMT
8
+ Content-Length: 55
9
+ Connection: close
10
+
11
+ [{"rid":"007","name":"St. John's South - Mount Pearl"}]
@@ -0,0 +1,11 @@
1
+ HTTP/1.1 200 OK
2
+ Server: Apache/2.2.3 (Red Hat)
3
+ X-Origin-Server: web17:sb17
4
+ Content-Type: text/html
5
+ Cache-Control: max-age=29
6
+ Expires: Tue, 05 Mar 2013 03:46:37 GMT
7
+ Date: Tue, 05 Mar 2013 03:46:08 GMT
8
+ Content-Length: 66
9
+ Connection: close
10
+
11
+ [{"rid":"052","name":"Gasp\u00e9sie - \u00celes-de-la-Madeleine"}]
@@ -0,0 +1,11 @@
1
+ HTTP/1.1 404 Not Found
2
+ Server: Apache/2.2.3 (Red Hat)
3
+ X-Origin-Server: web20:sb17
4
+ Content-Length: 0
5
+ Content-Type: text/html
6
+ Vary: Accept-Encoding
7
+ Cache-Control: max-age=28
8
+ Expires: Tue, 05 Mar 2013 03:46:37 GMT
9
+ Date: Tue, 05 Mar 2013 03:46:09 GMT
10
+ Connection: close
11
+
@@ -0,0 +1,11 @@
1
+ HTTP/1.1 200 OK
2
+ Server: Apache/2.2.3 (Red Hat)
3
+ X-Origin-Server: web19:sb17
4
+ Content-Type: text/html
5
+ Cache-Control: max-age=30
6
+ Expires: Tue, 05 Mar 2013 03:46:39 GMT
7
+ Date: Tue, 05 Mar 2013 03:46:09 GMT
8
+ Content-Length: 177
9
+ Connection: close
10
+
11
+ [{"rid":"133","name":"Glengarry - Prescott - Russell"},{"rid":"159","name":"Nepean - Carleton"},{"rid":"170","name":"Ottawa - Orl\u00e9ans"},{"rid":"171","name":"Ottawa South"}]
@@ -0,0 +1,11 @@
1
+ HTTP/1.1 200 OK
2
+ Server: Apache/2.2.3 (Red Hat)
3
+ X-Origin-Server: web20:sb17
4
+ Content-Type: text/html
5
+ Cache-Control: max-age=30
6
+ Expires: Tue, 05 Mar 2013 03:46:38 GMT
7
+ Date: Tue, 05 Mar 2013 03:46:08 GMT
8
+ Content-Length: 93
9
+ Connection: close
10
+
11
+ [{"rid":"257","name":"Edmonton - Spruce Grove"},{"rid":"255","name":"Edmonton - St. Albert"}]
@@ -0,0 +1,11 @@
1
+ HTTP/1.1 404 Not Found
2
+ Server: Apache/2.2.3 (Red Hat)
3
+ X-Origin-Server: web21:sb17
4
+ Content-Length: 0
5
+ Content-Type: text/html
6
+ Vary: Accept-Encoding
7
+ Cache-Control: max-age=30
8
+ Expires: Tue, 05 Mar 2013 03:46:40 GMT
9
+ Date: Tue, 05 Mar 2013 03:46:10 GMT
10
+ Connection: close
11
+