govkit-ca 0.0.12 → 0.0.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60277f47ef35ddd41b20164989eb02e673e0b6ff
4
- data.tar.gz: 5b1c0312a70afa33193bc0a676959d18755e5c02
3
+ metadata.gz: d0b61e37c1480b7a74fa8eee100aadc3b20ad9f8
4
+ data.tar.gz: 21a6a467de791251785c1d1829634421eed5544d
5
5
  SHA512:
6
- metadata.gz: 8013b9e8b88f57696fca95e51009b4e5a787170eb7873b2db2c105213f9a8729433ddd5204063f79aa832a58c7a84d0194ae5f424280129a32a81604aef656ce
7
- data.tar.gz: cb0376eba458d2778c83a9a1040838068ffb188b878879c7c495e8e6d33c41919c76e992f26b054bdddbe25d7798063ef2404ee2a188958953c5eaf458136b73
6
+ metadata.gz: 5d77a599c818d350b7c27ac8626d5f82d26aae4add3c71294482156e3990838c81949fb36a318426016666206fc8c91122976973c4250caf992d3929c95ba045
7
+ data.tar.gz: f7d0fedc2b0caf4f51c884d83ceff9d73921cc5a2e72e7256ed16f31cb2f4e8d55f41e282c259a203eb8be8d7a09279411362066b8d678ec1c24c770f2879dc7
@@ -1,4 +1,6 @@
1
+ sudo: false
1
2
  language: ruby
3
+ cache: bundler
2
4
  rvm:
3
5
  - 1.9.3
4
6
  - 2.0.0
@@ -2,6 +2,7 @@ module GovKit
2
2
  module CA
3
3
  module PostalCode
4
4
  module Strategy
5
+ # @deprecated Due to redistribution.
5
6
  class CBCCa < Base
6
7
  base_uri 'www.cbc.ca'
7
8
  http_method :get
@@ -5,20 +5,12 @@ module GovKit
5
5
  class ConservativeCa < Base
6
6
  base_uri 'www.conservative.ca'
7
7
  http_method :get
8
- path '/wp-content/themes/conservative/functions-process.php?x=vldpc&fpc=<%= @postal_code %>'
8
+ path '/team/?postalcode=<%= @postal_code %>'
9
9
 
10
10
  private
11
11
 
12
12
  def electoral_districts!
13
- images.map{|a| a[:src][/\d+\.jpg\z/]}
14
- end
15
-
16
- def valid?
17
- !images.empty?
18
- end
19
-
20
- def images
21
- @images ||= Nokogiri::HTML(response.parsed_response, nil, 'utf-8').css('img')
13
+ # @todo returns HTML with electoral district names only
22
14
  end
23
15
  end
24
16
  end
@@ -2,6 +2,7 @@ module GovKit
2
2
  module CA
3
3
  module PostalCode
4
4
  module Strategy
5
+ # @deprecated Due to redistribution.
5
6
  class DigitalCopyrightCa < Base
6
7
  base_uri 'www.digital-copyright.ca'
7
8
  http_method :get
@@ -6,7 +6,7 @@ module GovKit
6
6
  base_uri 'www.greenparty.ca'
7
7
  http_method :post
8
8
  path '/en/party/find-your-riding'
9
- post_data 'form_id=gpc_glue_riding_lookup_form&postal_code=<%= @postal_code %>'
9
+ post_data 'form_id=riding_lookup_form&postal_code=<%= @postal_code %>'
10
10
 
11
11
  private
12
12
 
@@ -12,14 +12,6 @@ module GovKit
12
12
  def electoral_districts!
13
13
  # @todo returns HTML with electoral district names only
14
14
  end
15
-
16
- def valid?
17
- !!div
18
- end
19
-
20
- def div
21
- @div ||= Nokogiri::HTML(response.parsed_response, nil, 'utf-8').at_css('#ctl00_cphContent_pnlWithMP')
22
- end
23
15
  end
24
16
  end
25
17
  end
@@ -1,5 +1,5 @@
1
1
  module GovKit
2
2
  module CA
3
- VERSION = "0.0.12"
3
+ VERSION = "0.0.13"
4
4
  end
5
5
  end
@@ -3,11 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  RSpec.describe GovKit::CA::PostalCode::Strategy::CBCCa do
4
4
  describe '#electoral_districts', :broken => true do
