govkit-ca 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/LICENSE +1 -1
  2. data/README.md +2 -2
  3. data/Rakefile +1 -1
  4. data/govkit-ca.gemspec +8 -8
  5. data/lib/gov_kit-ca/postal_code/strategy/base.rb +33 -1
  6. data/lib/gov_kit-ca/postal_code/strategy/{cbc-ca.rb → cbc_ca.rb} +6 -13
  7. data/lib/gov_kit-ca/postal_code/strategy/{conservative-ca.rb → conservative_ca.rb} +2 -4
  8. data/lib/gov_kit-ca/postal_code/strategy/digital-copyright_ca.rb +27 -0
  9. data/lib/gov_kit-ca/postal_code/strategy/{elections-ca.rb → elections_ca.rb} +2 -4
  10. data/lib/gov_kit-ca/postal_code/strategy/{greenparty-ca.rb → greenparty_ca.rb} +3 -5
  11. data/lib/gov_kit-ca/postal_code/strategy/{liberal-ca.rb → liberal_ca.rb} +3 -5
  12. data/lib/gov_kit-ca/postal_code/strategy/{ndp-ca.rb → ndp_ca.rb} +3 -5
  13. data/lib/gov_kit-ca/postal_code/strategy/{parl-gc-ca.rb → parl_gc_ca.rb} +3 -5
  14. data/lib/gov_kit-ca/postal_code/{strategy.rb → strategy_set.rb} +1 -7
  15. data/lib/gov_kit-ca/postal_code.rb +9 -3
  16. data/lib/gov_kit-ca/version.rb +1 -1
  17. data/lib/gov_kit-ca.rb +2 -1
  18. data/spec/cbc_ca_spec.rb +13 -6
  19. data/spec/digital-copyright_ca_spec.rb +32 -0
  20. data/spec/elections_ca_spec.rb +7 -0
  21. data/spec/fixtures/cbc_ca/A1A1A1.response +11 -0
  22. data/spec/fixtures/cbc_ca/G0C2Y0.response +11 -0
  23. data/spec/fixtures/cbc_ca/H0H0H0.response +309 -0
  24. data/spec/fixtures/cbc_ca/K0A1K0.response +11 -0
  25. data/spec/fixtures/cbc_ca/T5S2B9.response +11 -0
  26. data/spec/fixtures/cbc_ca/X1B1B1.response +309 -0
  27. data/spec/fixtures/conservative_ca/A1A1A1.response +467 -0
  28. data/spec/fixtures/conservative_ca/G0C2Y0.response +467 -0
  29. data/spec/fixtures/conservative_ca/H0H0H0.response +467 -0
  30. data/spec/fixtures/conservative_ca/K0A1K0.response +467 -0
  31. data/spec/fixtures/conservative_ca/T5S2B9.response +467 -0
  32. data/spec/fixtures/conservative_ca/X1B1B1.response +467 -0
  33. data/spec/fixtures/digital-copyright_ca/A1A1A1.response +262 -0
  34. data/spec/fixtures/digital-copyright_ca/G0C2Y0.response +263 -0
  35. data/spec/fixtures/digital-copyright_ca/H0H0H0.response +278 -0
  36. data/spec/fixtures/digital-copyright_ca/K0A1K0.response +264 -0
  37. data/spec/fixtures/digital-copyright_ca/T5S2B9.response +267 -0
  38. data/spec/fixtures/digital-copyright_ca/X1B1B1.response +278 -0
  39. data/spec/fixtures/elections_ca/A1A1A1.response +12 -0
  40. data/spec/fixtures/elections_ca/G0C2Y0.response +12 -0
  41. data/spec/fixtures/elections_ca/H0H0H0.response +11 -0
  42. data/spec/fixtures/elections_ca/K0A1K0.response +11 -0
  43. data/spec/fixtures/elections_ca/T5S2B9.response +12 -0
  44. data/spec/fixtures/elections_ca/X1B1B1.response +11 -0
  45. data/spec/fixtures/greenparty_ca/A1A1A1.response +13 -0
  46. data/spec/fixtures/greenparty_ca/G0C2Y0.response +13 -0
  47. data/spec/fixtures/greenparty_ca/H0H0H0.response +13 -0
  48. data/spec/fixtures/greenparty_ca/K0A1K0.response +13 -0
  49. data/spec/fixtures/greenparty_ca/T5S2B9.response +13 -0
  50. data/spec/fixtures/greenparty_ca/X1B1B1.response +13 -0
  51. data/spec/fixtures/liberal_ca/A1A1A1.response +582 -0
  52. data/spec/fixtures/liberal_ca/G0C2Y0.response +582 -0
  53. data/spec/fixtures/liberal_ca/H0H0H0.response +663 -0
  54. data/spec/fixtures/liberal_ca/K0A1K0.response +663 -0
  55. data/spec/fixtures/liberal_ca/T5S2B9.response +663 -0
  56. data/spec/fixtures/liberal_ca/X1B1B1.response +663 -0
  57. data/spec/fixtures/ndp_ca/A1A1A1.response +12 -0
  58. data/spec/fixtures/ndp_ca/G0C2Y0.response +12 -0
  59. data/spec/fixtures/ndp_ca/H0H0H0.response +12 -0
  60. data/spec/fixtures/ndp_ca/K0A1K0.response +12 -0
  61. data/spec/fixtures/ndp_ca/T5S2B9.response +12 -0
  62. data/spec/fixtures/ndp_ca/X1B1B1.response +12 -0
  63. data/spec/fixtures/parl_gc_ca/A1A1A1.response +337 -0
  64. data/spec/fixtures/parl_gc_ca/G0C2Y0.response +337 -0
  65. data/spec/fixtures/parl_gc_ca/H0H0H0.response +226 -0
  66. data/spec/fixtures/parl_gc_ca/K0A1K0.response +784 -0
  67. data/spec/fixtures/parl_gc_ca/T5S2B9.response +511 -0
  68. data/spec/fixtures/parl_gc_ca/X1B1B1.response +226 -0
  69. data/spec/greenparty_ca_spec.rb +7 -0
  70. data/spec/liberal_ca_spec.rb +10 -2
  71. data/spec/ndp_ca_spec.rb +7 -0
  72. data/spec/postal_code_spec.rb +13 -0
  73. data/spec/spec_helper.rb +13 -0
  74. data/spec/strategy_set_spec.rb +0 -0
  75. data/tasks/postal-code-for-districts.csv +212 -0
  76. data/tasks/tasks.rb +73 -0
  77. metadata +180 -98
  78. data/lib/gov_kit-ca/postal_code/strategy/digital_copyright-ca.rb +0 -28
  79. data/tasks/rid_to_edid.rb +0 -136
@@ -0,0 +1,226 @@
1
+ HTTP/1.1 200 OK
2
+ Cache-Control: private
3
+ Content-Type: text/html; charset=utf-8
4
+ Last-Modified: Wed, 02 Feb 2011 05:00:00 GMT
5
+ Server: Microsoft-IIS/7.0
6
+ X-Aspnet-Version: 2.0.50727
7
+ X-Powered-By: ASP.NET
8
+ Date: Sun, 05 Jun 2011 03:17:15 GMT
9
+ Connection: close
10
+ Content-Length: 15403
11
+
12
+
13
+
14
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
15
+
16
+ <html xmlns="http://www.w3.org/1999/xhtml" >
17
+ <head><title>
18
+ Find your Member of Parliament using your Postal Code
19
+ </title><link href="../../CSS/Main_Screen.css" rel="stylesheet" type="text/css" media="all" /><link href="../../CSS/Main_Print.css" rel="stylesheet" type="text/css" media="print" /><link id="ctl00_cssAllStyle" rel="stylesheet" type="text/css" media="all" href="../../CSS/compilations_Screen.css" /><link id="ctl00_cssPrintStyle" rel="stylesheet" type="text/css" media="print" href="../../CSS/compilations_Print.css" /><link href="../../CSS/Index.css" rel="stylesheet" type="text/css" media="all" /><link href="/Common/Parl/Styles/CommonElements.css" type="text/css" rel="stylesheet" media="screen" /></head>
20
+ <body style="background-color:white">
21
+ <form name="aspnetForm" method="post" action="MemberByPostalCode.aspx?PostalCode=X1B1B1" id="aspnetForm">
22
+ <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJMjEzNjczNDc3ZGQpm/tkoX0B50W588AiMpju7SMSbQ==" />
23
+
24
+
25
+ <script src="/ParlInfo/JS/Language_E.js" type="text/javascript"></script>
26
+ <script src="/ParlInfo/JS/MainTemplate.js" type="text/javascript"></script>
27
+ <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBQKV1JGcCQKXra4YAtyNkoUNApPP9foMAvCHuoIPxV8wYm5VBdKvq9wXOMJMAfiAQ6w=" />
28
+ <a id="PageTop"></a><!--This is an anchor used to return to the top of the page-->
29
+
30
+
31
+ <div id="ctl00_ParlHeader">
32
+
33
+ <div class="parlwebsite-toolbar">
34
+ <div class="parlwebsite-logo-area">
35
+ <span class="parlwebsite-homeimage parlwebsite-homeimage-en-CA" title="Parliament of Canada">
36
+ <div><br /><strong>Parliament of Canada</strong><br /><br /></div>
37
+ </span>
38
+ </div>
39
+ <div class="parlwebsite-utility-links">
40
+ <a href="http://www.parl.gc.ca/SiteMap.aspx?Language=E" tabindex="3">Site Map</a> |
41
+ <a href="http://www.parl.gc.ca/ParlInfo/AboutParliamentIndex.aspx?Language=E" tabindex="4">A to Z Index</a> |
42
+ <a href="http://www.parl.gc.ca/ContactUs.aspx?Language=E" tabindex="5">Contact Us</a> |
43
+ <a id="parlwebsite-language-link" href="/ParlInfo/Compilations/HouseOfCommons/MemberByPostalCode.aspx?PostalCode=X1B1B1&Language=F" title="Fran&ccedil;ais" tabindex="6">Fran&ccedil;ais</a>
44
+ <div class="parlwebsite-search-area">
45
+ <input name="ctl00$ctl05$searchTextbox" type="text" id="ctl00_ctl05_searchTextbox" /><input type="submit" name="ctl00$ctl05$searchButton" value="Search" id="ctl00_ctl05_searchButton" class="test" skipSetLanguage="true" />
46
+ <a href="http://www.parl.gc.ca/Search/Advanced.aspx?Language=E" class="parlwebsite-adv-search">Advanced Search</a>
47
+ </div>
48
+ </div>
49
+ <div class="parlwebsite-nav">
50
+ <a href="http://www.parl.gc.ca/Default.aspx?Language=E" tabindex="7">Home</a> |
51
+ <a href="http://www.parl.gc.ca/ParlBusiness.aspx?Language=E" tabindex="8">Parliamentary Business</a> |
52
+ <a href="http://www.parl.gc.ca/SenatorsMembers.aspx?Language=E" tabindex="9">Senators and Members</a> |
53
+ <a href="http://www.parl.gc.ca/About.aspx?Language=E" tabindex="10">About Parliament</a> |
54
+ <a href="http://www.parl.gc.ca/Visitors/index-E.asp" tabindex="11">Visitor Information</a> |
55
+ <a href="http://www.parl.gc.ca/EmploymentOpportunities/Default.aspx?Language=E" tabindex="12">Employment</a>
56
+ </div>
57
+ </div>
58
+
59
+ </div>
60
+
61
+
62
+ <div id="ctl00_pnlHeader" class="pnlHeaderCentered">
63
+
64
+ <!---->
65
+ <img id="ctl00_Image3" class="IMGTEST2" src="../../images/loptopleft-e.gif" alt=" Parliament of Canada" border="0" />
66
+ </div>
67
+
68
+ <div id="ctl00_pnlMain" class="parlwebsite-parlinfo-body">
69
+
70
+ <div id="ctl00_pnlMenu" class="pnlMenu">
71
+
72
+ <div id="ctl00_pnlMenuContent" class="pnlMenuContent">
73
+
74
+
75
+
76
+ <div id="ctl00_cphRootMenu_ctl00_pnlRootHomeMenu" class="MenuItemSelected">
77
+
78
+ <a id="ctl00_cphRootMenu_ctl00_lnkRootHomeMenu" class="MenuItemLinkSelected" href="../../default.aspx?Menu=Home">PARLINFO - Home</a>
79
+
80
+ </div>
81
+ <div id="ctl00_cphRootMenu_ctl00_pnlRootSitemapMenu" class="MenuSubItem">
82
+
83
+ <a id="ctl00_cphRootMenu_ctl00_lnkRootSitemapMenu" class="MenuSubItemLink" href="../../Sitemap.aspx">Sitemap of ParlInfo</a>
84
+
85
+ </div>
86
+ <div id="ctl00_cphRootMenu_ctl00_pnlRootIndexMenux" class="MenuSubItem">
87
+
88
+ <a id="ctl00_cphRootMenu_ctl00_lnkRootIndexMenu" class="MenuSubItemLink" href="../../AboutParliamentIndex.aspx">A to Z Index</a>
89
+
90
+ </div>
91
+
92
+
93
+
94
+
95
+
96
+ <div id="ctl00_cphMenu_ctl00" class="Menu">
97
+ <div id="ctl00_cphMenu_divMenudefault.aspx.Menu=Home" class="MenuItemInvisible"><a id="ctl00_cphMenu_lnkdefault.aspx.Menu=Home" class="MenuItemInvisibleLink" href="../../default.aspx?Menu=Home">PARLINFO - Home</a></div>
98
+ <div id="ctl00_cphMenu_divMenupages.parliament.aspx.Menu=Parliament" class="MenuItem"><a id="ctl00_cphMenu_lnkpages.parliament.aspx.Menu=Parliament" class="MenuItemLink" href="../../pages/parliament.aspx?Menu=Parliament">Parliament</a></div>
99
+ <div id="ctl00_cphMenu_divMenupages.govgeneral.aspx.Menu=GG" class="MenuItem"><a id="ctl00_cphMenu_lnkpages.govgeneral.aspx.Menu=GG" class="MenuItemLink" href="../../pages/govgeneral.aspx?Menu=GG">Governor General </a></div>
100
+ <div id="ctl00_cphMenu_divMenucompilations.senate.aspx.Menu=Senate" class="MenuItem"><a id="ctl00_cphMenu_lnkcompilations.senate.aspx.Menu=Senate" class="MenuItemLink" href="../senate.aspx?Menu=Senate">Senate</a></div>
101
+ <div id="ctl00_cphMenu_divMenucompilations.HouseOfCommons.aspx.Menu=HoC" class="MenuItem"><a id="ctl00_cphMenu_lnkcompilations.HouseOfCommons.aspx.Menu=HoC" class="MenuItemLink" href="../HouseOfCommons.aspx?Menu=HoC">House of Commons</a></div>
102
+ <div id="ctl00_cphMenu_divMenupages.federalgovernment.aspx.Menu=Federal" class="MenuItem"><a id="ctl00_cphMenu_lnkpages.federalgovernment.aspx.Menu=Federal" class="MenuItemLink" href="../../pages/federalgovernment.aspx?Menu=Federal">Federal Government</a></div>
103
+ <div id="ctl00_cphMenu_divMenucompilations.Constitution.aspx.Menu=Constitution" class="MenuItem"><a id="ctl00_cphMenu_lnkcompilations.Constitution.aspx.Menu=Constitution" class="MenuItemLink" href="../Constitution.aspx?Menu=Constitution">Constitution</a></div>
104
+ <div id="ctl00_cphMenu_divMenucompilations.legislation.aspx.Menu=Legislation" class="MenuItem"><a id="ctl00_cphMenu_lnkcompilations.legislation.aspx.Menu=Legislation" class="MenuItemLink" href="../legislation.aspx?Menu=Legislation">Legislation</a></div>
105
+ <div id="ctl00_cphMenu_divMenuCompilations.ElectionsAndRidings.aspx.Menu=ElectionsRidings" class="MenuItemSelected"><a id="ctl00_cphMenu_lnkCompilations.ElectionsAndRidings.aspx.Menu=ElectionsRidings" class="MenuItemLinkSelected" href="../ElectionsAndRidings.aspx?Menu=ElectionsRidings">Elections and Ridings</a></div>
106
+ <div id="ctl00_cphMenu_divMenuCompilations.ElectionsAndRidings.Elections.aspx.Menu=ElectionsRidings-Election" class="MenuSubItemWithChildren"><a id="ctl00_cphMenu_lnkCompilations.ElectionsAndRidings.Elections.aspx.Menu=ElectionsRidings-Election" class="MenuSubItemWithChildrenLink" href="../ElectionsAndRidings/Elections.aspx?Menu=ElectionsRidings-Election">Elections</a></div>
107
+ <div id="ctl00_cphMenu_divMenu-.Menu=ElectionsRidings-ElectionResults" class="MenuSubItemWithChildren"><a id="ctl00_cphMenu_lnk-.Menu=ElectionsRidings-ElectionResults" class="MenuSubItemWithChildrenLink" href="../ElectionsAndRidings/ResultsParty.aspx">Electoral Results</a></div>
108
+ <div id="ctl00_cphMenu_divMenu-.Menu=ElectionsRidings-Riding" class="MenuSubItemWithChildrenSelected"><a id="ctl00_cphMenu_lnk-.Menu=ElectionsRidings-Riding" class="MenuSubItemWithChildrenLinkSelected" href="MemberByPostalCode.aspx">Ridings / Constituencies</a></div>
109
+ <div id="ctl00_cphMenu_divMenuCompilations.HouseOfCommons.MemberByPostalCode.aspx" class="MenuSubSubItemSelected"><a id="ctl00_cphMenu_lnkCompilations.HouseOfCommons.MemberByPostalCode.aspx" class="MenuSubSubItemLinkSelected" href="MemberByPostalCode.aspx">Find your Member of Parliament using your Postal Code</a></div>
110
+ <div id="ctl00_cphMenu_divMenuCompilations.ElectionsAndRidings.ConstituencyProvince.aspx" class="MenuSubSubItem"><a id="ctl00_cphMenu_lnkCompilations.ElectionsAndRidings.ConstituencyProvince.aspx" class="MenuSubSubItemLink" href="../ElectionsAndRidings/ConstituencyProvince.aspx">Federal Electoral Constituencies by Province</a></div>
111
+ <div id="ctl00_cphMenu_divMenuCompilations.HouseOfCommons.Legislation.LegislationElectoralDistrict.aspx.Menu=ElectionsRidings-Legislation" class="MenuSubSubItem"><a id="ctl00_cphMenu_lnkCompilations.HouseOfCommons.Legislation.LegislationElectoralDistrict.aspx.Menu=ElectionsRidings-Legislation" class="MenuSubSubItemLink" href="Legislation/LegislationElectoralDistrict.aspx?Menu=ElectionsRidings-Legislation">Legal Measures Governing Changes in Federal Electoral Districts</a></div>
112
+ <div id="ctl00_cphMenu_divMenu.About.Parliament.FederalRidingsHistory.HFER.asp" class="MenuSubSubItem"><a id="ctl00_cphMenu_lnk.About.Parliament.FederalRidingsHistory.HFER.asp" class="MenuSubSubItemLink" href="/About/Parliament/FederalRidingsHistory/HFER.asp">History of the federal electoral ridings</a></div>
113
+ <div id="ctl00_cphMenu_divMenucompilations.PoliticalParties.PoliticalParties.aspx.Menu=Party" class="MenuItem"><a id="ctl00_cphMenu_lnkcompilations.PoliticalParties.PoliticalParties.aspx.Menu=Party" class="MenuItemLink" href="../PoliticalParties/PoliticalParties.aspx?Menu=Party">Political Parties</a></div>
114
+ <div id="ctl00_cphMenu_divMenucompilations.ProvinceTerritory.aspx.Menu=ProvinceTerritory" class="MenuItem"><a id="ctl00_cphMenu_lnkcompilations.ProvinceTerritory.aspx.Menu=ProvinceTerritory" class="MenuItemLink" href="../ProvinceTerritory.aspx?Menu=ProvinceTerritory">Provinces and Territories</a></div>
115
+ <div id="ctl00_cphMenu_divMenuCompilations.SupremeCourt.aspx.Menu=SupremeCourt" class="MenuItem"><a id="ctl00_cphMenu_lnkCompilations.SupremeCourt.aspx.Menu=SupremeCourt" class="MenuItemLink" href="../SupremeCourt.aspx?Menu=SupremeCourt&amp;Current=True">Supreme Court of Canada</a></div>
116
+
117
+ </div>
118
+
119
+ </div>
120
+ <img id="ctl00_Image1" src="../../images/leftnavbottom.gif" alt=" " height="22" width="200" border="0" />
121
+
122
+
123
+ <div id="ctl00_pnlMenuBottom" class="pnlMenuBottom">
124
+
125
+ <div id="ctl00_pnlWhatIsNew">
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ </div>
134
+
135
+ </div>
136
+
137
+ </div>
138
+
139
+ <!-- Related Links -->
140
+
141
+
142
+
143
+ <!-- END Related Links -->
144
+
145
+ <div id="ctl00_pnlContent" class="pnlContent">
146
+
147
+
148
+ <img id="ctl00_imgImageSection" class="imgBrandRight" src="../../images/SectionImage/ElectionsRidings.jpg" alt="Elections and Ridings Section" height="80" width="100" border="0" />
149
+
150
+ <div id="ctl00_pnlBreadCrumpsHolder" class="BreadCrumbsHolder">
151
+
152
+
153
+ <div id="ctl00_cphBreadcrumbs_ctl00" class="Bread">
154
+ <div id="ctl00_cphBreadcrumbs_divBreadCompilations.ElectionsAndRidings.aspx.Menu=ElectionsRidings" class="BreadItem"><a id="ctl00_cphBreadcrumbs_lnkCompilations.ElectionsAndRidings.aspx.Menu=ElectionsRidings" class="BreadItemLink" href="../ElectionsAndRidings.aspx?Menu=ElectionsRidings">Elections and Ridings</a></div>
155
+ <div id="ctl00_cphBreadcrumbs_divBread-.Menu=ElectionsRidings-Riding" class="BreadSubItemWithChildren"><a id="ctl00_cphBreadcrumbs_lnk-.Menu=ElectionsRidings-Riding" class="BreadSubItemWithChildrenLink" href="MemberByPostalCode.aspx">Ridings / Constituencies</a></div>
156
+ <div id="ctl00_cphBreadcrumbs_divBreadCompilations.HouseOfCommons.MemberByPostalCode.aspx" class="BreadSubSubItem"><a id="ctl00_cphBreadcrumbs_lnkCompilations.HouseOfCommons.MemberByPostalCode.aspx" class="BreadSubSubItemLink" href="MemberByPostalCode.aspx">Find your Member of Parliament using your Postal Code</a></div>
157
+
158
+ </div>
159
+
160
+ </div>
161
+
162
+ <div id="ctl00_cphContent_HeaderWithoutPicture1_pnlHeader" class="pnlListHeader">
163
+
164
+ <span id="ctl00_cphContent_HeaderWithoutPicture1_lblTitle" class="lblTitle" style="display:inline-block;">Find your Member of Parliament using your Postal Code</span>
165
+
166
+ <div class="pnlRelatedLinks"><span Class="RelatedTitle">Selected Links</span>
167
+ <a href="http://www.pch.gc.ca/pgm/ceem-cced/prtcl/address2-eng.cfm" Class="RelatedLink">Styles of address - Federal dignitaries</a>
168
+ </div>
169
+
170
+ <div id="ctl00_cphContent_HeaderWithoutPicture1_pnlListHeaderNotes" class="pnlListHeaderNote">
171
+
172
+ <span id="ctl00_cphContent_HeaderWithoutPicture1_lblNotes"><P><STRONG>Note</STRONG>: If your postal code returns more than one result, please consult <A href="http://www.elections.ca/scripts/pss/FindED.aspx?L=e&amp;PC=&amp;image.x=20&amp;image.y=11">Elections Canada</A>'s advanced search function.</P>
173
+ <P><STRONG>Source</STRONG>: Statistics Canada -&nbsp;October 2010</P></span>
174
+
175
+
176
+ </div>
177
+
178
+ </div>
179
+
180
+ <div id="ctl00_cphContent_pnlListHeaderCriterias" class="pnlListHeaderCriteria">
181
+
182
+ <span id="ctl00_cphContent_lblCriteria" class="lblCriteria" style="display:inline-block;">Search Criteria</span>
183
+ <div id="ctl00_cphContent_pnlPostalCriteria" class="CriteriaSeparator">
184
+
185
+ <label for="ctl00_cphContent_txtPostalCriteria" id="ctl00_cphContent_lblPostalCriteria" class="CriteriaSeparatorTitleSection">Postal Code (eg. A1A1A1):</label>
186
+ <input name="ctl00$cphContent$txtPostalCriteria" type="text" value="X1B1B1" maxlength="7" id="ctl00_cphContent_txtPostalCriteria" />
187
+
188
+ </div>
189
+
190
+ <div id="ctl00_cphContent_pnlRefreshList" class="CriteriaSeparatorButton">
191
+
192
+ <input type="submit" name="ctl00$cphContent$btnRefreshList" value="Search" id="ctl00_cphContent_btnRefreshList" class="test" />
193
+
194
+ </div>
195
+
196
+ </div>
197
+
198
+
199
+
200
+
201
+
202
+ <a href="/ParlInfo/Compilations/HouseOfCommons/MemberByPostalCode.aspx?PostalCode=X1B1B1#PageTop" id="ctl00_BackToTopArrow2_BackToTopLink" class="BackToTopArrowFooter" title="Back to top of document">^</a>
203
+
204
+ </div>
205
+
206
+ </div>
207
+
208
+
209
+
210
+ <div id="ctl00_ParlFooter">
211
+
212
+ <div class="parlwebsite-footer">
213
+ <a href="http://www.parl.gc.ca/Default.aspx?Language=E">Home</a> |
214
+ <a href="http://www.parl.gc.ca/ImportantNotices.aspx?Language=E">Important Notices</a>
215
+ </div>
216
+
217
+ </div>
218
+
219
+
220
+ <script type="text/javascript">
221
+ //<![CDATA[
222
+ doPopups();//]]>
223
+ </script>
224
+ </form>
225
+ </body>
226
+ </html>
@@ -3,6 +3,13 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  class GovKit::CA::PostalCode::Strategy::GreenPartyCa
4
4
  describe GovKit::CA::PostalCode::Strategy::GreenPartyCa do
5
5
  describe '#electoral_districts' do
6
+ before :all do
7
+ %w(G0C2Y0 T5S2B9 K0A1K0 H0H0H0 X1B1B1).each do |postal_code|
8
+ strategy = GovKit::CA::PostalCode::Strategy::GreenPartyCa.new(postal_code)
9
+ FakeWeb.register_uri strategy.class.http_method, "#{strategy.class.base_uri}#{strategy.send(:path)}", :response => fixture_path('greenparty_ca', "#{postal_code}.response")
10
+ end
11
+ end
12
+
6
13
  it 'should return the electoral districts within a postal code' do
7
14
  { 'G0C2Y0' => [24019],
8
15
  'T5S2B9' => [48015], # differs from cbc.ca
@@ -1,11 +1,19 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require 'gov_kit-ca/postal_code/strategy/liberal_ca'
2
3
 
3
4
  class GovKit::CA::PostalCode::Strategy::LiberalCa
4
5
  describe GovKit::CA::PostalCode::Strategy::LiberalCa do
5
6
  describe '#electoral_districts' do
7
+ before :all do
8
+ %w(G0C2Y0 T5S2B9 K0A1K0 H0H0H0 X1B1B1).each do |postal_code|
9
+ strategy = GovKit::CA::PostalCode::Strategy::LiberalCa.new(postal_code)
10
+ FakeWeb.register_uri strategy.class.http_method, "#{strategy.class.base_uri}#{strategy.send(:path)}", :response => fixture_path('liberal_ca', "#{postal_code}.response")
11
+ end
12
+ end
13
+
6
14
  it 'should return the electoral districts within a postal code' do
7
- { 'G0C2Y0' => [24019],
8
- 'T5S2B9' => [48015, 48017], # differs from elections.ca, ndp.ca
15
+ { 'G0C2Y0' => [24019], # this postal code intermittently fails
16
+ 'T5S2B9' => [48015, 48017], # differs from elections.ca, ndp.ca, greenparty.ca
9
17
  'K0A1K0' => [35012, 35025, 35040, 35052, 35063, 35064, 35087],
10
18
  }.each do |postal_code,electoral_districts|
11
19
  GovKit::CA::PostalCode::Strategy::LiberalCa.new(postal_code).electoral_districts.should == electoral_districts
data/spec/ndp_ca_spec.rb CHANGED
@@ -3,6 +3,13 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  class GovKit::CA::PostalCode::Strategy::NDPCa
4
4
  describe GovKit::CA::PostalCode::Strategy::NDPCa do
5
5
  describe '#electoral_districts' do
6
+ before :all do
7
+ %w(G0C2Y0 T5S2B9 K0A1K0 H0H0H0 X1B1B1).each do |postal_code|
8
+ strategy = GovKit::CA::PostalCode::Strategy::NDPCa.new(postal_code)
9
+ FakeWeb.register_uri strategy.class.http_method, "#{strategy.class.base_uri}#{strategy.send(:path)}", :response => fixture_path('ndp_ca', "#{postal_code}.response")
10
+ end
11
+ end
12
+
6
13
  it 'should return the electoral districts within a postal code' do
7
14
  { 'G0C2Y0' => [24019],
8
15
  'T5S2B9' => [48015], # differs from cbc.ca
@@ -29,6 +29,19 @@ module GovKit::CA::PostalCode
29
29
  end
30
30
 
31
31
  describe '#find_electoral_districts_by_postal_code' do
32
+ before :all do
33
+ { 'ElectionsCa' => 'elections_ca',
34
+ 'CBCCa' => 'cbc_ca',
35
+ 'NDPCa' => 'ndp_ca',
36
+ 'GreenPartyCa' => 'greenparty_ca',
37
+ }.each do |const,path|
38
+ %w(A1A1A1 K0A1K0 H0H0H0).each do |postal_code|
39
+ strategy = GovKit::CA::PostalCode::Strategy.const_get(const).new(postal_code)
40
+ FakeWeb.register_uri strategy.class.http_method, "#{strategy.class.base_uri}#{strategy.send(:path)}", :response => fixture_path(path, "#{postal_code}.response")
41
+ end
42
+ end
43
+ end
44
+
32
45
  it 'should return the electoral districts within a postal code' do
33
46
  { 'A1A1A1' => [10007],
34
47
  'K0A1K0' => [35012, 35025, 35040, 35052, 35063, 35064, 35087],
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,16 @@
1
1
  require 'rubygems'
2
2
  require 'rspec'
3
+ require 'fakeweb'
3
4
  require File.dirname(__FILE__) + '/../lib/gov_kit-ca'
5
+
6
+ FakeWeb.allow_net_connect = false
7
+
8
+ module Helpers
9
+ def fixture_path(*args)
10
+ File.join(File.dirname(__FILE__), 'fixtures', *args)
11
+ end
12
+ end
13
+
14
+ RSpec.configure do |config|
15
+ config.include Helpers
16
+ end
File without changes
@@ -0,0 +1,212 @@
1
+ A0A1C0
2
+ A0A1H0
3
+ A0H1A0
4
+ A0K1N0
5
+ B0C1C0
6
+ B0J1N0
7
+ B0J2M0
8
+ B2W1Z1
9
+ B3K2V1
10
+ B4A3V1
11
+ C0A1A0
12
+ C0A1C0
13
+ C0B1B0
14
+ C1A1A1
15
+ E1A1A3
16
+ E1N1A1
17
+ E1W1A1
18
+ E2E1A1
19
+ E2M4X7
20
+ E2V1A1
21
+ E3A0B3
22
+ E3N1A1
23
+ G0A4V0
24
+ G0E1C0
25
+ G0L3T0
26
+ G0M1C0
27
+ G0R1A0
28
+ G0S1G0
29
+ G0V1B0
30
+ G0W1B0
31
+ G0W3B0
32
+ G1A1A1
33
+ G1J2Y9
34
+ G1Y3N1
35
+ G2L2R1
36
+ G4R1N1
37
+ G8T1A1
38
+ H1A1A2
39
+ H1C1H2
40
+ H1H1B1
41
+ H1R1Y5
42
+ H1W3K2
43
+ H1Z2V8
44
+ H2K4G2
45
+ H2R2Z2
46
+ H2S3C2
47
+ H2Y3Y8
48
+ H3X4A3
49
+ H4E1A8
50
+ H4J1A1
51
+ H4Y1J4
52
+ H7A2M2
53
+ H7H1A1
54
+ H7P4B7
55
+ H7R4W1
56
+ H8S4L2
57
+ H8Y1A1
58
+ J0B2P0
59
+ J0B2T0
60
+ J0E1Z0
61
+ J0J1G0
62
+ J0K1B0
63
+ J0L2K0
64
+ J0N1H0
65
+ J0P1B0
66
+ J0R1A0
67
+ J0Y1A0
68
+ J1E2Z1
69
+ J3V1A1
70
+ J4B1A2
71
+ J4V1Z1
72
+ J8P1A1
73
+ J8Y6W1
74
+ J9E1R1
75
+ K0A1K0
76
+ K0A2W0
77
+ K0H1M0
78
+ K0K1B0
79
+ K0L1A0
80
+ K1A0A4
81
+ K1M0E1
82
+ K2A1A6
83
+ L0B1A0
84
+ L0G1W0
85
+ L0J1A0
86
+ L0J1C0
87
+ L0K1E0
88
+ L0M1G0
89
+ L0P1B0
90
+ L0R1T0
91
+ L0S1B0
92
+ L1H1X8
93
+ L2M1A1
94
+ L3P1A1
95
+ L3T3M9
96
+ L3X1A4
97
+ L4K5Z5
98
+ L4M1A1
99
+ L4T4K3
100
+ L4X1A1
101
+ L4Y2A1
102
+ L5B1C2
103
+ L5N3S2
104
+ L6M1B2
105
+ L6S4Z8
106
+ L7A1M2
107
+ L7P1L5
108
+ L8E1A1
109
+ M1B1A1
110
+ M1B1E9
111
+ M1E5G4
112
+ M1H1A1
113
+ M1P4Z5
114
+ M1T3V5
115
+ M1V5H4
116
+ M2R2G4
117
+ M4A1P1
118
+ M4E3X7
119
+ M4K1H1
120
+ M4S3E2
121
+ M5V2E1
122
+ M6A1G1
123
+ M6K3A1
124
+ M6P3P2
125
+ M8W3Y1
126
+ M9A5H5
127
+ M9N3P7
128
+ M9W2A1
129
+ N0A1C0
130
+ N0B1E0
131
+ N0G1B0
132
+ N0M2S0
133
+ N0P1J0
134
+ N0R1K0
135
+ N2A3Y4
136
+ N2J5A1
137
+ N5Y3Z1
138
+ N5Z4Y1
139
+ N6J2Z1
140
+ N9A6R1
141
+ P0J1A0
142
+ P0M1E0
143
+ P0R1C0
144
+ P0T1A0
145
+ P3G1B1
146
+ R0B0A0
147
+ R0G1P0
148
+ R2C2Z2
149
+ R2H3B8
150
+ R2N1Z4
151
+ R2P0A1
152
+ R2Y0A1
153
+ R3H0C1
154
+ S0A0X0
155
+ S0A3E0
156
+ S0A3J0
157
+ S0G0G0
158
+ S0G0J0
159
+ S0G0N0
160
+ S0H0B0
161
+ S0J0J0
162
+ S0J2M0
163
+ S0K0H0
164
+ S0M2E0
165
+ T0A2H1
166
+ T0B3M0
167
+ T0G1E0
168
+ T0J0B0
169
+ T0K0K0
170
+ T0M0E0
171
+ T2A1L5
172
+ T2H2Z1
173
+ T2J7A1
174
+ T3B5C4
175
+ T5A0A3
176
+ T5S0A6
177
+ T6C0J1
178
+ T9M1H1
179
+ V0A1A0
180
+ V0C1B0
181
+ V0E1A0
182
+ V0E1C0
183
+ V0E1S0
184
+ V0G1A0
185
+ V0J1N0
186
+ V0N1A0
187
+ V0N1B0
188
+ V0N1P0
189
+ V0R2L0
190
+ V1P1A1
191
+ V2V7G9
192
+ V2Y3A7
193
+ V3B1A1
194
+ V3J1A1
195
+ V3M1A4
196
+ V3R0A1
197
+ V4A1B1
198
+ V4C3Y2
199
+ V4N2N1
200
+ V4X2L3
201
+ V5K4A6
202
+ V5P1N8
203
+ V5R4P2
204
+ V5T1A1
205
+ V6M3N4
206
+ V6V1G4
207
+ V6X4E8
208
+ V7K1G2
209
+ V8N1A6
210
+ X0A0A0
211
+ X0E0A0
212
+ Y0A1B0
data/tasks/tasks.rb ADDED
@@ -0,0 +1,73 @@
1
+ require File.expand_path('../../lib/gov_kit-ca', __FILE__)
2
+
3
+ # The following file maps 629,605 postal codes to electoral districts:
4
+ # https://github.com/danielharan/canadian-postal-code-to-electoral-districts/raw/master/pc_edid.yml
5
+ # However, it contains invalid postal codes, such as M5V1L6, and doesn't contain
6
+ # every electoral district, such as 35061 (postal code L1H1X8).
7
+ #
8
+ # http://www.digital-copyright.ca/pcfrf/pcfrf.tgz contains
9
+ # postal-code-for-districts.csv, "which is 308 postal codes that should map to
10
+ # each of the 308 different electoral districts." However, six of them do not
11
+ # exist (G0A2C0, J8M1R8, J0W1B0, J0B1H0, L0J1B0, N2A1A3), 14 are duplicate, and
12
+ # the remaining 294 map to 246 electoral districts.
13
+ #
14
+ # The included tasks/postal-code-for-districts.csv covers 275 electoral
15
+ # districts at the time of writing.
16
+ desc "Picks the set cover for postal codes to electoral districts"
17
+ task :trim_postal_codes, :file do |t,args|
18
+ abort "Usage: rake #{t.name}[postal-code-for-districts.csv]" unless args[:file]
19
+
20
+ # Get the electoral districts that each postal code covers
21
+ postal_to_edid = {}
22
+ File.read(args[:file]).split("\n").uniq.each do |postal_code| # Remove duplicate postal codes
23
+ postal_to_edid[postal_code] = GovKit::CA::PostalCode.find_electoral_districts_by_postal_code(postal_code)
24
+ end
25
+
26
+ size = postal_to_edid.values.flatten.uniq.size
27
+ if size < 308
28
+ puts "Postal codes cover #{size} of 308 electoral districts."
29
+ end
30
+
31
+ # Get the minimum number of postal codes to cover all electoral districts.
32
+ # This is an instance of the set cover problem, which is NP-complete. Use the
33
+ # greedy algorithm, which is the best-possible polynomial time approximation
34
+ # algorithm for set cover. http://en.wikipedia.org/wiki/Set_cover_problem
35
+ postal_codes = []
36
+ until postal_to_edid.empty?
37
+ postal_code, edids = postal_to_edid.max{|_,v| v.size}
38
+ postal_to_edid.each{|k,v| postal_to_edid[k] -= edids}
39
+ postal_to_edid.reject!{|k,v| v.empty?}
40
+ postal_codes << postal_code
41
+ end
42
+
43
+ puts postal_codes.sort
44
+ end
45
+
46
+ desc "Generate RSpec fixtures"
47
+ task :generate_rspec_fixtures do |t,args|
48
+ require 'gov_kit-ca/postal_code/strategy/conservative_ca'
49
+ require 'gov_kit-ca/postal_code/strategy/digital-copyright_ca'
50
+ require 'gov_kit-ca/postal_code/strategy/liberal_ca'
51
+ require 'gov_kit-ca/postal_code/strategy/parl_gc_ca'
52
+
53
+ { 'CBCCa' => 'cbc_ca',
54
+ 'ConservativeCa' => 'conservative_ca',
55
+ 'DigitalCopyrightCa' => 'digital-copyright_ca',
56
+ 'ElectionsCa' => 'elections_ca',
57
+ 'GreenPartyCa' => 'greenparty_ca',
58
+ 'LiberalCa' => 'liberal_ca',
59
+ 'NDPCa' => 'ndp_ca',
60
+ 'ParlGcCa' => 'parl_gc_ca',
61
+ }.each do |const,path|
62
+ %w(A1A1A1 G0C2Y0 T5S2B9 K0A1K0 H0H0H0 X1B1B1).each do |postal_code|
63
+ File.open(File.expand_path("../../spec/fixtures/#{path}/#{postal_code}.response", __FILE__), 'w') do |f|
64
+ response = GovKit::CA::PostalCode::Strategy.const_get(const).new(postal_code).send(:response)
65
+ f.write "HTTP/#{response.http_version} #{response.code} #{response.message}\n"
66
+ response.headers.each_capitalized do |name,value|
67
+ f.write "#{name}: #{value}\n"
68
+ end
69
+ f.write "\n#{response.body}"
70
+ end
71
+ end
72
+ end
73
+ end