5
5
  it 'should return the electoral districts within a postal code' do
6
- { 'G0C2Y0' => [24019],
7
- 'T5S2B9' => [48015, 48017], # too many 48015
8
- 'B0J2L0' => [12002, 12007, 12008],
9
- 'K0A1K0' => [35025, 35052, 35063, 35064],
10
- }.each do |postal_code,electoral_districts|
6
+ EXPECTATIONS[:cbc_ca].each do |postal_code,electoral_districts|
11
7
  expect(GovKit::CA::PostalCode::Strategy::CBCCa.new(postal_code).electoral_districts).to eq(electoral_districts)
12
8
  end
13
9
  end
@@ -2,26 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  RSpec.describe GovKit::CA::PostalCode::Strategy::ConservativeCa do
4
4
  describe '#electoral_districts' do
5
- it 'should return the electoral districts within a postal code' do
6
- { 'T1P1K1' => [48010],
7
- 'K0A1K0' => [35025, 35052, 35063],
8
- }.each do |postal_code,electoral_districts|
9
- expect(GovKit::CA::PostalCode::Strategy::ConservativeCa.new(postal_code).electoral_districts).to eq(electoral_districts)
10
- end
11
- end
12
-
13
- it 'should (unfortunately) return false if a postal code is held by another party' do
14
- expect(GovKit::CA::PostalCode::Strategy::ConservativeCa.new('G0C2Y0').electoral_districts).to eq(false)
15
- expect(GovKit::CA::PostalCode::Strategy::ConservativeCa.new('T5S2B9').electoral_districts).to eq(false)
16
- expect(GovKit::CA::PostalCode::Strategy::ConservativeCa.new('B0J2L0').electoral_districts).to eq(false)
17
- end
18
-
19
- it 'should return false if a postal code contains no electoral districts' do
20
- expect(GovKit::CA::PostalCode::Strategy::ConservativeCa.new('H0H0H0').electoral_districts).to eq(false)
21
- end
22
-
23
- it 'should return false if a postal code does not exist' do
24
- expect(GovKit::CA::PostalCode::Strategy::ConservativeCa.new('X1B1B1').electoral_districts).to eq(false)
25
- end
5
+ pending
26
6
  end
27
7
  end
@@ -3,11 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  RSpec.describe GovKit::CA::PostalCode::Strategy::DigitalCopyrightCa do
4
4
  describe '#electoral_districts' do
5
5
  it 'should return the electoral districts within a postal code' do
6
- { 'G0C2Y0' => [24019, 24039], # too many 24019
7
- 'T5S2B9' => [48012, 48013, 48014, 48015, 48017, 48018], # too many 48015
8
- 'B0J2L0' => [12002, 12007, 12008],
9
- 'K0A1K0' => [35025, 35052, 35063],
10
- }.each do |postal_code,electoral_districts|
6
+ EXPECTATIONS[:digital_copyright_ca].each do |postal_code,electoral_districts|
11
7
  expect(GovKit::CA::PostalCode::Strategy::DigitalCopyrightCa.new(postal_code).electoral_districts).to eq(electoral_districts)
12
8
  end
13
9
  end
@@ -3,9 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  RSpec.describe GovKit::CA::PostalCode::Strategy::ElectionsCa do
4
4
  describe '#electoral_districts' do
5
5
  it 'should return the electoral districts within a postal code' do
6
- { 'G0C2Y0' => [24019],
7
- 'T5S2B9' => [48015],
8
- }.each do |postal_code,electoral_districts|
6
+ EXPECTATIONS[:elections_ca].each do |postal_code,electoral_districts|
9
7
  expect(GovKit::CA::PostalCode::Strategy::ElectionsCa.new(postal_code).electoral_districts).to eq(electoral_districts)
10
8
  end
11
9
  end
@@ -3,9 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  RSpec.describe GovKit::CA::PostalCode::Strategy::GreenPartyCa do
4
4
  describe '#electoral_districts' do
5
5
  it 'should return the electoral districts within a postal code' do
6
- { 'G0C2Y0' => [24026],
7
- 'T5S2B9' => [48031],
8
- }.each do |postal_code,electoral_districts|
6
+ EXPECTATIONS[:green_party_ca].each do |postal_code,electoral_districts|
9
7
  expect(GovKit::CA::PostalCode::Strategy::GreenPartyCa.new(postal_code).electoral_districts).to eq(electoral_districts)
10
8
  end
11
9
  end
@@ -3,11 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  RSpec.describe GovKit::CA::PostalCode::Strategy::LiberalCa do
4
4
  describe '#electoral_districts' do
5
5
  it 'should return the electoral districts within a postal code' do
6
- { 'G0C2Y0' => [24026],
7
- 'T5S2B9' => [48031],
8
- 'B0J2L0' => [12002], # too few
9
- 'K0A1K0' => [35076], # too few
10
- }.each do |postal_code,electoral_districts|
6
+ EXPECTATIONS[:liberal_ca].each do |postal_code,electoral_districts|
11
7
  expect(GovKit::CA::PostalCode::Strategy::LiberalCa.new(postal_code).electoral_districts).to eq(electoral_districts)
12
8
  end
13
9
  end
@@ -3,11 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  RSpec.describe GovKit::CA::PostalCode::Strategy::NDPCa do
4
4
  describe '#electoral_districts' do
5
5
  it 'should return the electoral districts within a postal code' do
6
- { 'G0C2Y0' => [24026],
7
- 'T5S2B9' => [48020, 48031], # too many 48031
8
- 'B0J2L0' => [12002], # too few
9
- 'K0A1K0' => [35031, 35076, 35088],
10
- }.each do |postal_code,electoral_districts|
6
+ EXPECTATIONS[:ndp_ca].each do |postal_code,electoral_districts|
11
7
  expect(GovKit::CA::PostalCode::Strategy::NDPCa.new(postal_code).electoral_districts).to eq(electoral_districts)
12
8
  end
13
9
  end
@@ -13,3 +13,44 @@ require File.dirname(__FILE__) + '/../lib/gov_kit-ca'
13
13
  RSpec.configure do |config|
14
14
  config.filter_run_excluding :broken => true
15
15
  end
16
+
17
+ EXPECTATIONS = {
18
+ conservative_ca: {
19
+ 'T1P1K1' => [48010],
20
+ 'K0A1K0' => [35025, 35052, 35063],
21
+ },
22
+ elections_ca: {
23
+ 'G0C2Y0' => [24026],
24
+ 'T5S2B9' => [48031],
25
+ },
26
+ green_party_ca: {
27
+ 'G0C2Y0' => [24026],
28
+ 'T5S2B9' => [48031],
29
+ },
30
+ liberal_ca: {
31
+ 'G0C2Y0' => [24026],
32
+ 'T5S2B9' => [48031],
33
+ 'B0J2L0' => [12002], # too few
34
+ 'K0A1K0' => [35076], # too few
35
+ },
36
+ ndp_ca: {
37
+ 'G0C2Y0' => [24026],
38
+ 'T5S2B9' => [48031],
39
+ 'B0J2L0' => [12002, 12008],
40
+ 'K0A1K0' => [35031, 35076],
41
+ },
42
+
43
+ # Deprecated.
44
+ cbc_ca: {
45
+ 'G0C2Y0' => [24019],
46
+ 'T5S2B9' => [48015, 48017],
47
+ 'B0J2L0' => [12002, 12007, 12008],
48
+ 'K0A1K0' => [35025, 35052, 35063, 35064],
49
+ },
50
+ digital_copyright_ca: {
51
+ 'G0C2Y0' => [24019, 24039],
52
+ 'T5S2B9' => [48012, 48013, 48014, 48015, 48017, 48018],
53
+ 'B0J2L0' => [12002, 12007, 12008],
54
+ 'K0A1K0' => [35025, 35052, 35063],
55
+ },
56
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govkit-ca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Open North
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-04 00:00:00.000000000 Z
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  version: '0'
191
191
  requirements: []
192
192
  rubyforge_project:
193
- rubygems_version: 2.2.2
193
+ rubygems_version: 2.4.5
194
194
  signing_key:
195
195
  specification_version: 4
196
196
  summary: Easy access to Canadian civic data around the web
@@ -207,3 +207,4 @@ test_files:
207
207
  - spec/represent_spec.rb
208
208
  - spec/spec_helper.rb
209
209
  - spec/strategy_set_spec.rb
210
+ has_rdoc: